Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing 茉莉花反应成分测试失败_Unit Testing_Jasmine_Karma Runner - Fatal编程技术网

Unit testing 茉莉花反应成分测试失败

Unit testing 茉莉花反应成分测试失败,unit-testing,jasmine,karma-runner,Unit Testing,Jasmine,Karma Runner,尝试使用Karma和Jasmine设置测试 要设置gulp watch任务-我有包含以下任务的gulp文件: gulp.task('default', ['browserify','css','karma'], function () { gulp.watch('../App/src/**/*.js', ['browserify']); gulp.watch('../App/src/**/*.css', ['css']); gulp.watch('../App/src/t

尝试使用Karma和Jasmine设置测试

要设置gulp watch任务-我有包含以下任务的gulp文件:

gulp.task('default', ['browserify','css','karma'], function () {
    gulp.watch('../App/src/**/*.js', ['browserify']);
    gulp.watch('../App/src/**/*.css', ['css']);
    gulp.watch('../App/src/tests/**/*.js', ['rewireAndSetupTests']);
    gulp.watch('../App/src/tests/**/*.js', ['karma']);
});
我的所有测试当前都失败,出现以下错误:

[08:46:15] Starting Karma server...
INFO [karma]: Karma v0.12.37 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.8 (Windows 8 0.0.0)]: Connected on socket  3xjo1pLi0mPkCJQlk9Cd with id 68708323
PhantomJS 1.9.8 (Windows 8 0.0.0) ERROR
  ReferenceError: Can't find variable: module
  at d:/Source/tests/stub/channelStub.js:25
有人能告诉我如何设置测试吗

这是我的业力配置:

var webpack = require("webpack"),
path = require("path");

module.exports = function (config) {
config.set({
    basePath: "",
    frameworks: ["jasmine"],
    files: [
        "node_modules/phantomjs-polyfill/bind-polyfill.js",
        "./App/src/tests/bundle.js"
    ],
    webpack: {
        module: {
            loaders: [
                { test: /\.js$/, loader: "jsx-loader" }
            ]
        },
        plugins: [
            new webpack.ResolverPlugin([
                new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"])
            ])
        ],
        resolve: {
            root: [path.join(__dirname, "./bower_components"), path.join(__dirname, "./src")]
        }
    },
    webpackMiddleware: {
        noInfo: true
    },
    plugins: [
        require("karma-webpack"),
        require("karma-jasmine"),
        require("rewire-webpack"),
        require("phantomjs"),
        require("karma-phantomjs-launcher"),
       require("karma-chrome-launcher")
    ],
    reporters: ["dots"],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ["PhantomJS"],
    singleRun: false
});
};
更新:乙烯基转换似乎有问题,有人知道我如何解决这个问题吗

gulp.task('rewireAndSetupTests', function () {

var browserified = transform(function(filename) {
    console.log(filename);
    var b = browserify(filename);
    b.transform({ global: true }, reactify);
    b.transform({ global: true }, rewireify);
    return b;
});
return gulp.src(['./app/src/tests/**/*.js'])
    .pipe(concat('suite.js'))
    .pipe(browserified)
    .pipe(gulp.dest('./dist/'));

});

如果您正在浏览gulp任务,为什么还要使用webpack预处理器?谢谢,我已经删除了那行代码。仍然保持获取错误未捕获引用错误:未定义模块