i我的软件包。
"scripts": {
"test": "node tests/*-test.js"
}
我在tests
文件夹中有a-test.js
和b-test.js
,我可以通过运行ls tests/*-test.js
进行验证。
但是,npm run test
仅执行a-test.js
。如何执行所有*-test.js
脚本?明确列出它们不是一个选项,因为我将来将有2个以上的运行。
您可以使用诸如grunt
或gulp
之类的任务管理器,或执行这些脚本的简单脚本:
test.js:
require('./test/a-test.js')
require('./test/b-test.js')
package.json
"scripts": {
"test": "node test.js"
}
您也可以使用Incluble-All模块为您自动化这些模块https://www.npmjs.com/package/package/include-all-all-all-all
使用IncludeAll:
的示例 const path = require('path');
const includeAll = require('include-all');
const controller = includeAll({
dirname: path.join(__dirname, 'test'),
filter: /(.+test).js$/,
});