需要 – 用摩托车测试和摩根测试

前端之家收集整理的这篇文章主要介绍了需要 – 用摩托车测试和摩根测试前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用 Yeoman来支架我的项目.它配有几个方便的东西,包括一个基于 PhantomJS的测试跑步者.

我的问题是,当我的测试在浏览器中正常运行时,他们会在CLI中使用PhantomJS运行它们时超时.

以下是我的测试index.html的样子:

<!doctype html>
<head>
  <Meta charset="utf-8">
  <Meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>Mocha Spec Runner</title>
  <link rel="stylesheet" href="lib/mocha/mocha.css">
</head>
<body>
  <div id="mocha"></div>
  <script src="lib/mocha/mocha.js"></script>
  <!-- assertion framework -->
  <script src="lib/chai.js"></script>

  <!-- include source files here... -->
  <script data-main="scripts/main" src="scripts/vendor/require.js"></script>

  <script>
    mocha.setup({ui: 'bdd',ignoreLeaks: true});
    expect = chai.expect;
    should = chai.should();
    require(['../spec/map.spec'],function () {
      setTimeout(function () {
        require(['../runner/mocha']);
      },100);
    });
  </script> 

</body>
</html>

这里是map.spec.js:

require(['map'],function (Map) {
  describe('Choropleth Map Generator',function() {
    describe('Configure the map',function () {
      it("should enforce mandatory parameters in the configuration",function () {
        var config = {title: 'test configuration'};
        var map = new Map(config);
        (function () {
          map.getConfig();
        }).should.throw(Error);
      });
    });
  });
});

现在,当我做你的测试,我得到这个:

Running "server:phantom" (server) task

Starting static web server on port 3501

[...]

Running "mocha:all" (mocha) task
Testing index.html
<WARN> PhantomJS timed out,possibly due to a missing Mocha run() call. Use --force to continue. </WARN>

Aborted due to warnings.

正如我所说,yeoman服务器:测试在浏览器中正确显示我的断言.

我使用的是Yeoman 0.9.6和PhantomJS 1.7.0.任何帮助是赞赏.

解决方法

什么是你的mocha配置在Gruntfile.你有这样的东西吗?
mocha: {
  all: ['http://localhost:3501/index.html']
},
原文链接:https://www.f2er.com/js/153235.html

猜你在找的JavaScript相关文章