vitest 2.1.0-beta.4 → 2.1.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/LICENSE.md +29 -0
  2. package/dist/browser.d.ts +4 -3
  3. package/dist/browser.js +2 -2
  4. package/dist/chunks/{RandomSequencer.B4M2ux5b.js → RandomSequencer.CjkAy_bL.js} +67 -21
  5. package/dist/chunks/{base.BYvKfYzm.js → base.B-9RAXb6.js} +1 -1
  6. package/dist/chunks/{cac.C8rwFluK.js → cac.BZlOqtiQ.js} +7 -6
  7. package/dist/chunks/{cli-api.Bej3bUwz.js → cli-api.B-2f6g4d.js} +7541 -7357
  8. package/dist/chunks/{constants.CaAN7icJ.js → constants.fzPh7AOq.js} +1 -1
  9. package/dist/chunks/{coverage.CqfT4xaf.js → coverage.zlNdAMHK.js} +5 -3
  10. package/dist/chunks/{creator.GreKbaUc.js → creator.D0TxjnLa.js} +27 -22
  11. package/dist/chunks/{environment.0M5R1SX_.d.ts → environment.C5eAp3K6.d.ts} +1 -1
  12. package/dist/chunks/{globals.DRPLtPOv.js → globals.Br36EZIp.js} +3 -3
  13. package/dist/chunks/{index.YuPJueCg.js → index.C4LZENmc.js} +4446 -4416
  14. package/dist/chunks/index.CWhwfxXK.js +835 -0
  15. package/dist/chunks/{index.CxWPpGJz.js → index.dWDhoZDV.js} +2 -2
  16. package/dist/chunks/{index.CNZXZ9PJ.js → index.m3Xip5Zz.js} +1 -1
  17. package/dist/chunks/{reporters.DRZ7ndzr.d.ts → reporters.B0Ao6Zu1.d.ts} +154 -117
  18. package/dist/chunks/{resolveConfig.CGobt8AB.js → resolveConfig.C0vpvVRF.js} +43 -33
  19. package/dist/chunks/{runBaseTests.BAhL8UH_.js → runBaseTests.Cf8lGnUq.js} +5 -5
  20. package/dist/chunks/{setup-common.KBrCO5LJ.js → setup-common.B7uEQsGB.js} +1 -1
  21. package/dist/chunks/{vi.B6QZ938s.js → vi.DBepMgvg.js} +9 -0
  22. package/dist/chunks/vite.Bvz2vSw0.d.ts +11 -0
  23. package/dist/chunks/{worker.BANO5ak1.d.ts → worker.CTdJUeeB.d.ts} +3 -2
  24. package/dist/chunks/{worker.Cx2xE71X.d.ts → worker.DTM-0OlZ.d.ts} +1 -1
  25. package/dist/cli.js +2 -2
  26. package/dist/config.cjs +1 -0
  27. package/dist/config.d.ts +70 -2
  28. package/dist/config.js +1 -0
  29. package/dist/coverage.d.ts +4 -3
  30. package/dist/coverage.js +27 -3
  31. package/dist/environments.d.ts +2 -2
  32. package/dist/execute.d.ts +2 -2
  33. package/dist/index.d.ts +11 -6
  34. package/dist/index.js +3 -3
  35. package/dist/node.d.ts +17 -7
  36. package/dist/node.js +39 -36
  37. package/dist/reporters.d.ts +2 -2
  38. package/dist/reporters.js +5 -5
  39. package/dist/runners.js +1 -1
  40. package/dist/workers/forks.js +1 -1
  41. package/dist/workers/runVmTests.js +5 -5
  42. package/dist/workers/threads.js +1 -1
  43. package/dist/workers.d.ts +4 -16
  44. package/dist/workers.js +1 -1
  45. package/package.json +12 -12
  46. package/dist/chunks/index.DNUmWFkO.js +0 -319
@@ -43,4 +43,4 @@ const globalApis = [
43
43
  "onTestFailed"
44
44
  ];
45
45
 
46
- export { API_PATH as A, CONFIG_NAMES as C, defaultBrowserPort as a, defaultInspectPort as b, configFiles as c, defaultPort as d, extraInlineDeps as e, globalApis as g, workspacesFiles as w };
46
+ export { API_PATH as A, defaultBrowserPort as a, defaultInspectPort as b, configFiles as c, defaultPort as d, extraInlineDeps as e, globalApis as g, workspacesFiles as w };
@@ -8,9 +8,11 @@ async function resolveCoverageProviderModule(options, loader) {
8
8
  }
9
9
  const provider = options.provider;
10
10
  if (provider === "v8" || provider === "istanbul") {
11
- const { default: coverageModule } = await loader.executeId(
12
- CoverageProviderMap[provider]
13
- );
11
+ let builtInModule = CoverageProviderMap[provider];
12
+ if (provider === "v8" && loader.isBrowser) {
13
+ builtInModule += "/browser";
14
+ }
15
+ const { default: coverageModule } = await loader.executeId(builtInModule);
14
16
  if (!coverageModule) {
15
17
  throw new Error(
16
18
  `Failed to load ${CoverageProviderMap[provider]}. Default export is missing.`
@@ -3,9 +3,9 @@ import { existsSync, writeFileSync, readFileSync } from 'node:fs';
3
3
  import { mkdir, writeFile } from 'node:fs/promises';
4
4
  import { p as prompt, f as findUp } from './index.CM5UI-4O.js';
5
5
  import c from 'tinyrainbow';
6
- import { detectPackageManager, installPackage } from './index.DNUmWFkO.js';
6
+ import { detectPackageManager, installPackage } from './index.CWhwfxXK.js';
7
7
  import { execa } from 'execa';
8
- import { c as configFiles } from './constants.CaAN7icJ.js';
8
+ import { c as configFiles } from './constants.fzPh7AOq.js';
9
9
  import 'node:url';
10
10
  import 'node:process';
11
11
  import './_commonjsHelpers.BFTU3MAI.js';
@@ -15,6 +15,9 @@ import 'fs';
15
15
  import 'path';
16
16
  import 'process';
17
17
  import 'url';
18
+ import 'node:module';
19
+ import 'child_process';
20
+ import 'stream';
18
21
 
19
22
  const jsxExample = {
20
23
  name: "HelloWorld.jsx",
@@ -43,8 +46,7 @@ import HelloWorld from './HelloWorld.jsx'
43
46
 
44
47
  test('renders name', () => {
45
48
  const { getByText } = render(<HelloWorld name="Vitest" />)
46
- const element = getByText('Hello Vitest!')
47
- expect(element).toBeInTheDocument()
49
+ await expect.element(getByText('Hello Vitest!')).toBeInTheDocument()
48
50
  })
49
51
  `
50
52
  };
@@ -78,15 +80,14 @@ defineProps<{
78
80
  `,
79
81
  test: `
80
82
  import { expect, test } from 'vitest'
81
- import { render } from '@testing-library/vue'
83
+ import { render } from 'vitest-browser-vue'
82
84
  import HelloWorld from './HelloWorld.vue'
83
85
 
84
86
  test('renders name', () => {
85
87
  const { getByText } = render(HelloWorld, {
86
88
  props: { name: 'Vitest' },
87
89
  })
88
- const element = getByText('Hello Vitest!')
89
- expect(element).toBeInTheDocument()
90
+ await expect.element(getByText('Hello Vitest!')).toBeInTheDocument()
90
91
  })
91
92
  `
92
93
  };
@@ -108,15 +109,12 @@ const svelteExample = {
108
109
  `,
109
110
  test: `
110
111
  import { expect, test } from 'vitest'
111
- import { render } from '@testing-library/svelte'
112
+ import { render } from 'vitest-browser-svelte'
112
113
  import HelloWorld from './HelloWorld.svelte'
113
114
 
114
115
  test('renders name', () => {
115
- const { getByText } = render(HelloWorld, {
116
- props: { name: 'Vitest' },
117
- })
118
- const element = getByText('Hello Vitest!')
119
- expect(element).toBeInTheDocument()
116
+ const { getByText } = render(HelloWorld, { name: 'Vitest' })
117
+ await expect.element(getByText('Hello Vitest!')).toBeInTheDocument()
120
118
  })
121
119
  `
122
120
  };
@@ -192,11 +190,15 @@ function getExampleTest(framework) {
192
190
  switch (framework) {
193
191
  case "solid":
194
192
  case "preact":
195
- case "react":
196
193
  return {
197
194
  ...jsxExample,
198
195
  test: jsxExample.test.replace("@testing-library/jsx", `@testing-library/${framework}`)
199
196
  };
197
+ case "react":
198
+ return {
199
+ ...jsxExample,
200
+ test: jsxExample.test.replace("@testing-library/jsx", "vitest-browser-react")
201
+ };
200
202
  case "vue":
201
203
  return vueExample;
202
204
  case "svelte":
@@ -315,13 +317,13 @@ function getFramework() {
315
317
  function getFrameworkTestPackage(framework) {
316
318
  switch (framework) {
317
319
  case "vanilla":
318
- return "@testing-library/dom";
320
+ return null;
319
321
  case "vue":
320
- return "@testing-library/vue";
322
+ return "vitest-browser-vue";
321
323
  case "svelte":
322
- return "@testing-library/svelte";
324
+ return "vitest-browser-svelte";
323
325
  case "react":
324
- return "@testing-library/react";
326
+ return "vitest-browser-react";
325
327
  case "preact":
326
328
  return "@testing-library/preact";
327
329
  case "solid":
@@ -467,7 +469,7 @@ async function generateWorkspaceFile(options) {
467
469
  ` },`,
468
470
  `])`,
469
471
  ""
470
- ].filter((c2) => c2 != null).join("\n");
472
+ ].filter((c2) => typeof c2 === "string").join("\n");
471
473
  await writeFile(options.configPath, workspaceContent);
472
474
  }
473
475
  async function generateFrameworkConfigFile(options) {
@@ -489,7 +491,7 @@ async function generateFrameworkConfigFile(options) {
489
491
  ` },`,
490
492
  `})`,
491
493
  ""
492
- ].join("\n");
494
+ ].filter((t) => typeof t === "string").join("\n");
493
495
  await writeFile(options.configPath, configContent);
494
496
  }
495
497
  async function updatePkgJsonScripts(pkgJsonPath, vitestScript) {
@@ -598,9 +600,12 @@ async function create() {
598
600
  return fail();
599
601
  }
600
602
  const dependenciesToInstall = [
601
- "@vitest/browser",
602
- getFrameworkTestPackage(framework)
603
+ "@vitest/browser"
603
604
  ];
605
+ const frameworkPackage = getFrameworkTestPackage(framework);
606
+ if (frameworkPackage) {
607
+ dependenciesToInstall.push(frameworkPackage);
608
+ }
604
609
  const providerPkg = getProviderPackageNames(provider);
605
610
  if (providerPkg.pkg) {
606
611
  dependenciesToInstall.push(providerPkg.pkg);
@@ -17,7 +17,7 @@ interface ModuleCache {
17
17
  }
18
18
  interface AfterSuiteRunMeta {
19
19
  coverage?: unknown;
20
- transformMode: TransformMode;
20
+ transformMode: TransformMode | 'browser';
21
21
  projectName?: string;
22
22
  }
23
23
  interface UserConsoleLog {
@@ -1,5 +1,5 @@
1
- import { g as globalApis } from './constants.CaAN7icJ.js';
2
- import { V as VitestIndex } from './index.CNZXZ9PJ.js';
1
+ import { g as globalApis } from './constants.fzPh7AOq.js';
2
+ import { V as VitestIndex } from './index.m3Xip5Zz.js';
3
3
  import '@vitest/runner';
4
4
  import './benchmark.C8CRJYG4.js';
5
5
  import '@vitest/runner/utils';
@@ -10,7 +10,7 @@ import './utils.Ck2hJTRs.js';
10
10
  import './env.CmHVDJnw.js';
11
11
  import 'std-env';
12
12
  import './run-once.Sxe67Wng.js';
13
- import './vi.B6QZ938s.js';
13
+ import './vi.DBepMgvg.js';
14
14
  import 'chai';
15
15
  import './_commonjsHelpers.BFTU3MAI.js';
16
16
  import '@vitest/expect';