【问题标题】:mocha-webpack not finding testsmocha-webpack 找不到测试
【发布时间】:2018-07-20 04:11:11
【问题描述】:

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

【问题讨论】:

  • mocha-webpack --webpack-config test/server/webpack.config-test.js \"src/**/*.js\" 有效吗?
  • @RodrigoMata 哇,事情就是这么简单。这完美地为我解决了。如果你回答,我会给你赏金
  • 很高兴听到它的工作,很高兴能提供帮助!

标签: javascript node.js webpack mocha.js mocha-webpack


【解决方案1】:

您需要将此添加到您的代码行中:

mocha-webpack --webpack-config test/server/webpack.config-test.js \"src/**/*.js\"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-03
    • 2015-11-29
    • 1970-01-01
    • 2013-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多