1

I'm getting started with testing with this article Deploying our app

Here's my package.json:

{
  "name": "complete-toolchain",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "node tests/*.js",
    "build": "npm run test && npx parcel build src/index.html"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "axios": "^0.21.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^7.14.0",
    "eslint-plugin-react": "^7.21.5",
    "parcel-bundler": "^1.12.4",
    "postcss-preset-env": "^6.7.0",
    "prettier": "^2.2.0"
  },
  "dependencies": {
    "date-fns": "^2.16.1",
    "format-number": "^3.0.0",
    "react": "^17.0.1",
    "react-async-hook": "^3.6.2",
    "react-dom": "^17.0.1"
  }
}

I get error when I run npm run test:

Cannot find module 'C:\Users\x\complete-toolchain\tests\*.js'

Why doesn't it understand this? Of course it works with "test": "node tests/nasa-feed.test.js",.

user3132457
  • 789
  • 2
  • 11
  • 29
  • 1
    It looks like you're using a Windows shell, which doesn't expand globs the same way \*nix does. Why not use an actual test runner? – jonrsharpe Nov 24 '20 at 07:29
  • i see, i'm using git bash as terminal on vscode. i'm learning this for now, and later will use test runner. just wanted to make this work – user3132457 Nov 24 '20 at 07:32
  • 1
    *You're* using git bash, but unless you've [configured it](https://stackoverflow.com/questions/23243353/how-to-set-shell-for-npm-run-scripts-in-windows) run-script will use the system shell. – jonrsharpe Nov 24 '20 at 07:41
  • oh i didn't know that. i did `npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"` and it worked fine, thanks. – user3132457 Nov 24 '20 at 07:44

0 Answers0