Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@wdio/junit-reporter does not add testcase when there is an error or assertion fail in the before function. #6784

Closed
andreazcleafy opened this issue Apr 30, 2021 · 2 comments
Labels
first-timers-only Issues that are well described and directed for people that start contributing to the project good first pick a reasonable task to start getting familiar with the code base help wanted Issues that are free to take by anyone interested wdio-junit-reporter

Comments

@andreazcleafy
Copy link

  • WebdriverIO version: [6.4.]
  • Mode: [WDIO Testrunner]
  • If WDIO Testrunner, running sync/async: [async]
  • Node.js version: [12.22.1]
  • YARN version: [1.21.1]
  • Browser name and version: [Chrome 70]
  • Platform name and version: [Ubuntu 20.04.2 LTS]
  • Additional wdio packages used (if applicable): [@wdio/junit-reporter, @wdio/local-runner, @wdio/mocha-framework]

Config of WebdriverIO

exports.config = {
    runner: 'local',
    hostname: 'localhost',
    port: 4444,
    path: '/wd/hub',
    specs: ['./tests/**/*.js'],
    exclude: [],
    maxInstances: 10,
    capabilities: [
        {
            maxInstances: 5,
            browserName: 'chrome',
            acceptInsecureCerts: false,
            'goog:chromeOptions': {
                args: ['start-maximized'],
                prefs: {
                    directory_upgrade: true,
                    prompt_for_download: false,
                },
            },
        },
    ],
    logLevel: 'error',
    bail: 0,
    baseUrl: 'http://localhost',
    waitforTimeout: 10000,
    connectionRetryTimeout: 120000,
    connectionRetryCount: 3,
    framework: 'mocha',
    reporters: [
        'spec',
        [
            'junit',
            {
                outputDir: 'results',
                outputFileFormat: (options) => `${options.cid}.${options.capabilities.browserName}.xml`,
            },
        ],
    ],
    mochaOpts: {
        require: ['@babel/register'],
        ui: 'bdd',
        timeout: 60000,
    },
}

Describe the bug
Selecting junit reporter, the generated file has not a testcase tag when there is an error or an assertion fail

To Reproduce
Copy and past the test below
Execute the test below with yarn wdio wdio.conf.js -R junit --spec test.example.js

describe('EXAMPLE DESCRIBE', () => {
    before(() => {
        throw new Error()
        expect(false).toBe(true)
    })

    it('EXAMPLE TEST', ()=>{
        expect(true).toBe(true)
    })
})

Expected behavior
In the generated file, as you can see, there is no testcase:

<?xml version="1.0" encoding="UTF-8"?>
    <testsuites>
        <testsuite name="EXAMPLE_DESCRIBE" timestamp="2021-04-30T16:58:32" time="0.005" tests="0" failures="0" errors="0" skipped="0">
             <properties>
                 <property name="specId" value="0"/>
                 <property name="suiteName" value="EXAMPLE DESCRIBE"/>
                 <property name="capabilities" value="chrome.70_0_3538_77.linux"/>
                 <property name="file" value="/tmp/test.example.js"/>
             </properties>
         </testsuite>
</testsuites>
@andreazcleafy andreazcleafy changed the title @wdio/junit-reporter not add testcase when there is an error or assertion fail in the before function. @wdio/junit-reporter does not add testcase when there is an error or assertion fail in the before function. Apr 30, 2021
@christian-bromann christian-bromann added first-timers-only Issues that are well described and directed for people that start contributing to the project good first pick a reasonable task to start getting familiar with the code base help wanted Issues that are free to take by anyone interested wdio-junit-reporter labels May 3, 2021
@dwentland24
Copy link

Hi,
this is fixed already in #5812 and available in v6.5.1.
Should this also be fixed int v6.4?

@christian-bromann
Copy link
Member

Should this also be fixed int v6.4?

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first-timers-only Issues that are well described and directed for people that start contributing to the project good first pick a reasonable task to start getting familiar with the code base help wanted Issues that are free to take by anyone interested wdio-junit-reporter
Projects
None yet
Development

No branches or pull requests

3 participants