我似乎无法弄清楚如何获取mocha-webpack来检测文件夹中的测试。我正在运行以下命令:
mocha-webpack --webpack-config test/server/webpack.config-test.js
webpack.config-test.js
var nodeExternals = require("webpack-node-externals")
const path = require("path")
function resolve(dir)
{
return path.join(__dirname, "..", dir)
}
module.exports = {
context: path.resolve(__dirname),
resolve: {
extensions: [".js"],
alias: {
"vue$": "vue/dist/vue.esm.js",
"@": resolve("src"),
}
},
target: "node", // webpack should compile node compatible code
externals: [nodeExternals()], // in order to ignore all modules in node_modules folder
}
如果有帮助,我也正在使用vue-cli,因此已经有webpack配置,也许我可以只导入其中一个然后进行一些更改。
答案 0 :(得分:1)
您需要将其添加到代码行中:
mocha-webpack --webpack-config test/server/webpack.config-test.js \"src/**/*.js\"