We have a project which to ease development uses node to handle some dependencies as well as our test scripts to spin up a docker image to run tests. The goal is that the devs don't need to run bats
locally and can just run npm test
which'll spin up the image and run tests.
I can get it working locally in my Git Bash multiple ways - however I cannot get it working via the npm script - it's caused me a day or 2 now of spamming different SO approaches to try and tackle. Here's what I'm working with:
{
"scripts": {
"test": "bats test/**/*.bats",
"test-ci": "bats --formatter junit -T test/**/*.bats",
"test-docker": "docker run -it -v /c/source/git/devops/dotnetcore-nuget-push/:/app node:slim npm test",
"test-docker-test": "docker run -it -v $(pwd):/app -w //app node:slim npm test",
"test-docker-debug": "docker run -it -v /c/source/git/devops/dotnetcore-nuget-push:/app -w //app node:slim bash -c \"echo $(pwd) && ls\"",
"test-docker2": "docker run -it -v /c/source/git/devops/dotnetcore-nuget-push/:/app -w //app node:slim npm test",
},
}
Ideally we'll just have test
in the end - just trying a few things to make sure they work the same.
Here's what works locally in Git Bash:
docker run -it -v /$(pwd):/app -w //app node:slim npm test
docker run -it -v /$(pwd):/$(pwd) -w /$(pwd) node:slim npm test
MSYS_NO_PATHCONV=1 docker run -it -v $(pwd):$(pwd) -w $(pwd) node:slim npm test
So I've tried adding some of those and a debugging one to my npm scripts but the only thing that works is when I hardcode the volume path -v /c/source/git/devops/dotnetcore-nuget-push/:/app
. Ideally this wouldn't be hard coded but when I use $(pwd)
I get errors that it can't find my package.json now.. here's it using $(pwd)
instead of hard coded path - it tries to look in the workdir/app path - however the workdir IS app, it should be looking for the package.json
right where the app is mounted - similar to how it is when I do the hard coded path.
I've looked at the following resources - but none are using npm