当使用带有xargs的NPM时,没有mocha测试运行或报告

no mocha tests run or report when using npm with | xargs

本文关键字:没有 mocha 测试运行 报告 NPM xargs      更新时间:2023-09-26

我正在尝试使用npm运行mocha测试,像这样:

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

当我直接从CLI中执行它时,它工作得很好,但是当我使用npm run test时,它似乎没有执行任何测试(或者至少没有显示它们的任何输出)。

仅供参考:我使用xargs,因为mocha没有忽略文件的选项,我使用emacs,它在同一目录

中生成用于检测的临时文件。

您可能需要转义*.js:

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