Hi,
I am reading through Deploying our app article and in the Testing section it told us to add a npm script for test in package.json file.
"scripts": {
…
"test": "node tests/*.js",
"build": "npm run test && parcel build src/index.html"
}
The problem is that when I run the npm run test it returns an error.
$ npm run test
> will-it-miss@1.0.0 test
> node 'tests/*.js'
node:internal/modules/cjs/loader:1080
throw err;
^
Error: Cannot find module 'C:\Users\PC\Desktop\will-it-miss\'tests\*.js''
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v18.17.0
There is also another thread created with the title Help With “Deploying our app” tests but there is no solution here as well.
If I do not use wildcard (*) in the test like this
"scripts": {
…
"test": "node tests/nasa-feed.test.js",
"build": "npm run test && parcel build src/index.html"
}
it works just fine. Also if I run it directly in the command line using wildcard (*) it also works.
After searching for hours I found out that the wildcard (*) is only available in the Unix system I am using windows and windows do not support Glob wildcards in npm. I also found Glob wildcards in Windows npm on StackOverflow which further explains this. So Is there a solution to this problem?
Thank you.