Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get lesson 2 tests to initiate. #77

Open
Connor-Flewitt opened this issue Oct 12, 2021 · 6 comments
Open

Cannot get lesson 2 tests to initiate. #77

Connor-Flewitt opened this issue Oct 12, 2021 · 6 comments

Comments

@Connor-Flewitt
Copy link

I have installed yarn using yarn install and checked it was successful using yarn version. I then use yarn dev within the CLI of visual studio, to build the project and start the server.
I then try to run yarn test-routes to check my code against the test criteria (at this stage I haven't written any code, but I have the lesson 2 directory open in VS code, I just want to check the test is working), but receive the following error:

'Connors-MBP:api-design-node-v3-lesson-2 connorflewitt$ yarn test-routes
yarn run v1.22.15
$ npm run test -t router
npm WARN lifecycle The node binary used for scripts is /var/folders/x1/mz8mq97502566d0vm7_148d40000gn/T/yarn--1634049615107-0.4726967466122134/node but npm is using /usr/local/bin/node itself. Use the --scripts-prepend-node-path option to include the path for the node binary npm was executed with.

api-design-v3@1.0.0 test /Users/connorflewitt/Documents/Learning Resources/api-design-node-v3-master/api-design-node-v3-lesson-2
cross-env NODE_ENV=testing jest --forceExit --detectOpenHandles --silent "router"

sh: cross-env: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! api-design-v3@1.0.0 test: cross-env NODE_ENV=testing jest --forceExit --detectOpenHandles --silent "router"
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the api-design-v3@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/connorflewitt/.npm/_logs/2021-10-12T14_40_15_531Z-debug.log
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. '

Is anyone able to recreate and/or solve this issue?

@spiropoulos94
Copy link

Exactly the same is happening to me.

@thenishantgiri
Copy link

I have installed yarn using yarn install and checked it was successful using yarn version. I then use yarn dev within the CLI of visual studio, to build the project and start the server. I then try to run yarn test-routes to check my code against the test criteria (at this stage I haven't written any code, but I have the lesson 2 directory open in VS code, I just want to check the test is working), but receive the following error:

'Connors-MBP:api-design-node-v3-lesson-2 connorflewitt$ yarn test-routes yarn run v1.22.15 $ npm run test -t router npm WARN lifecycle The node binary used for scripts is /var/folders/x1/mz8mq97502566d0vm7_148d40000gn/T/yarn--1634049615107-0.4726967466122134/node but npm is using /usr/local/bin/node itself. Use the --scripts-prepend-node-path option to include the path for the node binary npm was executed with.

api-design-v3@1.0.0 test /Users/connorflewitt/Documents/Learning Resources/api-design-node-v3-master/api-design-node-v3-lesson-2
cross-env NODE_ENV=testing jest --forceExit --detectOpenHandles --silent "router"

sh: cross-env: command not found npm ERR! code ELIFECYCLE npm ERR! syscall spawn npm ERR! file sh npm ERR! errno ENOENT npm ERR! api-design-v3@1.0.0 test: cross-env NODE_ENV=testing jest --forceExit --detectOpenHandles --silent "router" npm ERR! spawn ENOENT npm ERR! npm ERR! Failed at the api-design-v3@1.0.0 test script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /Users/connorflewitt/.npm/_logs/2021-10-12T14_40_15_531Z-debug.log error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. '

Is anyone able to recreate and/or solve this issue?

Try removing cross-env from the test script inside your package.json file

Branch: lesson-2 or lesson-2-solution

changes to be made in filename: package.json

Before:

"scripts": {
"build": "babel src --out-dir dist",
"test": "cross-env NODE_ENV=testing jest --forceExit --detectOpenHandles --silent",
"test-routes": "npm run test -t router",
"test-models": "npm run test -t model",
"test-controllers": "npm run test -t controllers",
"test-auth": "npm run test -t Authentication:",
"dev": "nodemon --exec npm run restart",
"restart": "rimraf dist && npm run build && npm run start",
"start": "node dist/index.js"
}

After:

"scripts": {
"build": "babel src --out-dir dist",
"test": "NODE_ENV=testing jest --forceExit --detectOpenHandles --silent",
"test-routes": "npm run test -t router",
"test-models": "npm run test -t model",
"test-controllers": "npm run test -t controllers",
"test-auth": "npm run test -t Authentication:",
"dev": "nodemon --exec npm run restart",
"restart": "rimraf dist && npm run build && npm run start",
"start": "node dist/index.js"
}

Please let me know if this doesn't work out!

@thenishantgiri
Copy link

Exactly the same is happening to me.

Please try the above fix, do let us know if this doesn't help you!

@Connor-Flewitt
Copy link
Author

Great, appreciate the help. Will check and feedback!

@subarashii-huch09
Copy link

@thenishantgiri Thanks for the help, it works! ✨

@PrbFonseca
Copy link

Updating Jest to the latest version fixed the issue for me.

$npm remove jest
$ npm install jest --save

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants