Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialbabyoscar
12,930 PointsWhy is npm test throwing error but mocha test works?
When I run npm test
after setting up my workspace like the teacher's, it throws this error:
> workspace@1.0.0 test /home/treehouse/workspace
> mocha
/home/treehouse/workspace/node_modules/mocha/lib/mocha.js:1215
for await (const fixtureFn of fixtureFns) {
^^^^^
SyntaxError: Unexpected reserved word
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/treehouse/workspace/node_modules/mocha/lib/cli/one-and-dones.j
s:12:15)
npm ERR! Test failed. See above for more details.
, but when I run mocha test
, it returns
0 passing (2ms)
Why is this happening?
babyoscar
12,930 PointsI already went on with different videos, using mocha test
, so I think my workspace code is ahead of this video's. My code is exactly the same as the teacher's code. Also, it seems like the problem is in mocha.js
, which is not my code.
Paul Messmer
15,023 PointsOh ok I'm glad you figured it out!
1 Answer
babyoscar
12,930 PointsYes, also it must've been something with the workspace I had (or maybe my code), because it provided the teacher's code after this section of the course, and when I run npm test
it works fine.
Paul Messmer
15,023 PointsPaul Messmer
15,023 PointsCan I see your JS code? Are you calling this in a async function?