首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >nwjs和karma-mocha玩得不好

nwjs和karma-mocha玩得不好
EN

Stack Overflow用户
提问于 2016-07-13 20:42:16
回答 1查看 249关注 0票数 2

我在使用Karma测试我的NW.js应用程序时遇到了问题。以前有效的测试在更新后不再有效?(我不确定是哪个更新杀死了我)

代码语言:javascript
复制
START:
13 07 2016 08:33:30.517:INFO [karma]: Karma v1.1.1 server started at http://localhost:9876/
13 07 2016 08:33:30.519:INFO [launcher]: Launching browser NodeWebkitTest with unlimited concurrency
13 07 2016 08:33:30.531:INFO [launcher]: Starting browser node-webkit
13 07 2016 08:33:36.221:INFO [Chrome 41.0.2272 (Windows 7 0.0.0)]: Connected on socket /#6fJGXLlwDNlOGXukAAAA with id 21855637
Chrome 41.0.2272 (Windows 7 0.0.0) ERROR
Uncaught TypeError: Cannot read property 'setup' of undefined
at C:/Users/ethomps2/IdeaProjects/evidentia3/node_modules/karma-mocha/lib/adapter.js:209

Finished in 0.331 secs / 0 secs

在适配器中出现故障的位置,适配器正在查找window.mocha

这是我的karma配置:

代码语言:javascript
复制
module.exports = function (config) {
config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['mocha', 'chai', 'sinon'],

    'plugins': [
        'karma-nodewebkit-launcher',
        'karma-mocha',
        'karma-chai',
        'karma-sinon',
        'karma-coverage',
        'karma-mocha-reporter'
    ],


    // list of files / patterns to load in the browser
    files: [
        <my code including test files>
    ],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
        '../build/js/controllers/*.js': ['coverage'],
        '../build/js/services/*.js': ['coverage'],
        '../build/js/filters/*.js': ['coverage'],
        '../build/js/directives/*.js': ['coverage']
    },


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['mocha', 'coverage'],


    // web server port
    port: 9876,


    // enable / disable colors in the output (reporters and logs)
    colors: true,


    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: false,


    // start these browsers

    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['NodeWebkitTest'],

    customLaunchers: {
        'NodeWebkitTest': {
            base: 'NodeWebkit',
            paths: ['node_modules'],
            options: {
                "name": "Evidentia",
                "main": "index.html",
                "description": "Evidence management software for your genealogy research",
                "version": "3.0.0",
                "ver": "300",
                "webkit": {
                    "page-cache": false
                },
                "window": {
                    "title": "Evidentia",
                    "icon": "img/Evidentia128x128.png",
                    "toolbar": true,
                    "frame": true,
                    "width": 1100,
                    "height": 700,
                    "show": false
                }
            }
        }
    },

    // optionally, configure the reporter
    coverageReporter: {
        type: 'html',
        dir: '../coverage/',
        instrumenterOptions: {
            istanbul: {noCompact: true}
        }
    },


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true
})
};

如您所见,我使用karma-nodewebkit-launcher作为我的浏览器。我的理解是nwjs global链接到了窗口。

EN

回答 1

Stack Overflow用户

发布于 2017-05-18 11:27:07

在你的项目中使用karma-nodewebkit-mocha

有关更多详细信息,请参阅https://github.com/karma-runner/karma-mocha/issues/184

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38352076

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档