(options: TestUserConfig, cli: string[], fs: TestFsStructure = {})
| 659 | }) |
| 660 | |
| 661 | function getCliConfig(options: TestUserConfig, cli: string[], fs: TestFsStructure = {}) { |
| 662 | const root = resolve(process.cwd(), `vitest-test-${crypto.randomUUID()}`) |
| 663 | useFS(root, { |
| 664 | ...fs, |
| 665 | 'basic.test.ts': /* ts */` |
| 666 | import { test } from 'vitest' |
| 667 | test('basic', () => { |
| 668 | expect(1).toBe(1) |
| 669 | }) |
| 670 | `, |
| 671 | 'vitest.config.ts': /* ts */ ` |
| 672 | export default { |
| 673 | test: { |
| 674 | reporters: [ |
| 675 | { |
| 676 | onInit(vitest) { |
| 677 | const browser = vitest.config.browser |
| 678 | const workspace = (p) => ({ |
| 679 | name: p.name, |
| 680 | headless: p.config.browser.headless, |
| 681 | browser: p.config.browser.enabled, |
| 682 | ui: p.config.browser.ui, |
| 683 | locators: p.config.browser.locators, |
| 684 | }) |
| 685 | console.log(JSON.stringify({ |
| 686 | browser: { |
| 687 | headless: browser.headless, |
| 688 | browser: browser.enabled, |
| 689 | ui: browser.ui, |
| 690 | }, |
| 691 | workspace: vitest.projects.map(p => { |
| 692 | return { |
| 693 | ...workspace(p), |
| 694 | parent: p._parent ? workspace(p._parent) : null, |
| 695 | } |
| 696 | }) |
| 697 | })) |
| 698 | // throw an error to avoid running tests |
| 699 | throw new Error('stop') |
| 700 | }, |
| 701 | }, |
| 702 | ], |
| 703 | ...${JSON.stringify(options)} |
| 704 | } |
| 705 | } |
| 706 | `, |
| 707 | }) |
| 708 | return runVitestCli( |
| 709 | { |
| 710 | nodeOptions: { |
| 711 | env: { |
| 712 | CI: '', |
| 713 | GITHUB_ACTIONS: undefined, |
| 714 | }, |
| 715 | }, |
| 716 | }, |
| 717 | '--root', |
| 718 | root, |
no test coverage detected