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 trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![babyoscar](https://secure.gravatar.com/avatar/4dc74fed360cf3be33e1851ce44f6d47?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
babyoscar
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](https://secure.gravatar.com/avatar/4dc74fed360cf3be33e1851ce44f6d47?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
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](https://secure.gravatar.com/avatar/7d7668fc334116e5969de49df7610d14?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Paul Messmer
15,023 PointsOh ok I'm glad you figured it out!
1 Answer
![babyoscar](https://secure.gravatar.com/avatar/4dc74fed360cf3be33e1851ce44f6d47?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
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?