当没有当前规范时使用'expect',这可能是因为异步测试在Jasmine 2.3.1中超时

Jay*_*kla 17 jasmine angularjs karma-runner gulp

我通过gulp运行业力测试案例如下:

gulp.task('unit-test-karma', function () {
    return gulp.src(filePaths.libraryPaths.concat(filePaths.codePathsVerbose.concat(filePaths.testPaths).concat(filePaths.htmlPaths).concat(filePaths.jadePaths)))
        //.pipe(plumber({ errorHandler: notify.onError(function(error) { console.log(error.message); return "Karma Error"; }) }))
        .pipe(karma({
            configFile: './karma.conf.js',
            action: 'run', // watch
            singleRun: true,
            reporters: [ 'dots' ]
        }));
});
Run Code Online (Sandbox Code Playgroud)

当我以操作方式运行时run,IE 11会抛出错误.

IE 11.0.0 (Windows 10 0.0.0) ERROR
  'expect' was used when there was no current spec, this could be because an asynchronous test timed out
  at C:/BbCAT-WebDI/BbCAT-Web/BbCAT-Angular/node_modules/jasmine-core/lib/jasmine-core/jasmine.js:938
Run Code Online (Sandbox Code Playgroud)

但是如果运行与动作相同,watch则所有测试用例在chrome,IE和firefox中成功执行.

看完一些帖子后,似乎有一些问题与$ http服务电话但无法找到问题所在的确切位置!

Tja*_*ark 1

这是一个很现实的问题,我现在也遇到了这个问题。我认为这里有一个核心错误。我有很好的封装测试。它们很小(每个最多 3 行)

我有一个主要描述部分,有 2 个嵌套描述,第一个描述有 8 个 it() 函数,第二个有 3it() 函数。

IE

describe("main", ()=>{
    describe("1st", ()=>{
        //here are 8 it() definitions
    })
    describe("2nd", ()=>{
        //here are 3 it() definitions
    })
})
Run Code Online (Sandbox Code Playgroud)

现在,当我从任一描述中删除单个 it() 定义时,问题就消失了。或者,如果我添加第三个describe(),问题就会消失。

这是 jasmine 中的一个问题 - 要么它们没有正确报告错误,要么存在严重错误。或者,这可能是业力试图通过同时运行多个测试来变得聪明。无论哪种方式,这个问题都是真实的,并且与混乱的代码无关。

也许这与正在测试的底层单元有关 - 我的函数是递归的(尽管我的测试用例不深入)。

业力茉莉@0.3.8

茉莉花核心@2.4.1

业力@0.13.22

phantomjs-prebuilt@2.1.7

karma-phantomjs-launcher@1.0.0