mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
fix(experimental): export setupEnvironment for custom pools (#9187)
This commit is contained in:
parent
167d3a98ab
commit
5d26b87b08
@ -120,7 +120,7 @@ Your `CustomPoolRunner` will be controlling how your custom test runner worker l
|
||||
In your worker file, you can import helper utilities from `vitest/worker`:
|
||||
|
||||
```ts [my-worker.ts]
|
||||
import { init, runBaseTests } from 'vitest/worker'
|
||||
import { init, runBaseTests, setupEnvironment } from 'vitest/worker'
|
||||
|
||||
init({
|
||||
post: (response) => {
|
||||
@ -141,7 +141,8 @@ init({
|
||||
deserialize: (value) => {
|
||||
// Optional, provide custom deserializer for `on` callbacks
|
||||
},
|
||||
runTests: state => runBaseTests('run', state),
|
||||
collectTests: state => runBaseTests('collect', state),
|
||||
runTests: (state, traces) => runBaseTests('run', state, traces),
|
||||
collectTests: (state, traces) => runBaseTests('collect', state, traces),
|
||||
setup: setupEnvironment,
|
||||
})
|
||||
```
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
export { runBaseTests } from '../runtime/workers/base'
|
||||
export { runBaseTests, setupEnvironment } from '../runtime/workers/base'
|
||||
export { init } from '../runtime/workers/init'
|
||||
|
||||
@ -30,6 +30,7 @@ function startModuleRunner(options: ContextModuleRunnerOptions) {
|
||||
let _currentEnvironment!: Environment
|
||||
let _environmentTime: number
|
||||
|
||||
/** @experimental */
|
||||
export async function setupEnvironment(context: WorkerSetupContext): Promise<() => Promise<void>> {
|
||||
const startTime = performance.now()
|
||||
const {
|
||||
|
||||
@ -340,6 +340,7 @@ it('exports snapshot', async ({ skip, task }) => {
|
||||
"./worker": {
|
||||
"init": "function",
|
||||
"runBaseTests": "function",
|
||||
"setupEnvironment": "function",
|
||||
},
|
||||
}
|
||||
`)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user