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

'Piggyback' data as result from worker to main process #3447

Closed
4 tasks done
nicojs opened this issue May 25, 2023 · 0 comments · Fixed by #3449
Closed
4 tasks done

'Piggyback' data as result from worker to main process #3447

nicojs opened this issue May 25, 2023 · 0 comments · Fixed by #3449

Comments

@nicojs
Copy link
Contributor

nicojs commented May 25, 2023

Clear and concise description of the problem

When developing tools atop of vitest using the programmatic API, tools, like mutation testing frameworks (i.e. StrykerJS), sometimes need to report additional data from the testing environment back to the main process.

See #3017 (reply in thread)

Suggested solution

Using a custom vitest.setup.js

import { afterAll } from 'vitest';

afterAll((suite) => {
  suite.meta.custom = stuff;
});

A tool could use this:

const vitest = await createVitest("test", { watch: false });
vitest.projects[0].config.setupFiles = ["vitest.setup.js"];
await vitest.start();
vitest.state.getFiles()[0].result.meta.custom // per suite/worker we can get the custom data here

Alternative

An rpc approach is also mentioned here: #3017 (reply in thread)

Additional context

The vitest-plugin in StrykerJS currently uses files to communicate between the test environment and the main process. This works, but doesn't support "Browser mode".

Validations

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

Successfully merging a pull request may close this issue.

2 participants