Jasmine没有超过13个规格的规格

时间:2017-05-01 12:08:46

标签: javascript jasmine

Jasmine在向其添加第14个规范后报告没有发现规范的消息(如果它是工作规范的副本则无关紧要)。如果我使用一个自制的记者,它表明它经历了所有的规格没有问题,但它报告没有发现最终结果的规格。

添加了一个控制台日志以显示我的意思

Started
[#quickSort]

Results               Top Level Tests
-------               ---------------
.Passed                should sort small array
.Passed                should hallo small array
.Passed                should sort array with identical values
.Passed                should do nothing with empty array
.Passed                shouldn't sort a string
.Passed                should do nothing with array with single field

Group "#quickSort" was finished


[#signature]

Results               Top Level Tests
-------               ---------------
[#signature Write signatureformat Remove]

Results               Top Level Tests
-------               ---------------
.Passed                Compact 1/2; Remove additional x/y members
.Passed                Compact 2/2; Also remove additional x/y members in sequential paths

Group "Write signatureformat Remove" was finished


[#signature Write signatureformat Reposition]

Results               Top Level Tests
-------               ---------------
.Passed                Reposition 1/2; Reposition top-left to 0,0 for more compact output
.Passed                Reposition 2/2; Reposition top-left to 0,0 for more compact output

Group "Write signatureformat Reposition" was finished


[#signature Write signatureformat Downscale]

Results               Top Level Tests
-------               ---------------
.Passed                Downscale 1/2; Downscale when needed with minimal resolution loss, so it will never get to large (-2000..2000)
.Passed                Downscale 2/2; Downscale when needed with minimal resolution loss, so it will never get to large (-2000..2000)

Group "Write signatureformat Downscale" was finished


.Passed                Write signatureformat - Complex export
.Passed                Write signatureformat - Rotate 180 degrees

Group "#signature" was finished


Started


No specs found
Finished in 0.002 seconds

此处还有spec_runner的来源

//var exit = require('exit');
var Jasmine = require('jasmine'),
    reporters = require('jasmine-reporters');

var junitReporter = new reporters.NUnitXmlReporter({
  savePath: __dirname,
  consolidateAll: true
});

var myReporter = {

    jasmineStarted: function (suiteInfo) {
    },
    suiteStarted: function (result) {
        console.log('[' + result.fullName + ']');
        console.log('');
        console.log('Results               Top Level Tests');
        console.log('-------               ---------------');
    },
    specStarted: function (result) {
    },
    specDone: function (result) {
        var line = result.status.substr(0, 1).toUpperCase() + result.status.substr(1);
        if (line === "Failed") line = "+" + line;
        while (line.length < 22) line += " ";
        console.log(line + result.description);
    },
    suiteDone: function (result) {
        console.log('');
        console.log('Group "' + result.description + '" was ' + result.status);
        for (var i = 0; i < result.failedExpectations.length; i++) {
            console.log('AfterAll ' + result.failedExpectations[i].message);
            console.log(result.failedExpectations[i].stack);
        }
        console.log('');
        console.log('');

        // werkt gewoon niet???? [rv]
        //if (result.status !== "passed") exit(1)
    },
    jasmineDone: function () {
    }
};

var jasmine = new Jasmine();
jasmine.loadConfigFile("spec/support/jasmine.json");
jasmine.addReporter(myReporter);
jasmine.execute();

4 个答案:

答案 0 :(得分:4)

修正了它。问题出在package.json中。我使用了"scripts":{"test": "jasmine spec/spec_runner.js"}

这导致茉莉花运行2次。使用

修复了它

"scripts":{"test": "node spec/spec_runner.js"}

答案 1 :(得分:1)

在尝试运行测试之前,请确保您的应用程序已成功编译。如果您有待处理的错误,Jasmine将无法找到规格文件。

答案 2 :(得分:1)

类似于上一篇文章,但我使用的是茉莉花ts:

<blockquote class="imgur-embed-pub" lang="en" data-id="Wr92Jrv"><a href="//imgur.com/Wr92Jrv"></a></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>

这将创建以下文件(如果尚不存在):

npx jasmine init

初始内容不适合我,因此我必须遵循以下内容,尤其要注意spec_dir(相对于您从中运行tests命令的package.json):

spec/support/jasmine.json

答案 3 :(得分:0)

遇到此问题时,我在相应的文件夹中使用了此命令:

$jasmine init

这很简单,但是对我有用。

相关问题