为什么摩卡说我的测试通过了,而不应该?



目前,我不明白为什么终端说我的测试通过。我的测试设置为失败。

这是终端消息:

  Google
    ✓ Load google search page

  1 passing (22ms)

这是我用 Node JS 编写的测试

const assert = require('assert');
const {Builder, By, Key, until} = require('selenium-webdriver');
const suite = require('selenium-webdriver/testing')
var driver = new Builder()
    .forBrowser('chrome')
    .build();
describe('Google', function() {
  it('Load google search page', function() {
driver.get('https://www.foobar.com')
  .then(_ => driver.wait(until.titleIs('Darkness!'), 10000))
  .then(_ => driver.quit());
    });
  });
当您

要进行异步测试时,请查看文档使用以下格式:

it('should be fulfilled', function (done) {
    promise.should.be.fulfilled.and.notify(done);
});
it('should be rejected', function (done) {
    otherPromise.should.be.rejected.and.notify(done);
});

适用于您的案例 :

describe('Google', function() {
  it('Load google search page', function(done) {
     driver.get('https://www.foobar.com')
      .then(() => driver.wait(until.titleIs('Darkness!'), 10000))
      .then(() => driver.quit())
      .then(() => done())
      .catch(done);
  });
});

最新更新