| 508 | } |
| 509 | |
| 510 | export async function runInlineTests( |
| 511 | structure: TestFsStructure, |
| 512 | config?: RunVitestConfig, |
| 513 | options?: VitestRunnerCLIOptions, |
| 514 | task?: TestContext['task'], |
| 515 | ) { |
| 516 | const root = resolve(process.cwd(), `vitest-test-${crypto.randomUUID()}`) |
| 517 | const fs = useFS(root, structure, undefined, task) |
| 518 | const vitest = await runVitest({ |
| 519 | root, |
| 520 | ...config, |
| 521 | }, config?.$cliFilters ?? [], options) |
| 522 | return { |
| 523 | fs, |
| 524 | root, |
| 525 | ...vitest, |
| 526 | get results() { |
| 527 | return vitest.ctx?.state.getTestModules() || [] |
| 528 | }, |
| 529 | testTree() { |
| 530 | return buildTestTree(vitest.ctx?.state.getTestModules() || []) |
| 531 | }, |
| 532 | buildTree(onResult: (testResult: TestCase) => any) { |
| 533 | return buildTestTree(vitest.ctx?.state.getTestModules() || [], onResult) |
| 534 | }, |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | const isWindows = process.platform === 'win32' |
| 539 | |