jest-playwright icon indicating copy to clipboard operation
jest-playwright copied to clipboard

Allow extending `handleTestEvent` in `PlaywrightEnvironment`

Open juan-fernandez opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe. This is specifically a problem for libraries intercepting jest-environment-* libraries to create integrations.

In this specific line:

    async handleTestEvent(event: Event) {
      const { browserName } = this._config
      const { collectCoverage, haveSkippedTests } = this._jestPlaywrightConfig
      const browserType = getBrowserType(browserName)
      //...

we're not calling super.handleTestEvent which would help said libraries.

Describe the solution you'd like Change to above to

    async handleTestEvent(event: Event) {
      // calling `super.handleTestEvent` in case it's there
      if (super.handleTestEvent) {
        await super.handleTestEvent.apply(this, arguments)
      }
      const { browserName } = this._config
      const { collectCoverage, haveSkippedTests } = this._jestPlaywrightConfig
      const browserType = getBrowserType(browserName)
      //...

This would help:

  • in case jest-environment-* libraries decide to implement their own handleTestEvent
  • with Datadog's test visibility library, making it easier to integrate both libraries

Describe alternatives you've considered Calling super.handleTestEvent seems low risk, so no alternatives were considered.

juan-fernandez avatar Sep 19 '24 13:09 juan-fernandez

PR in #822

juan-fernandez avatar Sep 19 '24 13:09 juan-fernandez