Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Pass context to the parent of PlaywrightEnvironment #819

@juan-fernandez

Description

@juan-fernandez

This line could be changed and it'd help users of PlaywrightEnvironment to leverage the context that's passed to jest environments

From

    constructor(config: JestEnvironmentConfig) {
      super(config)
      this._config = config.projectConfig as JestPlaywrightProjectConfig
    }

to

    constructor(config: JestEnvironmentConfig, context: EnvironmentContext) {
      super(config, context)
      this._config = config.projectConfig as JestPlaywrightProjectConfig
    }

This is actually how jest recommends creating your own test environment in their docs:

// my-custom-environment
const NodeEnvironment = require('jest-environment-node').TestEnvironment;

class CustomEnvironment extends NodeEnvironment {
  constructor(config, context) {
    super(config, context);
    console.log(config.globalConfig);
    console.log(config.projectConfig);
    this.testPath = context.testPath;
    this.docblockPragmas = context.docblockPragmas;
  }
  ...

Describe the solution you'd like
Passing context when calling super

Additional context
This is an issue specifically for Datadog's test visibility.

If you're OK with this change I can contribute it myself 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions