【问题标题】:PhantomJS catching error in JasminePhantomJS 在 Jasmine 中捕获错误
【发布时间】:2015-03-11 14:30:56
【问题描述】:

问题

我有一个为大型应用程序构建的非常大的测试套件。

该套件包含超过 20 个不同的 JS 规范文件,这些文件通过了对所述应用程序的数百次测试。它已经到了 Jasmine(通过 Grunt watch 运行)无法在不抛出“警告:未定义使用 --force 继续”消息的情况下运行所有​​测试的地步。

如果我运行 SpecRunner.html 文件,所有测试都通过了,并且没有其他信息,即使 PhantomJS 说可以在那里找到更多信息。

一个人可以编写的测试数量是否有某种限制?

我正在使用 grunt v. ^0.4.5 和 grunt-contrib-jasmin v. ~0.6.3

Gruntfile.js

module.exports = function(grunt) {
    // Project configuration. Can be any arbitrary data.
    // Things you might want to <% %> include in tasks.
    // These data can be accessed by grunt.config.<property>
    // Taksa are also configured here taking the format:
    // <taskname>: { <target1>: {}, <target2>: {} }

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        js: {
            lib: [
                'PriceAnalytics.Web/Scripts/lib/jquery/*.min.js', // jquery needs to be loaded before bootstrap
                'PriceAnalytics.Web/Scripts/lib/bootstrap/bootstrap.min.js',
                'PriceAnalytics.Web/Scripts/lib/knockout/knockout*.js',
                'PriceAnalytics.Web/Scripts/lib/underscore/underscore.min.js',
                'PriceAnalytics.Web/Scripts/lib/underscore/underscore.mixin.deepExtend.js',
                'PriceAnalytics.Web/Scripts/lib/globalize/globalize.js',
                'PriceAnalytics.Web/Scripts/lib/highcharts/highcharts.js'
            ],
            src: 'PriceAnalytics.Web/Scripts/src/**/*.js',
            spec: 'PriceAnalytics.Web.Test/spec/**/*.js'
        },

        jasmine: {
            src: '<%= js.src %>',
            options: {
                specs: '<%= js.spec %>',
                vendor: '<%= js.lib %>',
                //display: 'short',
                summary: true
                //keepRunner: true  could probably leverage this option so that we don't have to manually maintain teh specrunner script tags
            }
        },

        watch: {
            gruntfile: {
                files: '<%= jshint.gruntfile.src %>',
                tasks: ['jshint:gruntfile']
            },
            src_spec: {
                files: '<%= jshint.src_spec.src %>',
                tasks: ['jshint:src_spec', 'jasmine']
            }
        }
    });

    // Load the plugins
    grunt.loadNpmTasks('grunt-contrib-jasmine');
    grunt.loadNpmTasks('grunt-contrib-watch');

    // Default task(s)
    grunt.registerTask('default', ['jasmine']);
};

【问题讨论】:

  • 我仍在努力解决这个问题,它已经困扰我好几个星期了......我迫切需要建议。

标签: javascript unit-testing jasmine phantomjs grunt-contrib-jasmine


【解决方案1】:

原来我们的应用程序代码中存在一个错误,它从 try/catch 中抛出错误,从而导致测试失败/不运行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-31
    • 2015-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-17
    相关资源
    最近更新 更多