Help With "Deploying our app" tests

Greetings, I’m getting an error code on attempts to use the command “npm run test”

Error: Cannot find module ‘C:\Users\UserName\Git Tests\will-it-miss\tests*.js’
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: ‘MODULE_NOT_FOUND’,
requireStack: []
}

I assumed, from reading this error, that this means the file for the nasa test in the learning section is unable to be found at the specified location. I have checked the file path to ensure it is in the path in the same location as Cannot find module ‘C:…’. I additionally ensured that the code was done correctly, for the nasa-feed.test.js and the package.json files. If anyone else has had this issue, or has found a workaround please let me know at the earliest convenience, as everything appears to be correct.

Thanks in advance!

Hi @gbruch and welcome to the community :wave:

I haven’t done this exercise myself, but what looks suspicious is the path:
C:\Users\UserName\Git Tests\will-it-miss\tests*.js
Normally, test files would go into their own directory. Looking at your path above it seems like the test files are directly in the project directory and start with “tests” and end with “.js”. Is it possible that the path should be:
C:\Users\UserName\Git Tests\will-it-miss\tests\*.js
It would then refer to all JS files inside the “tests” directory. Maybe “scripts” -> “test” in package.json is missing the backslash.

Have a nice day,
Michael

1 Like

Hey @gbruch! Welcome to the MDN Web Docs learning community.
Can you provide a link to the code exercise you are following?


Schalk
Staff Community Manager - MDN Web Docs

1 Like

Hi @schalkneethling

It’s from “Tools and testing - Client-side web development tools”:

1 Like

Hey @gbruch,

Looking at this line:

C:\Users\UserName\Git Tests\will-it-miss\tests*.js

Can you please double check that the following line in your package .json:

"test": "node tests/*.js",

Is typed as "test": "node tests/*.js", and not “test”: “node tests*.js”,`. Notice the missing forward slash(/). Let me know if this helps solve your problem.


Schalk
Staff Community Manager - MDN Web Docs