no mocha tests run or report when using npm with |

2019-09-18 02:34发布

问题:

I'm trying to use npm to run mocha tests like this:

scripts: {
  test: "find ./src ./test -name *.js | xargs mocha --opts mocha.opts"
}

this works fine when I execute it straight from the CLI, but doesn't appear to execute any tests (or at least doesn't display any output from them) when I use npm run test.

FYI: I'm using xargs since mocha has no option to ignore files, and I use emacs, which generates temp files for linting in the same directory

回答1:

You probably need to escape the *.js:

scripts: {
  test: "find ./src ./test -name '*.js' | xargs mocha --opts mocha.opts"
}