我似乎不知道如何让 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 配置,也许我可以只导入其中一个,然后做一些细微的改变。