webdriverio-boneyard/wdio-junit-reporter

Skipping a test suite with ternary format causes broken xml result

Opened this issue · 2 comments

The problem

Using ternary operator on describe level causes this reporter generates broken xml result.

Environment

  • WebdriverIO version: 4.12.0
  • Node.js version: 8.9.4
  • wdio-junit-reporter version: 0.4.2 and 0.3.1

Details

Setup

true ? describe.skip : describe('google', () => {
    it('should open home page', () => {
        homePage.open();
        homePage.searchBox.waitForVisible();
    });

    it('should search things', () => {
        homePage.search('the answer to life the universe and everything');
        resultPage.calculatorBox.waitForVisible();
        expect(resultPage.calculatorBox.getText()).equals('42');
    });
});

Expected:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="google" timestamp="2018-03-15T14:26:22" time="0.018" tests="2" failures="0" errors="0" skipped="2">
    <properties>
      <property name="specId" value="6ed49d49e69c669eba8317ca37ef6a22"/>
      <property name="suiteName" value="google"/>
      <property name="capabilities" value="chrome"/>
      <property name="file" value=".\specs\google.spec.ts"/>
    </properties>
    <testcase classname="chrome.google" name="should_open_home_page" time="0">
      <skipped/>
    </testcase>
    <testcase classname="chrome.google" name="should_search_things" time="0.001">
      <skipped/>
    </testcase>
  </testsuite>
</testsuites>

Actual:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites/>

false ? describe : describe.skip('google', () => {}); and describe.skip generate expected result with no problem.

Have you tried:

describe('my test', () => {
    true ? describe.skip : describe('google', () => {
        it('should open home page', () => {
            homePage.open();
            homePage.searchBox.waitForVisible();
        });

        it('should search things', () => {
            homePage.search('the answer to life the universe and everything');
            resultPage.calculatorBox.waitForVisible();
            expect(resultPage.calculatorBox.getText()).equals('42');
        });
    });
})

?

Got the broken result as well.