Skip to content

[🐛 Bug]: webdriverio v8 expectationResultHandler property in jasmineOpts no longer has any effect #10530

@mitchellhwright

Description

@mitchellhwright

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

8.10.5

Node.js Version

16.18.0

Mode

WDIO Testrunner

Which capabilities are you using?

No response

What happened?

in wdio v7.30 the jasmineOpts: expectationResultHandler worked fine and would add the function given to that property to all expect calls whether they passed or failed. In wdio 8 I only see this expectationResultHandler called when a expect fails causing the test to fail. Our framework was logging the expects() that passed using this property.

It looks like the jasmine dependency upgrades may have broken this functionality. Another example of breaking jasmine changes is in the jasmineOpts: requires property calls the addRequires() function which is no longer available in jasmine 5.0.0 and was last available in 4.3.0.

What is your expected behavior?

I expected the function defined in the jasmineOpts: expectationResultHandler property to be called for every expect() call whether the expect passes or fails.

How to reproduce the bug.

To reproduce init a new v8 wdio project with all defaults except select jasmine as the test framework instead of mocha.

Update the jasmineOpts property of wdio.conf.js to below:

jasmineOpts: {
    // Jasmine default timeout
    defaultTimeoutInterval: 60000,
    //
    // The Jasmine framework allows interception of each assertion in order to log the state of the application
    // or website depending on the result. For example, it is pretty handy to take a screenshot every time
    // an assertion fails.
    expectationResultHandler: function(passed, assertion) {
        console.error('The jasmineOpts: expectationResultHandler printed this!!!')
    }
},
logLevel: 'warn',

Notice that the 'The jasmineOpts: expectationResultHandler printed this!!!' text is not output for either of the two expect()'s in the sample test. If you make one of the expects fail then it is printed to the console.

Try the same test using @wdio v7 dependencies and you will see that text output by both passed expects().

To reproduce the log output posted in this ticket it's easiest to start by initializing a wdio v7 project selecting all defaults except jasmine instead of mocha, replace jasmineOpts in wdio.conf.js with the code above, and run that. Then delete the node_modules folder, replace the dependencies in package.json with the ones below, reinstall the dependencies, then rerun the test.

{
  "dependencies": {
    "@wdio/cli": "8.10.7"
  },
  "devDependencies": {
    "@wdio/jasmine-framework": "^8.10.7",
    "@wdio/local-runner": "^8.10.7",
    "@wdio/spec-reporter": "^8.10.6",
    "chromedriver": "^114.0.1",
    "wdio-chromedriver-service": "^8.1.1"
  }
}

Relevant log output

wdio v7 output:

mwright@C02C60LBMD6R wdiov7 % npx wdio run ./wdio.conf.js

Execution of 1 workers started at 2023-06-07T19:21:02.706Z

[0-0] RUNNING in chrome - /test/specs/example.e2e.js
[0-0] The jasmineOpts: expectationResultHandler printed this!!!
[0-0] The jasmineOpts: expectationResultHandler printed this!!!
[0-0] PASSED in chrome - /test/specs/example.e2e.js

wdio v8 output:

mwright@C02C60LBMD6R wdiov7 % npx wdio run ./wdio.conf.js

Execution of 1 workers started at 2023-06-07T19:25:03.316Z

[0-0] RUNNING in chrome - file:///test/specs/example.e2e.js
[0-0] PASSED in chrome - file:///test/specs/example.e2e.js


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

### Is there an existing issue for this?

- [X] I have searched the existing issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🐛good first picka reasonable task to start getting familiar with the code basehelp wantedIssues that are free to take by anyone interested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions