Skip to content

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

@nicojs

Description

@nicojs

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions