webdriverio-boneyard / wdio-junit-reporter

A WebdriverIO v4 plugin. Report results in junit xml format.
http://v4.webdriver.io
MIT License
11 stars 42 forks source link

Skipping a test suite with ternary format causes broken xml result #93

Open heqiao opened 6 years ago

heqiao commented 6 years ago

The problem

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

Environment

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.

christian-bromann commented 6 years ago

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');
        });
    });
})

?

heqiao commented 6 years ago

Got the broken result as well.