admin管理员组

文章数量:1297010

I am using the following stack to run several tests:

NodeJs
Selenium standalone
geckodriver thought I use chrome
webdriver.io
mocha 
chai

So after all my first_test.js is:

describe ('Website url test ', () => {
  it('should have a title ', () => {
    browser.call((done) => {
      browser.url('');
      var title = browser.getTitle();
      expect(title).to.be.equal('WebdriverIO - WebDriver bindings for Node.js')
      done();
    })
  })

And the output in the console is:Incorrect console output

But it should be like this for the passing tests as well: Correct console output

Is something in Mocha config that I should change so that the passing tests would produce the same optical oute?

I am using the following stack to run several tests:

NodeJs
Selenium standalone
geckodriver thought I use chrome
webdriver.io
mocha 
chai

So after all my first_test.js is:

describe ('Website url test ', () => {
  it('should have a title ', () => {
    browser.call((done) => {
      browser.url('http://webdriver.io');
      var title = browser.getTitle();
      expect(title).to.be.equal('WebdriverIO - WebDriver bindings for Node.js')
      done();
    })
  })

And the output in the console is:Incorrect console output

But it should be like this for the passing tests as well: Correct console output

Is something in Mocha config that I should change so that the passing tests would produce the same optical oute?

Share Improve this question edited Aug 14, 2017 at 11:19 NarendraR 7,70811 gold badges47 silver badges88 bronze badges asked Aug 12, 2017 at 16:37 apiManapiMan 891 silver badge4 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

This behavior was caused by the reporter chosen (in my case dot).

I changed to spec and I have a very verbose output now.

WebdriverIO supports a great variety of reporters:

  • Dot: which is the default reporter for WDIO, a lightweight console reporter that outputs a green, or red dot ('.') for a passing, respectively failing test case;

  • Spec: which just outputs in the console a step-by-step breakdown of the test cases you previously ran. This output will reside strictly in the console, unless you want to pipe your entire console log-stack via the logOutput: './<yourLogFolderPath>/' attribute from the wdio.conf.js file;

  • Json: which generates a .json report of the tests your previously ran. It's very well suited for people who already have a test results dashboard where they analyze their regression results (passing tests, failing tests, run-time, etc.) and just need to parse the data from somewhere. You can configure the path where you want the .json report to be generated via:

    reporterOptions: { outputDir: './<yourLogFolderPath>' }

Note: The Json reporter will populate the path given with WDIO-<timestamp>.json reports. If you want to pipe said .json to some other software for parsing, then you will need to go inside the library and change the naming convention so that you always get your results in the same file as opposed to a dynamically generated one.

  • Allure: Allure is one of the best reporter choices, especially if you don't have the makings of a test results dashboard in place as it generates one for you. You can check out this answer for a step-by-step breakdown;

!!! BUT as a best practice, no reporter should outweigh the importance of setting your logLevel (inside the wdio.conf.js file) to debug (logLevel: 'debug') for wdio-v5, or verbose (logLevel: 'verbose') for wdio-v4.

When debugging (I presume that was the reason purpose with the reporting), it's crucial that you get to the root of the problem in the fastest way possible and that is by looking at the REST calls made by your tests during run-time.

Hope this give a clearer overview to people starting with WebdriverIO and who need more info regarding which of these reporters is best suited for what scenario/situation.

Cheers!

本文标签: javascriptWebDriverio no console outputStack Overflow