FrontendMasters / intro-to-graphql

[Course] Introduction to GraphQL
192 stars 289 forks source link

Cannot run lesson-2 tests #9

Open MrSamsa42 opened 5 years ago

MrSamsa42 commented 5 years ago

I am not able to run the tests associated with lesson 2. See terminal output below. Environment is Windows 10, Node 12.10

npm run test-schema

intro-to-gql@1.0.0 test-schema C:\Users\mrsam\Projects\Education\intro-to-graphql GQL_LESSON=lesson-2 npm test -- -t lesson-2

'GQL_LESSON' is not recognized as an internal or external command, operable program or batch file. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! intro-to-gql@1.0.0 test-schema: GQL_LESSON=lesson-2 npm test -- -t lesson-2 npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the intro-to-gql@1.0.0 test-schema 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! C:\Users\mrsam\AppData\Roaming\npm-cache_logs\2019-11-03T21_38_39_591Z-debug.log

MrSamsa42 commented 5 years ago

It took forever, but I found the solution. Stack Overflow to the rescue (again): https://stackoverflow.com/questions/9249830/how-can-i-set-node-env-production-on-windows

So, change the script in the package.json file to:
"test-schema": "set GQL_LESSON=lesson-2 && npm test -- -t lesson-2"

peerhenry commented 4 years ago

It should be: "test-schema": "cross-env GQL_LESSON=lesson-2 npm test -- -t lesson-2"