Javascript 噩梦是来自同一测试的多个报告

Javascript 噩梦是来自同一测试的多个报告,javascript,automated-tests,chai,nightmare,Javascript,Automated Tests,Chai,Nightmare,由于@pipo_dev,我能够解决噩梦EJS中多次评估的问题,我想知道的一件事是,如果我能为同一测试提供多个报告,请以以下为例: describe('test google search results', function() { this.timeout(15000); it('should find the nightmare github link first', function(done) { var nightmare = Nightmare({show: true

由于@pipo_dev,我能够解决噩梦EJS中多次评估的问题,我想知道的一件事是,如果我能为同一测试提供多个报告,请以以下为例:

describe('test google search results', function() {
  this.timeout(15000);
  it('should find the nightmare github link first', function(done) {
    var nightmare = Nightmare({show: true})

    nightmare
      .goto('http://google.com')
      .wait(1000)
      .type('form[action*="/search"] [name=q]', 'github nightmare')
      .click('form[action*="/search"] [type=submit]')
      .wait(1000)//.wait('#rcnt')
      .evaluate(function() {
        return document.querySelector('div.rc h3.r a').href
      })
      .then(function(link) {
        console.log("TESTING 1");
        expect(link).to.equal('https://github.com/segmentio/nightmare');

        nightmare
          .evaluate(function() {
            return document.querySelector('div.rc h3.r a').href
          })
          .end()
          .then(function(link) {
            console.log("TESTING 2");
            expect(link).to.equal('https://github.com/segmentio/nightmare');
            done();
          })
      })
      .catch(function(error) {
        done(new Error(error))
      })
  });
});
我希望看到的输出是:

Test Google search results
  ✓ should find the nightmare github link first TEST 1 (8718ms)
  ✓ should find the nightmare github link first TEST 2 (8718ms)
我现在得到的是这样的东西:

Test Google search results
  ✓ should find the nightmare github link first (8718ms)

但是在当前的设置下,我只得到一份整个测试的报告,也许我的方法效率不高,但我需要在同一页面上的UI上运行多达100个测试,而不必在每次新测试启动时重新构建测试,这将节省大量时间。

在对噩梦进行了更多的处理后,我能够确定我可以实例化噩梦并在其他测试中重复使用它。简化版:

describe('descr', function() {

var ur = "http://www.helmutgranda.com";
var nightmare = new Nightmare{);
nightmare.goto(url);

it('first test', function(done) {
  nightmare
  .wait('element')
  .evaluate(....)
  .run();
}

it('second test', function(done) {
  nightmare
  .wait('element')
  .evaluate(....)
  .run();
}

});

在对噩梦做了更多的工作之后,我发现我可以实例化噩梦并在其他测试中重用它。简化版:

describe('descr', function() {

var ur = "http://www.helmutgranda.com";
var nightmare = new Nightmare{);
nightmare.goto(url);

it('first test', function(done) {
  nightmare
  .wait('element')
  .evaluate(....)
  .run();
}

it('second test', function(done) {
  nightmare
  .wait('element')
  .evaluate(....)
  .run();
}

});