Skip to content

Mochawesome HTML report: Missing scenario steps (stack) in CodeceptJS 3 when scenario fails #2727

Description

@mirao

What are you trying to achieve?

Mochawesome report shows scenario steps (stack) when a scenario fails. It's useful because of context - when it's not clear in which step it occurred.
This is how it looks in CodeeceptJS 2.6.11:

image

What do you get instead?

Missing scenario steps in CodeceptJS 3.0.3. There is only an "internal" stack from node modules which isn't too much useful:

image

Provide console output if related. Use --verbose mode for more details.

# codeceptjs run --grep "Test login screen"  --profile jobr  --reporter mocha-multi

Details

  • CodeceptJS version: 3.0.3
  • NodeJS Version: v12.20.0
  • mocha-multi: 1.1.3
  • mochawesome: 6.1.1
  • Operating System: Ubuntu 20.04/20.10
  • Configuration file:
    mocha: {
        reporterOptions: {
            "codeceptjs-cli-reporter": {
                stdout: "-",
                options: {
                    verbose: false,
                    debug: true,
                    steps: true
                }
            },
            mochawesome: {
                stdout: "./output/console.log",
                options: {
                    reportDir: "./output",
                    reportFilename: "report"
                }
            },
            "mocha-junit-reporter": {
                stdout: "./output/console.log",
                options: {
                    mochaFile: "./output/result.xml",
                    jenkinsMode: true,
                    attachments: true //add screenshot for a failed test
                },
            }
        }
    },

Activity

  1. elukoyanov commented on Dec 21, 2020

    @elukoyanov
    Contributor

    yep, I see this error too on 3.0.2

    For failed tests there are error stack and recorder code
    image

    For successful tests - some code
    image

    I am using WebDriver helper without gherkin steps.

    Do you use gherkin, @mirao ?

  2. mirao commented on Dec 21, 2020

    @mirao
    ContributorAuthor

    @elukoyanov No, I do not. I'm also using WebDriver without gherkin

  3. changed the title [-]Mochawesome HTML report: Missing scenario steps (stack) in CodeceptJS 3[/-] [+]Mochawesome HTML report: Missing scenario steps (stack) in CodeceptJS 3 when scenario fails[/+] on Dec 21, 2020
  4. ktryniszewski-mdsol commented on Jan 4, 2021

    @ktryniszewski-mdsol
    Contributor

    I think I accidentally suppressed the gherkin error in 3.0.3 when i was adding logic for bddStep event. Instead of throwing the error it was returning on the whole step when error is encountered. I am not sure if this is related, but I have a fix for that here: #2745

  5. kiranreddyk06 commented on Feb 24, 2021

    @kiranreddyk06

    Hi, I face the same issue. I can not see any steps/verbose information in the report.

    image

  6. ShawnBaumbach commented on Apr 13, 2021

    @ShawnBaumbach

    I'm having the same issue, in the json file, context becomes null and the code is replaced with the same recorder.errHandler blob you posted.

    Using the latest versions of mochawesome (6.2.2) and codeceptjs (3.0.6)

    This only happens if you retry the test. The old data is replaced with this incorrect data.

    Screenshots remain in the folder, but are also not displayed.

    This was not a problem with 2.x.x

    "context": null,
    "code": "recorder.errHandler((err) => {\n recorder.session.start('teardown');\n recorder.cleanAsyncErr();\n if (test.throws) { // check that test should actually fail\n try {\n assertThrown(err, test.throws);\n event.emit(event.test.passed, test);\n event.emit(event.test.finished, test);\n recorder.add(() => done());\n return;\n } catch (newErr) {\n err = newErr;\n }\n }\n event.emit(event.test.failed, test, err);\n event.emit(event.test.finished, test);\n recorder.add(() => done(err));\n});\nif (isAsyncFunction(testFn)) {\n event.emit(event.test.started, test);\n const catchError = e => {\n recorder.throw(e);\n recorder.catch((e) => {\n const err = (recorder.getAsyncErr() === null) ? e : recorder.getAsyncErr();\n recorder.session.start('teardown');\n recorder.cleanAsyncErr();\n event.emit(event.test.failed, test, err);\n event.emit(event.test.finished, test);\n recorder.add(() => done(err));\n });\n };\n let injectedArguments;\n try {\n injectedArguments = getInjectedArguments(testFn, test);\n } catch (e) {\n catchError(e);\n return;\n }\n testFn.call(test, injectedArguments).then(() => {\n recorder.add('fire test.passed', () => {\n event.emit(event.test.passed, test);\n event.emit(event.test.finished, test);\n });\n recorder.add('finish test', () => done());\n recorder.catch();\n }).catch(catchError);\n return;\n}\ntry {\n event.emit(event.test.started, test);\n testFn.call(test, getInjectedArguments(testFn, test));\n} catch (err) {\n recorder.throw(err);\n} finally {\n recorder.add('fire test.passed', () => {\n event.emit(event.test.passed, test);\n event.emit(event.test.finished, test);\n });\n recorder.add('finish test', () => done());\n recorder.catch();\n}",
    "err": {
    "message": "Error: Text "We've sent your info to" was not found on page after 10 sec\nwaiting for function failed: timeout 10000ms exceeded",
    "estack": "Error: Text "We've sent your info to" was not found on page after 10 sec\nwaiting for function failed: timeout 10000ms exceeded\n at C:\PLM\auto-quote-and-buy-ui\node_modules\codeceptjs\lib\helper\Puppeteer.js:2091:13\n at async Actor.takeScreenshot (e2e\src\steps\basic.steps.js:118:5)\n at async Test. (e2e\src\tests\features\send-to-agent_test.js:43:3)",
    "diff": null
    },

  7. locked and limited conversation to collaborators on Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions