webdriverio-community / wdio-cucumberjs-json-reporter

A WDIO reporter that creates CucumberJS JSON files for WebdriverIO
https://webdriver.io/docs/wdio-cucumberjs-json-reporter
MIT License
23 stars 32 forks source link

Line number are not getting populated in the Cucumber JSON report #88

Closed manoj-fsbtech closed 2 years ago

manoj-fsbtech commented 2 years ago

Config of webdriver.io and the reporter

services: ['selenium-standalone', ['chromedriver', {
        logFileName: 'wdio-chromedriver.log', // default
        outputDir: 'driver-logs',
        chromedriverCustomPath: "./chromedriver",
        args: ['--silent']
    }]],
    framework: 'cucumber',
    reporters: [
        ['allure', {
            outputDir: 'allure-results',
            disableWebdriverStepsReporting: true,
            disableWebdriverScreenshotsReporting: false,
            addConsoleLogs: true,
            useCucumberStepReporter: true
        }],
        ['cucumberjs-json', {
            jsonFolder: 'json_results/',
            language: 'en',
            disableHooks: false
        }],
        ['junit', {
            outputDir: './junit',
            outputFileFormat: function (options) { // optional
                return `results-${options.cid}.${options.capabilities}.xml`
            }
        }]
    ],

    //
    // If you are using Cucumber you need to specify the location of your step definitions.
    cucumberOpts: {
        // <string[]> (file/dir) require files before executing features
        require: ['./features/step-definitions/*.js'],
        // <boolean> show full backtrace for errors
        backtrace: false,
        // <string[]> ("extension:module") require files with the given EXTENSION after requiring MODULE (repeatable)
        requireModule: [],
        // <boolean> invoke formatters without executing steps
        dryRun: false,
        // <boolean> abort the run on first failure
        failFast: false,
        // <string[]> (type[:path]) specify the output format, optionally supply PATH to redirect formatter output (repeatable)
        format: ['pretty'],
        // <boolean> hide step definition snippets for pending steps
        snippets: true,
        // <boolean> hide source uris
        source: true,
        // <string[]> (name) specify the profile to use
        profile: [],
        // <boolean> fail if there are any undefined or pending steps
        strict: false,
        // <string> (expression) only execute the features or scenarios with tags matching the expression
        tagExpression: '',
        // <number> timeout for step definitions
        timeout: 120000,
        // <boolean> Enable this config to treat undefined definitions as warnings.
        ignoreUndefinedDefinitions: false
    },

Describe the bug It seems like when we generate the JSON report out of the wdio-cucumberjs-json-reporter package under the Steps definitions it is returning as the null.

To Reproduce Just generate a sample Cucumber Json report

Expected behavior Can we show the line number of the cucumber under the steps if we not able to find the line number can we default it to 0.

Snapshots image

Additional context When I have checked under the file, then it is showing step defination line number as null https://github.com/webdriverio-community/wdio-cucumberjs-json-reporter/blob/main/lib/reporter.ts

image

manoj-fsbtech commented 2 years ago

@wswebcreation ,

I have created this pull request where I am defaulting the line number to UID can you have a look at the same and approve it. https://github.com/webdriverio-community/wdio-cucumberjs-json-reporter/pull/89

There are few format issues I have fixed them.

wswebcreation commented 2 years ago

Thanks, I've reviewed the PR. Will close it and proceed in #89