Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support "setupFilesAfterEnv" #16

Closed
kayahr opened this issue Apr 13, 2022 · 3 comments · Fixed by #21
Closed

Support "setupFilesAfterEnv" #16

kayahr opened this issue Apr 13, 2022 · 3 comments · Fixed by #21

Comments

@kayahr
Copy link

kayahr commented Apr 13, 2022

Custom matcher libraries like jest-extended suggest to load the extension by specifying setupFilesAfterEnv in the Jest configuration. This doesn't work with jest-light-runner, it is simply ignored so I have to load jest-extended in every test file manually. Maybe it would be possible to support the setupFilesAfterEnv configuration?

@nicolo-ribaudo
Copy link
Owner

nicolo-ribaudo commented Apr 24, 2022

Hi! Would you like to open a PR for this? We can probably:

  • Get that option from config in
    constructor(config) {
    this.#config = config;
    this.#piscina = new Piscina({
    filename: new URL("./worker-runner.js", import.meta.url).href,
    maxThreads: this.#config.maxWorkers,
    env: {
    // Workers don't have a tty; we whant them to inherit
    // the color support level from the main thread.
    FORCE_COLOR: supportsColor.stdout.level,
    ...process.env,
    },
    });
    , and pass it to Piscina using the workerData option
  • In the top level of https://github.com/nicolo-ribaudo/jest-light-runner/blob/main/src/worker-runner.js, do something like const setupP = Promise.all(setupFilesAfterEnv.map(path => import(path)));
  • In the worker main function at
    export default async function ({
    , before doing anything (before port.postMessage("start");), we should await setupP to make sure that the setup files are loaded before running any test.

@nicolo-ribaudo
Copy link
Owner

Ignore the previous message. After that #21 is merge, it can be implemented in the same way that setupFiles is implemented.

@nicolo-ribaudo
Copy link
Owner

Ok, I ended up implementing this by myself in #21.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants