I'm trying to use gitlab CI/CD and make a yml-file that will run all tests in the frontend. The problem is I get the error
npm ERR! enoent ENOENT: no such file or directory, open '{path}\{branch}\package.json
Which makes sense, because the package.json is not in {branch} (the branch), but in {branch}/myreactapp. So the path should have been {branch}/myreactapp/package.json. How do I solve this?
yml-file:
stages: ["test", "deploy"]
test:
stage: test
script: npm run test
deploy:
stage: deploy
script: npm run deploy
I already tried before_script: - npm install and before_script: - npm init and also both combined.
Reproducing: I made a react.js project in my branch and added a test.test.js file and put a test in there that always passes.
it('works ', () => {});
And than I just tried to run the pipeline. Also changed (jest was react-scripts test) in package.json-file
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "jest",
"eject": "react-scripts eject"
}
