Skip to content

[🐛 Bug]: jasmine.addMatchers(...) does not work with injectGlobals set to true. #10586

@PSpSynedra

Description

@PSpSynedra

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

8.11.2

Node.js Version

18.13.0

Mode

WDIO Testrunner

Which capabilities are you using?

No response

What happened?

In our project we use Custom Matchers from jasmine to simplify testing of certain expectations.

We have set up wdio to use the jasmine-framework adapter (v.8.11.2) by setting the config framework to jasmine.
When setting injectGlobals in the wdio-config to false - everything works fine.
When setting injectGlobals in the wdio-config to true - the custom matchers won't be present on the return value of expect(...)

A workaround currently implemented sets injectGlobals to false and explicitly defines globals from @wdio/globals on the global-Object.

What is your expected behavior?

A call to jasmine.addMatchers(...) should add the defined matchers to return values of expect-calls as described in the jasemine Documentation of addMatchers(...).

How to reproduce the bug.

I have provided a Demo Project that reproduces the bug and allows simple testing of the proposed workaround.

Relevant log output

"spec" Reporter:
------------------------------------------------------------------
[chrome 114.0.5735.133 linux #0-0] Running: chrome (v114.0.5735.133) on linux
[chrome 114.0.5735.133 linux #0-0] Session ID: 06e7c5baadf140e1dfe3c126f2a73c01
[chrome 114.0.5735.133 linux #0-0]
[chrome 114.0.5735.133 linux #0-0] » /test/specs/CustomMatchersTest.js
[chrome 114.0.5735.133 linux #0-0] expect utility
[chrome 114.0.5735.133 linux #0-0]     should provide the custom matcher
[chrome 114.0.5735.133 linux #0-0]
[chrome 114.0.5735.133 linux #0-0] 1 failing (61ms)
[chrome 114.0.5735.133 linux #0-0]
[chrome 114.0.5735.133 linux #0-0] 1) expect utility should provide the custom matcher
[chrome 114.0.5735.133 linux #0-0] Expected undefined to be defined.      


### 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