簡體   English   中英

Webdriverio Node.js Mocha Chai測試跳過describe塊

[英]Webdriverio Node.js Mocha Chai test skips describe block

我正在運行此測試,看來當測試到達我的describe塊的功能部分時,它會跳過整個過程並給出錯誤的肯定結果。

// required libraries
var webdriverio = require('webdriverio');
var describe = require('describe');
var after = require('after');

console.log("Lets begin");

describe('Title Test for google site', function() {

 console.log("MARTY!!");
 // set timeout to 10 seconds
this.timeout(10000);
var driver = {};

console.log("before we start");
// hook to run before tests
before( function (done) {
// load the driver for browser
console.log("before browser");
driver = webdriverio.remote({ desiredCapabilities: {browserName: 'firefox'}       });
 driver.init(done);
});

it('should  load correct page and title', function () {
// load page, then call function()
return driver
.console.log("before site")
  .url('http://www.ggogle.com')
  // get title, then pass title to function()
  .getTitle().then( function (title) {
    // verify title
    (title).should.be.equal("google");
    // uncomment for console debug
    // console.log('Current Page Title: ' + title);
  });
  });
  });
  // a "hook" to run after all tests in this block
  after(function(done) {
   driver.end(done);
  });


  console.log ("Fin");

這是我得到的輸出

讓我們開始

[在0.4秒內完成]

如您所見,它會跳過所有其他內容。

這是錯誤的,應刪除:

var describe = require('describe');
var after = require('after');

Mocha describe Mocha的describeafter添加到測試文件的全局空間中。 您不需要導入它們。 查看Mocha網站上的所有示例,您不會在任何地方告訴他們導入describe及其同級。

要使Mocha添加describe及其兄弟姐妹,您需要通過mocha運行測試。 直接在測試文件上運行node將不起作用。 為了使mocha容易被發現,它必須在您的PATH 如果是在本地安裝的,則(很可能)它不在PATH因此您必須提供完整路徑./node_modules/.bin/mocha

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM