From 7c993e94542a8ae3ab101da7cf4317080696215e Mon Sep 17 00:00:00 2001 From: Vladimir Date: Fri, 26 Apr 2024 15:43:27 +0200 Subject: [PATCH 1/2] test: standardising internal test (#5600) --- .github/workflows/ci.yml | 31 +- .gitignore | 2 +- eslint.config.js | 4 +- package.json | 9 +- packages/vitest/src/node/pool.ts | 7 + packages/vitest/src/suite.ts | 2 +- packages/vitest/src/utils/env.ts | 1 + packages/vitest/src/utils/index.ts | 3 +- pnpm-lock.yaml | 782 ++---------------- test/README.md | 31 + test/bail/package.json | 14 - test/bail/test/bail.test.ts | 53 -- test/bail/vitest.config.ts | 15 - test/base/package.json | 12 - test/base/test/mocking-with-base.spec.ts | 10 - test/base/vitest.config.ts | 5 - test/browser/package.json | 7 +- test/browser/specs/filter.test.mjs | 36 - test/browser/specs/filter.test.ts | 14 + test/browser/specs/fix-4686.test.mjs | 20 - test/browser/specs/fix-4686.test.ts | 19 + test/browser/specs/run-vitest.mjs | 39 - test/browser/specs/runner.test.mjs | 77 -- test/browser/specs/runner.test.ts | 86 ++ test/browser/specs/server-url.test.mjs | 26 - test/browser/specs/server-url.test.ts | 24 + test/browser/specs/update-snapshot.test.mjs | 70 -- test/browser/specs/update-snapshot.test.ts | 36 + test/browser/specs/utils.ts | 28 + test/browser/tsconfig.json | 1 - test/browser/vitest.config.mts | 2 +- test/browser/vitest.config.unit.mts | 14 + test/changed/package.json | 11 - test/changed/tests/forceRerunTrigger.test.ts | 36 - test/changed/tests/related.test.ts | 18 - test/changed/tests/workspaceRelated.test.ts | 27 - test/changed/vitest.config.js | 9 - test/cjs/package.json | 21 - test/cjs/src/other.cjs | 2 - test/cjs/src/other.d.cts | 5 - test/cjs/src/prototype.d.cts | 2 - test/cjs/test/fs-extra.test.ts | 12 - test/cjs/test/function-default.test.ts | 13 - test/cjs/test/history.test.ts | 9 - test/cjs/test/interpret-default.test.tsx | 24 - test/cjs/test/prototype.test.ts | 8 - test/cjs/tsconfig.json | 5 - test/cjs/vitest.config.ts | 9 - test/{env-custom-file => cli}/custom.ts | 0 .../custom-file-env/custom-file-env.test.ts} | 2 +- .../fixtures/custom-pool}/pool/custom-pool.ts | 0 .../custom-pool}/tests/custom-not-run.spec.ts | 0 .../tests/custom-run.threads.spec.ts | 0 .../fixtures/custom-pool}/vitest.config.ts | 0 .../test/.cache/should-not-run.test.ts | 0 .../.cache/projects/test/should-run.test.ts | 0 .../expect-soft}/expects/soft.test.ts | 0 .../fixtures/expect-soft}/vite.config.ts | 0 .../fails}/.dot-folder/dot-test.test.ts | 0 .../fixtures/fails}/each-timeout.test.ts | 0 .../test => cli/fixtures/fails}/empty.test.ts | 0 .../fixtures/fails}/expect-soft.test.ts | 0 .../fails}/expect-unreachable.test.ts | 0 .../fixtures/fails}/expect.test.ts | 0 .../fixtures/fails}/hook-timeout.test.ts | 0 .../fixtures/fails}/hooks-called.test.ts | 0 .../inline-snapshop-inside-each.test.ts | 0 .../fails}/mock-import-proxy-module.test.ts | 0 .../fixtures/fails}/nested-suite.test.ts | 0 .../fixtures/fails}/primitive-error.test.ts | 0 .../fixtures/fails}/proxy-module.ts | 0 .../fixtures/fails}/snapshot-with-not.test.ts | 0 .../fixtures/fails}/stall.test.ts | 0 .../test-extend/circular-dependency.test.ts | 0 .../fails}/test-extend/fixture-error.test.ts | 0 .../test-extend/fixture-rest-params.test.ts | 0 .../test-extend/fixture-rest-props.test.ts | 0 .../fixture-without-destructuring.test.ts | 0 .../test-extend/test-rest-params.test.ts | 0 .../test-extend/test-rest-props.test.ts | 0 .../test-without-destructuring.test.ts | 0 .../fixtures/fails}/test-timeout.test.ts | 0 .../fixtures/fails}/unhandled.test.ts | 0 .../fixtures/fails}/vite.config.ts | 0 .../related/deep-related-exports.test.ts | 0 .../related/deep-related-imports.test.ts | 0 .../git-changed}/related/not-related.test.ts | 0 .../git-changed}/related/related.test.ts | 0 .../git-changed}/related/src/sourceA.ts | 0 .../git-changed}/related/src/sourceB.ts | 0 .../git-changed}/related/src/sourceC.ts | 0 .../git-changed}/related/src/sourceD.ts | 0 .../git-changed}/related/vitest.config.js | 0 .../git-changed}/workspace/package.json | 0 .../workspace/packages/packageA/index.js | 0 .../workspace/packages/packageA/index.test.js | 0 .../packages/packageA/vitest.config.mjs | 0 .../workspace/packages/packageB/index.js | 0 .../workspace/packages/packageB/index.test.js | 0 .../packages/packageB/vitest.config.mjs | 0 .../git-changed}/workspace/vitest.config.mjs | 0 .../workspace/vitest.workspace.js | 0 .../global-setup-fail}/example.test.ts | 0 .../global-setup-fail}/globalSetup/error.js | 0 .../global-setup-fail}/vitest.config.ts | 0 .../fixtures/inspect}/math.test.ts | 0 .../fixtures/inspect}/vitest.config.ts | 0 ....timestamp-1713887058308-b154731a64b17.mjs | 12 + .../fixtures/network-imports}/basic.test.ts | 0 .../network-imports/public/slash@3.0.0.js | 0 .../fixtures/public-api}/custom.spec.ts | 0 .../fixtures/public-api}/vitest.config.ts | 0 .../fixtures/restricted-fs}/src/math.js | 0 .../restricted-fs}/tests/basic.spec.js | 0 .../fixtures/restricted-fs}/vitest.config.ts | 0 .../fixtures/restricted-fs}/vitest.setup.js | 0 .../fixtures/setup-files}/console-setup.ts | 0 .../fixtures/setup-files}/empty-setup.ts | 0 .../fixtures/setup-files/empty.test.ts} | 0 .../stacktraces}/add-in-imba.test.imba | 0 .../fixtures/stacktraces}/add-in-js.test.js | 0 .../fixtures/stacktraces}/add.test.ts | 0 .../stacktraces}/error-in-deps.test.js | 0 .../stacktraces}/error-with-stack.test.js | 0 .../fixtures/stacktraces}/foo.js | 0 .../fixtures/stacktraces}/frame.spec.imba | 0 .../stacktraces}/mocked-global.test.js | 0 .../stacktraces}/mocked-imported.test.js | 0 .../stacktraces}/mocked-imported.test.ts | 0 .../stacktraces}/reset-modules.test.ts | 0 .../fixtures/stacktraces}/setup.js | 0 .../fixtures/stacktraces}/utils.ts | 0 .../fixtures/stacktraces}/vite.config.ts | 0 .../fixtures/tty}/example.test.ts | 0 .../fixtures => cli/fixtures/tty}/example.ts | 0 .../fixtures/tty}/math.test.ts | 0 .../fixtures => cli/fixtures/tty}/math.ts | 0 .../fixtures/tty}/vitest.config.ts | 0 test/cli/fixtures/vitest.config.js | 2 + .../import-external-css-assets.test.js | 12 +- .../fixtures/vm-threads}/module.test.js | 0 .../fixtures/vm-threads}/not-found.test.ts | 2 +- .../fixtures/vm-threads}/require-cjs.test.js | 8 +- .../vm-threads/src/external/assets/file1.png | 0 .../vm-threads/src/external/assets/file2.txt | 0 .../vm-threads/src/external/assets/file3.svg | 0 .../vm-threads/src/external/css/empty.css | 0 .../vm-threads/src/external/css/processed.css | 0 .../src/external/css/processed.module.css | 0 .../vm-threads/src/external/default-cjs.cjs | 0 .../src/external/export-default-cjs.js | 0 .../src/external/export-nested-default-cjs.js | 0 .../src/external/nested-default-cjs.cjs | 0 .../vm-threads/src/external/not-found.js | 0 .../src/external/package-null/package-null.js | 0 .../vm-threads/src/external/package.json | 0 .../vm-threads/src/external/primitive-cjs.cjs | 0 .../fixtures}/vm-threads/vitest.config.ts | 0 .../fixtures/ws-server-url}/basic.test.ts | 0 .../fixtures/ws-server-url}/vitest.config.ts | 0 test/cli/package.json | 11 +- .../test/__snapshots__/fails.test.ts.snap} | 0 .../__snapshots__/stacktraces.test.ts.snap} | 0 test/{run => cli}/test/custom-pool.test.ts | 4 +- test/cli/test/dotted-files.test.ts | 10 + .../test/expect-soft.test.ts} | 13 +- .../runner.test.ts => cli/test/fails.test.ts} | 2 +- test/cli/test/git-changed.test.ts | 76 ++ .../test/global-setup-fail.test.ts} | 2 +- test/{inspect => cli}/test/inspect.test.ts | 8 +- test/cli/test/network-imports.test.ts | 37 + .../test/public-api.test.ts} | 2 +- test/cli/test/restricted-fs.test.ts | 14 + test/cli/test/run-custom-env.test.ts | 19 + .../tests => cli/test}/server-url.test.ts | 4 +- test/cli/test/setup-files.test.ts | 42 + .../test/stacktraces.test.ts} | 20 +- test/{run => cli}/test/tty.test.ts | 2 +- test/cli/test/vm-threads.test.ts | 17 + test/cli/vitest.config.ts | 5 + .../allowed-exec-argv.test.ts | 2 - .../vitest.config.ts | 0 .../fixtures/bail}/test/first.test.ts | 0 .../fixtures/bail}/test/second.test.ts | 0 .../fixtures/bail}/vitest.config.ts | 0 .../fixtures/base-path}/src/index.ts | 0 .../base-path/test/mocking-with-base.spec.ts | 14 + test/{css/src => config/fixtures/css}/App.css | 0 .../fixtures/css}/App.module.css | 0 .../fixtures}/css/test/default-css.spec.ts | 14 +- .../css/test/non-scope-module.spec.ts | 2 +- .../fixtures}/css/test/process-css.spec.ts | 14 +- .../fixtures}/css/test/process-inline.spec.ts | 6 +- .../fixtures}/css/test/process-module.spec.ts | 12 +- .../fixtures}/css/test/scope-module.spec.ts | 2 +- .../test => config/fixtures/css}/utils.ts | 0 .../fixtures/exclude/math.test.ts | 0 test/{cli => config}/fixtures/exclude/math.ts | 0 .../fixtures/exclude/string.test.ts | 0 .../fixtures/exclude/string.ts | 0 .../fixtures/exclude/vitest.exclude.config.ts | 0 .../exec-args-fixtures/forks.test.ts | 0 .../exec-args-fixtures/threads.test.ts | 0 .../exec-args-fixtures/vmThreads.test.ts | 0 .../filters-slash}/test/basic-foo/a.test.ts | 0 .../filters-slash}/test/basic.test.ts | 0 .../filters-slash}/test/basic/a.test.ts | 0 .../filters-slash}/test/foo-basic/a.test.ts | 0 .../fixtures/filters-slash}/vitest.config.ts | 0 .../fixtures/filters/test/config.test.ts} | 0 .../filters}/test/dont-run-this.test.ts | 0 .../fixtures/filters}/test/example.test.ts | 0 .../project/test/happy-dom.test.ts | 0 .../project/test/jsdom.test.ts | 0 .../project/test/node.test.ts | 0 .../project/test/workspace-project.test.ts | 0 .../mixed-environments}/vitest.config.ts | 0 .../mixed-environments}/vitest.workspace.ts | 0 .../no-exec-argv.test.ts | 0 .../no-exec-args-fixtures}/vitest.config.ts | 0 .../fixtures/pass-empty-files}/empty.test.ts | 0 .../project/packages/project_1/base.test.ts | 0 .../project/packages/project_2/base.test.ts | 0 .../project/packages/space_1/base.test.ts | 0 .../fixtures/project/vitest.config.ts | 0 .../fixtures/project/vitest.workspace.ts | 0 .../fixtures}/shard/test/1.test.js | 0 .../fixtures}/shard/test/2.test.js | 0 .../fixtures}/shard/test/3.test.js | 0 test/config/fixtures/shard/vitest.config.js | 1 + test/config/fixtures/test/vitest.config.js | 7 + test/config/fixtures/vitest.config.js | 3 + test/config/test/bail.test.ts | 57 ++ test/config/test/base-path.test.ts | 12 + test/config/test/css-configs.test.ts | 21 + test/{cli => config}/test/exclude.test.ts | 0 test/{run => config}/test/exec-args.test.ts | 15 +- test/config/test/failures.test.ts | 9 +- .../test/mixed-environments.test.ts | 2 +- .../{resolution.test.ts => override.test.ts} | 0 test/config/test/pass-empty-files.test.ts | 10 + test/{cli => config}/test/project.test.ts | 0 .../test/shard.test.ts} | 4 +- .../test/testname-pattern.test.ts | 22 +- test/config/tsconfig.json | 4 + test/config/vitest.config.ts | 5 + .../deps/dep1/esm/index.js | 0 .../deps/dep1/package.json | 0 test/{vite-node => core}/deps/dep2/index.js | 0 .../deps/dep2/package.json | 0 test/core/index.html | 11 + test/core/package.json | 11 +- .../src/cjs/default-function.d.ts} | 0 .../src/cjs/default-function.js} | 0 .../src/cjs/prototype-cjs.js} | 0 .../src/external}/pkg-browser/index.d.ts | 0 .../src/external}/pkg-browser/package.json | 0 .../src/external}/pkg-browser/ssr.js | 0 .../src/external}/pkg-browser/web.js | 0 .../src/external}/pkg-node/index.d.ts | 0 .../src/external}/pkg-node/package.json | 0 .../src/external}/pkg-node/ssr.js | 0 .../src/external}/pkg-node/web.js | 0 .../src => core/src/in-source}/add.ts | 0 .../src => core/src/in-source}/fibonacci.ts | 0 .../src => core/src/in-source}/index.ts | 0 .../src => core/src/wasm}/add.wasm | Bin .../wasm}/wasm-bindgen-no-cyclic/README.md | 0 .../wasm}/wasm-bindgen-no-cyclic/index.d.ts | 0 .../src/wasm}/wasm-bindgen-no-cyclic/index.js | 0 .../wasm}/wasm-bindgen-no-cyclic/index_bg.js | 0 .../wasm-bindgen-no-cyclic/index_bg.wasm | Bin .../wasm-bindgen-no-cyclic/index_bg.wasm.d.ts | 0 .../wasm}/wasm-bindgen-no-cyclic/package.json | 0 .../src/wasm}/wasm-bindgen/README.md | 0 .../src/wasm}/wasm-bindgen/index.js | 0 .../src/wasm}/wasm-bindgen/index_bg.js | 0 .../src/wasm}/wasm-bindgen/index_bg.wasm | Bin .../src/wasm}/wasm-bindgen/package.json | 0 .../src/web-worker}/eventListenerWorker.ts | 0 .../src/web-worker}/objectWorker.ts | 0 .../src => core/src/web-worker}/selfWorker.ts | 0 .../src/web-worker}/selfWorkerDep.ts | 0 .../src/web-worker}/sharedWorker.ts | 0 .../src => core/src/web-worker}/worker.ts | 0 .../snapshot-concurrent-sync.test.ts.snap} | 2 +- .../snapshot-concurrent.test.ts.snap} | 0 .../test/__snapshots__/snapshot.test.ts.snap | 11 + .../test/child-specific.child_process.test.ts | 0 .../test/dual-package-hazard.test.ts} | 0 test/{edge-runtime => core}/test/edge.test.ts | 3 +- .../env-glob-dom/env-glob.overrides.spec.ts} | 0 .../test/env-glob-dom/env-glob.spec.ts} | 0 .../test/env-glob.dom.test.ts} | 0 .../test/env-glob.test.ts} | 0 test/core/test/env.test.ts | 6 + .../test/environments/custom-env.test.ts} | 2 + .../test/fixtures/snapshots}/basic/input.json | 0 .../test/fixtures/snapshots}/basic/output.css | 0 .../fixtures/snapshots}/multiple/input.json | 0 .../fixtures/snapshots}/multiple/output.css | 0 test/core/test/module.test.ts | 33 + .../test/resolve-ssr.test.ts} | 6 +- .../test/resolve-web.test.ts} | 6 +- .../test/snapshot-async.test.ts} | 0 .../test/snapshot-concurrent-sync.test.ts} | 0 .../test/snapshot-concurrent.test.ts} | 0 .../test/snapshot-file.test.ts} | 4 +- test/core/test/snapshot.test.ts | 27 + .../test/threads-specific.threads.test.ts | 0 .../test/utils-display.spec.ts} | 0 .../basic.test.ts => core/test/wasm.test.ts} | 10 +- .../test/web-worker-jsdom.test.ts} | 6 +- test/core/test/web-worker-node.test.ts | 271 ++++++ test/core/vite.config.ts | 46 +- .../vitest-environment-custom/index.ts | 0 .../vitest-environment-custom/package.json | 0 test/core/vitest.workspace.ts | 18 + test/css/package.json | 13 - test/css/testing.mjs | 28 - test/css/vitest.config.ts | 7 - test/cwd/package.json | 11 - test/edge-runtime/package.json | 14 - test/edge-runtime/vitest.config.ts | 7 - test/empty-test/package.json | 11 - test/empty-test/test/one.test.ts | 3 - test/env-custom-file/package.json | 14 - test/env-custom-file/vitest.config.ts | 12 - test/env-custom/package.json | 15 - test/env-custom/vitest.config.ts | 12 - test/env-glob/package.json | 12 - test/env-glob/vitest.config.ts | 10 - test/env-mixed/package.json | 13 - test/env-mixed/vitest.config.ts | 11 - test/esm/package.json | 16 - test/esm/src/prototype.d.mts | 1 - test/esm/src/prototype.mjs | 1 - test/esm/test/executes.spec.ts | 9 - test/esm/test/prototype.spec.ts | 9 - test/esm/vite.config.ts | 9 - test/failing/package.json | 13 - test/failing/vite.config.ts | 10 - test/fails/package.json | 14 - test/fails/vite.config.ts | 10 - test/filters/package.json | 12 - test/filters/vitest.config.ts | 8 - test/global-setup-fail/package.json | 11 - test/global-setup-fail/vitest.config.ts | 7 - .../setupFiles/add-something-to-global.ts | 2 +- test/global-setup/test/global-setup.test.ts | 2 +- test/global-setup/test/setup-files.test.ts | 2 +- test/global-setup/vitest.config.ts | 1 - test/import-meta/package.json | 13 - test/import-meta/vite.config.ts | 20 - test/inspect/package.json | 13 - test/inspect/vitest.config.ts | 7 - test/mixed-pools/package.json | 12 - test/mixed-pools/vitest.config.ts | 11 - test/network-imports/package.json | 11 - test/network-imports/vitest.config.ts | 24 - test/path-resolution-target/.eslintignore | 1 - test/path-resolution-target/.gitignore | 1 - test/path-resolution-target/README.md | 2 - test/path-resolution-target/dist/index.d.ts | 1 - test/path-resolution-target/dist/index.js | 3 - test/path-resolution-target/package.json | 6 - test/path-resolution/package.json | 15 - .../test/sister-package.test.ts | 17 - test/path-resolution/vitest.config.ts | 7 - test/public-api/package.json | 13 - test/public-api/vitest.config.ts | 10 - test/resolve/package.json | 13 - test/resolve/vitest.config.ts | 15 - test/restricted/package.json | 13 - test/run-once/package.json | 12 - test/run-once/test/run-once.test.ts | 26 - test/run-once/vitest.config.ts | 7 - .../vitest.config.ts | 3 - .../no-exec-args-fixtures/vitest.config.ts | 3 - test/run/package.json | 14 - test/run/vitest.config.ts | 12 - test/setup/package.json | 11 - test/setup/tests/console-setup.test.ts | 19 - test/setup/tests/empty-setup.test.ts | 5 - test/setup/tests/setup-files.test.ts | 33 - test/shard/package.json | 11 - test/shard/vitest.config.ts | 7 - test/single-thread/package.json | 12 - test/single-thread/test/a.test.ts | 11 - test/single-thread/test/b.test.ts | 18 - test/single-thread/test/c.test.ts | 4 - test/single-thread/test/d.test.ts | 8 - test/single-thread/test/timeout.ts | 4 - test/single-thread/vitest.config.ts | 15 - ...ts.test.ts.snap => snapshots.test.ts.snap} | 11 - .../{shapshots.test.ts => snapshots.test.ts} | 46 +- test/snapshots/test/workspace.test.ts | 19 - test/stacktraces/package.json | 12 - test/stacktraces/vite.config.ts | 10 - test/test-utils/index.ts | 7 +- test/utils/package.json | 13 - test/vite-config/package.json | 13 - test/vite-config/src/index.html | 1 - test/vite-config/src/src.ts | 1 - test/vite-config/src/test/root.test.ts | 12 - test/vite-config/vite.config.ts | 17 - test/vite-node/package.json | 2 - test/vm-threads/package.json | 12 - test/wasm-modules/package.json | 11 - test/wasm-modules/vitest.config.ts | 19 - test/watch/test/workspaces.test.ts | 2 +- test/web-worker/package.json | 13 - test/web-worker/setup.ts | 1 - test/web-worker/test/clone.test.ts | 136 --- test/web-worker/test/init.test.ts | 72 -- test/web-worker/test/postMessage.test.ts | 11 - test/web-worker/test/sharedWorker.spec.ts | 53 -- test/web-worker/vitest.config.ts | 19 - test/workspaces-browser/globalTest.ts | 12 + test/workspaces/globalTest.ts | 2 + test/workspaces/vitest.config.ts | 6 - test/workspaces/vitest.config.watch.ts | 16 + test/ws-api/package.json | 12 - test/ws-api/vitest.config.ts | 7 - 424 files changed, 1340 insertions(+), 2749 deletions(-) create mode 100644 test/README.md delete mode 100644 test/bail/package.json delete mode 100644 test/bail/test/bail.test.ts delete mode 100644 test/bail/vitest.config.ts delete mode 100644 test/base/package.json delete mode 100644 test/base/test/mocking-with-base.spec.ts delete mode 100644 test/base/vitest.config.ts delete mode 100644 test/browser/specs/filter.test.mjs create mode 100644 test/browser/specs/filter.test.ts delete mode 100644 test/browser/specs/fix-4686.test.mjs create mode 100644 test/browser/specs/fix-4686.test.ts delete mode 100644 test/browser/specs/run-vitest.mjs delete mode 100644 test/browser/specs/runner.test.mjs create mode 100644 test/browser/specs/runner.test.ts delete mode 100644 test/browser/specs/server-url.test.mjs create mode 100644 test/browser/specs/server-url.test.ts delete mode 100644 test/browser/specs/update-snapshot.test.mjs create mode 100644 test/browser/specs/update-snapshot.test.ts create mode 100644 test/browser/specs/utils.ts create mode 100644 test/browser/vitest.config.unit.mts delete mode 100644 test/changed/package.json delete mode 100644 test/changed/tests/forceRerunTrigger.test.ts delete mode 100644 test/changed/tests/related.test.ts delete mode 100644 test/changed/tests/workspaceRelated.test.ts delete mode 100644 test/changed/vitest.config.js delete mode 100644 test/cjs/package.json delete mode 100644 test/cjs/src/other.cjs delete mode 100644 test/cjs/src/other.d.cts delete mode 100644 test/cjs/src/prototype.d.cts delete mode 100644 test/cjs/test/fs-extra.test.ts delete mode 100644 test/cjs/test/function-default.test.ts delete mode 100644 test/cjs/test/history.test.ts delete mode 100644 test/cjs/test/interpret-default.test.tsx delete mode 100644 test/cjs/test/prototype.test.ts delete mode 100644 test/cjs/tsconfig.json delete mode 100644 test/cjs/vitest.config.ts rename test/{env-custom-file => cli}/custom.ts (100%) rename test/{env-custom-file/test/base.test.ts => cli/fixtures/custom-file-env/custom-file-env.test.ts} (76%) rename test/{run/pool-custom-fixtures => cli/fixtures/custom-pool}/pool/custom-pool.ts (100%) rename test/{run/pool-custom-fixtures => cli/fixtures/custom-pool}/tests/custom-not-run.spec.ts (100%) rename test/{run/pool-custom-fixtures => cli/fixtures/custom-pool}/tests/custom-run.threads.spec.ts (100%) rename test/{run/pool-custom-fixtures => cli/fixtures/custom-pool}/vitest.config.ts (100%) rename test/{cwd => cli/fixtures/dotted-files}/.cache/projects/test/.cache/should-not-run.test.ts (100%) rename test/{cwd => cli/fixtures/dotted-files}/.cache/projects/test/should-run.test.ts (100%) rename test/{failing/fixtures => cli/fixtures/expect-soft}/expects/soft.test.ts (100%) rename test/{failing/fixtures => cli/fixtures/expect-soft}/vite.config.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/.dot-folder/dot-test.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/each-timeout.test.ts (100%) rename test/{empty-test/test => cli/fixtures/fails}/empty.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/expect-soft.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/expect-unreachable.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/expect.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/hook-timeout.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/hooks-called.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/inline-snapshop-inside-each.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/mock-import-proxy-module.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/nested-suite.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/primitive-error.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/proxy-module.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/snapshot-with-not.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/stall.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/test-extend/circular-dependency.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/test-extend/fixture-error.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/test-extend/fixture-rest-params.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/test-extend/fixture-rest-props.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/test-extend/fixture-without-destructuring.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/test-extend/test-rest-params.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/test-extend/test-rest-props.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/test-extend/test-without-destructuring.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/test-timeout.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/unhandled.test.ts (100%) rename test/{fails/fixtures => cli/fixtures/fails}/vite.config.ts (100%) rename test/{changed/fixtures => cli/fixtures/git-changed}/related/deep-related-exports.test.ts (100%) rename test/{changed/fixtures => cli/fixtures/git-changed}/related/deep-related-imports.test.ts (100%) rename test/{changed/fixtures => cli/fixtures/git-changed}/related/not-related.test.ts (100%) rename test/{changed/fixtures => cli/fixtures/git-changed}/related/related.test.ts (100%) rename test/{changed/fixtures => cli/fixtures/git-changed}/related/src/sourceA.ts (100%) rename test/{changed/fixtures => cli/fixtures/git-changed}/related/src/sourceB.ts (100%) rename test/{changed/fixtures => cli/fixtures/git-changed}/related/src/sourceC.ts (100%) rename test/{changed/fixtures => cli/fixtures/git-changed}/related/src/sourceD.ts (100%) rename test/{changed/fixtures => cli/fixtures/git-changed}/related/vitest.config.js (100%) rename test/{changed/fixtures => cli/fixtures/git-changed}/workspace/package.json (100%) rename test/{changed/fixtures => cli/fixtures/git-changed}/workspace/packages/packageA/index.js (100%) rename test/{changed/fixtures => cli/fixtures/git-changed}/workspace/packages/packageA/index.test.js (100%) rename test/{changed/fixtures => cli/fixtures/git-changed}/workspace/packages/packageA/vitest.config.mjs (100%) rename test/{changed/fixtures => cli/fixtures/git-changed}/workspace/packages/packageB/index.js (100%) rename test/{changed/fixtures => cli/fixtures/git-changed}/workspace/packages/packageB/index.test.js (100%) rename test/{changed/fixtures => cli/fixtures/git-changed}/workspace/packages/packageB/vitest.config.mjs (100%) rename test/{changed/fixtures => cli/fixtures/git-changed}/workspace/vitest.config.mjs (100%) rename test/{changed/fixtures => cli/fixtures/git-changed}/workspace/vitest.workspace.js (100%) rename test/{global-setup-fail/fixtures => cli/fixtures/global-setup-fail}/example.test.ts (100%) rename test/{global-setup-fail/fixtures => cli/fixtures/global-setup-fail}/globalSetup/error.js (100%) rename test/{global-setup-fail/fixtures => cli/fixtures/global-setup-fail}/vitest.config.ts (100%) rename test/{inspect/fixtures => cli/fixtures/inspect}/math.test.ts (100%) rename test/{inspect/fixtures => cli/fixtures/inspect}/vitest.config.ts (100%) create mode 100644 test/cli/fixtures/inspect/vitest.config.ts.timestamp-1713887058308-b154731a64b17.mjs rename test/{network-imports/test => cli/fixtures/network-imports}/basic.test.ts (100%) rename test/{ => cli/fixtures}/network-imports/public/slash@3.0.0.js (100%) rename test/{public-api/fixtures => cli/fixtures/public-api}/custom.spec.ts (100%) rename test/{public-api/fixtures => cli/fixtures/public-api}/vitest.config.ts (100%) rename test/{restricted => cli/fixtures/restricted-fs}/src/math.js (100%) rename test/{restricted => cli/fixtures/restricted-fs}/tests/basic.spec.js (100%) rename test/{restricted => cli/fixtures/restricted-fs}/vitest.config.ts (100%) rename test/{restricted => cli/fixtures/restricted-fs}/vitest.setup.js (100%) rename test/{setup/setupFiles => cli/fixtures/setup-files}/console-setup.ts (100%) rename test/{setup/setupFiles => cli/fixtures/setup-files}/empty-setup.ts (100%) rename test/{setup/tests/fixtures/console.test.ts => cli/fixtures/setup-files/empty.test.ts} (100%) rename test/{stacktraces/fixtures => cli/fixtures/stacktraces}/add-in-imba.test.imba (100%) rename test/{stacktraces/fixtures => cli/fixtures/stacktraces}/add-in-js.test.js (100%) rename test/{stacktraces/fixtures => cli/fixtures/stacktraces}/add.test.ts (100%) rename test/{stacktraces/fixtures => cli/fixtures/stacktraces}/error-in-deps.test.js (100%) rename test/{stacktraces/fixtures => cli/fixtures/stacktraces}/error-with-stack.test.js (100%) rename test/{stacktraces/fixtures => cli/fixtures/stacktraces}/foo.js (100%) rename test/{stacktraces/fixtures => cli/fixtures/stacktraces}/frame.spec.imba (100%) rename test/{stacktraces/fixtures => cli/fixtures/stacktraces}/mocked-global.test.js (100%) rename test/{stacktraces/fixtures => cli/fixtures/stacktraces}/mocked-imported.test.js (100%) rename test/{stacktraces/fixtures => cli/fixtures/stacktraces}/mocked-imported.test.ts (100%) rename test/{stacktraces/fixtures => cli/fixtures/stacktraces}/reset-modules.test.ts (100%) rename test/{stacktraces/fixtures => cli/fixtures/stacktraces}/setup.js (100%) rename test/{stacktraces/fixtures => cli/fixtures/stacktraces}/utils.ts (100%) rename test/{stacktraces/fixtures => cli/fixtures/stacktraces}/vite.config.ts (100%) rename test/{run/fixtures => cli/fixtures/tty}/example.test.ts (100%) rename test/{run/fixtures => cli/fixtures/tty}/example.ts (100%) rename test/{run/fixtures => cli/fixtures/tty}/math.test.ts (100%) rename test/{run/fixtures => cli/fixtures/tty}/math.ts (100%) rename test/{run/fixtures => cli/fixtures/tty}/vitest.config.ts (100%) create mode 100644 test/cli/fixtures/vitest.config.js rename test/{vm-threads/test => cli/fixtures/vm-threads}/import-external-css-assets.test.js (80%) rename test/{vm-threads/test => cli/fixtures/vm-threads}/module.test.js (100%) rename test/{vm-threads/test => cli/fixtures/vm-threads}/not-found.test.ts (95%) rename test/{vm-threads/test => cli/fixtures/vm-threads}/require-cjs.test.js (70%) rename test/{ => cli/fixtures}/vm-threads/src/external/assets/file1.png (100%) rename test/{ => cli/fixtures}/vm-threads/src/external/assets/file2.txt (100%) rename test/{ => cli/fixtures}/vm-threads/src/external/assets/file3.svg (100%) rename test/{ => cli/fixtures}/vm-threads/src/external/css/empty.css (100%) rename test/{ => cli/fixtures}/vm-threads/src/external/css/processed.css (100%) rename test/{ => cli/fixtures}/vm-threads/src/external/css/processed.module.css (100%) rename test/{ => cli/fixtures}/vm-threads/src/external/default-cjs.cjs (100%) rename test/{ => cli/fixtures}/vm-threads/src/external/export-default-cjs.js (100%) rename test/{ => cli/fixtures}/vm-threads/src/external/export-nested-default-cjs.js (100%) rename test/{ => cli/fixtures}/vm-threads/src/external/nested-default-cjs.cjs (100%) rename test/{ => cli/fixtures}/vm-threads/src/external/not-found.js (100%) rename test/{ => cli/fixtures}/vm-threads/src/external/package-null/package-null.js (100%) rename test/{ => cli/fixtures}/vm-threads/src/external/package.json (100%) rename test/{ => cli/fixtures}/vm-threads/src/external/primitive-cjs.cjs (100%) rename test/{ => cli/fixtures}/vm-threads/vitest.config.ts (100%) rename test/{ws-api/fixtures/server-url => cli/fixtures/ws-server-url}/basic.test.ts (100%) rename test/{ws-api/fixtures/server-url => cli/fixtures/ws-server-url}/vitest.config.ts (100%) rename test/{fails/test/__snapshots__/runner.test.ts.snap => cli/test/__snapshots__/fails.test.ts.snap} (100%) rename test/{stacktraces/test/__snapshots__/runner.test.ts.snap => cli/test/__snapshots__/stacktraces.test.ts.snap} (100%) rename test/{run => cli}/test/custom-pool.test.ts (83%) create mode 100644 test/cli/test/dotted-files.test.ts rename test/{failing/test/expect.test.ts => cli/test/expect-soft.test.ts} (86%) rename test/{fails/test/runner.test.ts => cli/test/fails.test.ts} (96%) create mode 100644 test/cli/test/git-changed.test.ts rename test/{global-setup-fail/test/runner.test.ts => cli/test/global-setup-fail.test.ts} (85%) rename test/{inspect => cli}/test/inspect.test.ts (93%) create mode 100644 test/cli/test/network-imports.test.ts rename test/{public-api/tests/runner.spec.ts => cli/test/public-api.test.ts} (97%) create mode 100644 test/cli/test/restricted-fs.test.ts create mode 100644 test/cli/test/run-custom-env.test.ts rename test/{ws-api/tests => cli/test}/server-url.test.ts (75%) create mode 100644 test/cli/test/setup-files.test.ts rename test/{stacktraces/test/runner.test.ts => cli/test/stacktraces.test.ts} (86%) rename test/{run => cli}/test/tty.test.ts (85%) create mode 100644 test/cli/test/vm-threads.test.ts rename test/{run => config/fixtures}/allowed-exec-args-fixtures/allowed-exec-argv.test.ts (80%) rename test/{cwd => config/fixtures/allowed-exec-args-fixtures}/vitest.config.ts (100%) rename test/{bail/fixtures => config/fixtures/bail}/test/first.test.ts (100%) rename test/{bail/fixtures => config/fixtures/bail}/test/second.test.ts (100%) rename test/{bail/fixtures => config/fixtures/bail}/vitest.config.ts (100%) rename test/{base => config/fixtures/base-path}/src/index.ts (100%) create mode 100644 test/config/fixtures/base-path/test/mocking-with-base.spec.ts rename test/{css/src => config/fixtures/css}/App.css (100%) rename test/{css/src => config/fixtures/css}/App.module.css (100%) rename test/{ => config/fixtures}/css/test/default-css.spec.ts (70%) rename test/{ => config/fixtures}/css/test/non-scope-module.spec.ts (87%) rename test/{ => config/fixtures}/css/test/process-css.spec.ts (69%) rename test/{ => config/fixtures}/css/test/process-inline.spec.ts (73%) rename test/{ => config/fixtures}/css/test/process-module.spec.ts (71%) rename test/{ => config/fixtures}/css/test/scope-module.spec.ts (93%) rename test/{css/test => config/fixtures/css}/utils.ts (100%) rename test/{cli => config}/fixtures/exclude/math.test.ts (100%) rename test/{cli => config}/fixtures/exclude/math.ts (100%) rename test/{cli => config}/fixtures/exclude/string.test.ts (100%) rename test/{cli => config}/fixtures/exclude/string.ts (100%) rename test/{cli => config}/fixtures/exclude/vitest.exclude.config.ts (100%) rename test/{run => config/fixtures}/exec-args-fixtures/forks.test.ts (100%) rename test/{run => config/fixtures}/exec-args-fixtures/threads.test.ts (100%) rename test/{run => config/fixtures}/exec-args-fixtures/vmThreads.test.ts (100%) rename test/{filters/fixtures-slash => config/fixtures/filters-slash}/test/basic-foo/a.test.ts (100%) rename test/{filters/fixtures-slash => config/fixtures/filters-slash}/test/basic.test.ts (100%) rename test/{filters/fixtures-slash => config/fixtures/filters-slash}/test/basic/a.test.ts (100%) rename test/{filters/fixtures-slash => config/fixtures/filters-slash}/test/foo-basic/a.test.ts (100%) rename test/{empty-test => config/fixtures/filters-slash}/vitest.config.ts (100%) rename test/{filters/fixtures/test/filters.test.ts => config/fixtures/filters/test/config.test.ts} (100%) rename test/{filters/fixtures => config/fixtures/filters}/test/dont-run-this.test.ts (100%) rename test/{filters/fixtures => config/fixtures/filters}/test/example.test.ts (100%) rename test/{env-mixed/fixtures => config/fixtures/mixed-environments}/project/test/happy-dom.test.ts (100%) rename test/{env-mixed/fixtures => config/fixtures/mixed-environments}/project/test/jsdom.test.ts (100%) rename test/{env-mixed/fixtures => config/fixtures/mixed-environments}/project/test/node.test.ts (100%) rename test/{env-mixed/fixtures => config/fixtures/mixed-environments}/project/test/workspace-project.test.ts (100%) rename test/{env-mixed/fixtures => config/fixtures/mixed-environments}/vitest.config.ts (100%) rename test/{env-mixed/fixtures => config/fixtures/mixed-environments}/vitest.workspace.ts (100%) rename test/{run => config/fixtures}/no-exec-args-fixtures/no-exec-argv.test.ts (100%) rename test/{filters/fixtures-slash => config/fixtures/no-exec-args-fixtures}/vitest.config.ts (100%) rename test/{fails/fixtures => config/fixtures/pass-empty-files}/empty.test.ts (100%) rename test/{cli => config}/fixtures/project/packages/project_1/base.test.ts (100%) rename test/{cli => config}/fixtures/project/packages/project_2/base.test.ts (100%) rename test/{cli => config}/fixtures/project/packages/space_1/base.test.ts (100%) rename test/{cli => config}/fixtures/project/vitest.config.ts (100%) rename test/{cli => config}/fixtures/project/vitest.workspace.ts (100%) rename test/{ => config/fixtures}/shard/test/1.test.js (100%) rename test/{ => config/fixtures}/shard/test/2.test.js (100%) rename test/{ => config/fixtures}/shard/test/3.test.js (100%) create mode 100644 test/config/fixtures/shard/vitest.config.js create mode 100644 test/config/fixtures/test/vitest.config.js create mode 100644 test/config/fixtures/vitest.config.js create mode 100644 test/config/test/bail.test.ts create mode 100644 test/config/test/base-path.test.ts create mode 100644 test/config/test/css-configs.test.ts rename test/{cli => config}/test/exclude.test.ts (100%) rename test/{run => config}/test/exec-args.test.ts (85%) rename test/{env-mixed => config}/test/mixed-environments.test.ts (96%) rename test/config/test/{resolution.test.ts => override.test.ts} (100%) create mode 100644 test/config/test/pass-empty-files.test.ts rename test/{cli => config}/test/project.test.ts (100%) rename test/{shard/shard-test.test.ts => config/test/shard.test.ts} (90%) rename test/{filters => config}/test/testname-pattern.test.ts (73%) rename test/{vite-node => core}/deps/dep1/esm/index.js (100%) rename test/{vite-node => core}/deps/dep1/package.json (100%) rename test/{vite-node => core}/deps/dep2/index.js (100%) rename test/{vite-node => core}/deps/dep2/package.json (100%) create mode 100644 test/core/index.html rename test/{cjs/src/default-function.d.cts => core/src/cjs/default-function.d.ts} (100%) rename test/{cjs/src/default-function.cjs => core/src/cjs/default-function.js} (100%) rename test/{cjs/src/prototype.cjs => core/src/cjs/prototype-cjs.js} (100%) rename test/{resolve => core/src/external}/pkg-browser/index.d.ts (100%) rename test/{resolve => core/src/external}/pkg-browser/package.json (100%) rename test/{resolve => core/src/external}/pkg-browser/ssr.js (100%) rename test/{resolve => core/src/external}/pkg-browser/web.js (100%) rename test/{resolve => core/src/external}/pkg-node/index.d.ts (100%) rename test/{resolve => core/src/external}/pkg-node/package.json (100%) rename test/{resolve => core/src/external}/pkg-node/ssr.js (100%) rename test/{resolve => core/src/external}/pkg-node/web.js (100%) rename test/{import-meta/src => core/src/in-source}/add.ts (100%) rename test/{import-meta/src => core/src/in-source}/fibonacci.ts (100%) rename test/{import-meta/src => core/src/in-source}/index.ts (100%) rename test/{wasm-modules/src => core/src/wasm}/add.wasm (100%) rename test/{wasm-modules/src => core/src/wasm}/wasm-bindgen-no-cyclic/README.md (100%) rename test/{wasm-modules/src => core/src/wasm}/wasm-bindgen-no-cyclic/index.d.ts (100%) rename test/{wasm-modules/src => core/src/wasm}/wasm-bindgen-no-cyclic/index.js (100%) rename test/{wasm-modules/src => core/src/wasm}/wasm-bindgen-no-cyclic/index_bg.js (100%) rename test/{wasm-modules/src => core/src/wasm}/wasm-bindgen-no-cyclic/index_bg.wasm (100%) rename test/{wasm-modules/src => core/src/wasm}/wasm-bindgen-no-cyclic/index_bg.wasm.d.ts (100%) rename test/{wasm-modules/src => core/src/wasm}/wasm-bindgen-no-cyclic/package.json (100%) rename test/{wasm-modules/src => core/src/wasm}/wasm-bindgen/README.md (100%) rename test/{wasm-modules/src => core/src/wasm}/wasm-bindgen/index.js (100%) rename test/{wasm-modules/src => core/src/wasm}/wasm-bindgen/index_bg.js (100%) rename test/{wasm-modules/src => core/src/wasm}/wasm-bindgen/index_bg.wasm (100%) rename test/{wasm-modules/src => core/src/wasm}/wasm-bindgen/package.json (100%) rename test/{web-worker/src => core/src/web-worker}/eventListenerWorker.ts (100%) rename test/{web-worker/src => core/src/web-worker}/objectWorker.ts (100%) rename test/{web-worker/src => core/src/web-worker}/selfWorker.ts (100%) rename test/{web-worker/src => core/src/web-worker}/selfWorkerDep.ts (100%) rename test/{web-worker/src => core/src/web-worker}/sharedWorker.ts (100%) rename test/{web-worker/src => core/src/web-worker}/worker.ts (100%) rename test/{snapshots/test/__snapshots__/shapshots-concurrent-sync.test.ts.snap => core/test/__snapshots__/snapshot-concurrent-sync.test.ts.snap} (93%) rename test/{snapshots/test/__snapshots__/shapshots-concurrent.test.ts.snap => core/test/__snapshots__/snapshot-concurrent.test.ts.snap} (100%) rename test/{mixed-pools => core}/test/child-specific.child_process.test.ts (100%) rename test/{vite-node/test/external.test.ts => core/test/dual-package-hazard.test.ts} (100%) rename test/{edge-runtime => core}/test/edge.test.ts (85%) rename test/{env-glob/test/dom/overrides.spec.ts => core/test/env-glob-dom/env-glob.overrides.spec.ts} (100%) rename test/{env-glob/test/dom/base.spec.ts => core/test/env-glob-dom/env-glob.spec.ts} (100%) rename test/{env-glob/test/base.dom.test.ts => core/test/env-glob.dom.test.ts} (100%) rename test/{env-glob/test/base.test.ts => core/test/env-glob.test.ts} (100%) rename test/{env-custom/test/base.test.ts => core/test/environments/custom-env.test.ts} (89%) rename test/{snapshots/test/fixtures => core/test/fixtures/snapshots}/basic/input.json (100%) rename test/{snapshots/test/fixtures => core/test/fixtures/snapshots}/basic/output.css (100%) rename test/{snapshots/test/fixtures => core/test/fixtures/snapshots}/multiple/input.json (100%) rename test/{snapshots/test/fixtures => core/test/fixtures/snapshots}/multiple/output.css (100%) rename test/{resolve/test/ssr.test.ts => core/test/resolve-ssr.test.ts} (66%) rename test/{resolve/test/web.test.ts => core/test/resolve-web.test.ts} (65%) rename test/{snapshots/test/snapshots-async.test.ts => core/test/snapshot-async.test.ts} (100%) rename test/{snapshots/test/shapshots-concurrent-sync.test.ts => core/test/snapshot-concurrent-sync.test.ts} (100%) rename test/{snapshots/test/shapshots-concurrent.test.ts => core/test/snapshot-concurrent.test.ts} (100%) rename test/{snapshots/test/shapshots-file.test.ts => core/test/snapshot-file.test.ts} (79%) rename test/{mixed-pools => core}/test/threads-specific.threads.test.ts (100%) rename test/{utils/test/display.spec.ts => core/test/utils-display.spec.ts} (100%) rename test/{wasm-modules/test/basic.test.ts => core/test/wasm.test.ts} (89%) rename test/{web-worker/test/jsdom.test.ts => core/test/web-worker-jsdom.test.ts} (85%) create mode 100644 test/core/test/web-worker-node.test.ts rename test/{env-custom => core}/vitest-environment-custom/index.ts (100%) rename test/{env-custom => core}/vitest-environment-custom/package.json (100%) create mode 100644 test/core/vitest.workspace.ts delete mode 100644 test/css/package.json delete mode 100644 test/css/testing.mjs delete mode 100644 test/css/vitest.config.ts delete mode 100644 test/cwd/package.json delete mode 100644 test/edge-runtime/package.json delete mode 100644 test/edge-runtime/vitest.config.ts delete mode 100644 test/empty-test/package.json delete mode 100644 test/empty-test/test/one.test.ts delete mode 100644 test/env-custom-file/package.json delete mode 100644 test/env-custom-file/vitest.config.ts delete mode 100644 test/env-custom/package.json delete mode 100644 test/env-custom/vitest.config.ts delete mode 100644 test/env-glob/package.json delete mode 100644 test/env-glob/vitest.config.ts delete mode 100644 test/env-mixed/package.json delete mode 100644 test/env-mixed/vitest.config.ts delete mode 100644 test/esm/package.json delete mode 100644 test/esm/src/prototype.d.mts delete mode 100644 test/esm/src/prototype.mjs delete mode 100644 test/esm/test/executes.spec.ts delete mode 100644 test/esm/test/prototype.spec.ts delete mode 100644 test/esm/vite.config.ts delete mode 100644 test/failing/package.json delete mode 100644 test/failing/vite.config.ts delete mode 100644 test/fails/package.json delete mode 100644 test/fails/vite.config.ts delete mode 100644 test/filters/package.json delete mode 100644 test/filters/vitest.config.ts delete mode 100644 test/global-setup-fail/package.json delete mode 100644 test/global-setup-fail/vitest.config.ts delete mode 100644 test/import-meta/package.json delete mode 100644 test/import-meta/vite.config.ts delete mode 100644 test/inspect/package.json delete mode 100644 test/inspect/vitest.config.ts delete mode 100644 test/mixed-pools/package.json delete mode 100644 test/mixed-pools/vitest.config.ts delete mode 100644 test/network-imports/package.json delete mode 100644 test/network-imports/vitest.config.ts delete mode 100644 test/path-resolution-target/.eslintignore delete mode 100644 test/path-resolution-target/.gitignore delete mode 100644 test/path-resolution-target/README.md delete mode 100644 test/path-resolution-target/dist/index.d.ts delete mode 100644 test/path-resolution-target/dist/index.js delete mode 100644 test/path-resolution-target/package.json delete mode 100644 test/path-resolution/package.json delete mode 100644 test/path-resolution/test/sister-package.test.ts delete mode 100644 test/path-resolution/vitest.config.ts delete mode 100644 test/public-api/package.json delete mode 100644 test/public-api/vitest.config.ts delete mode 100644 test/resolve/package.json delete mode 100644 test/resolve/vitest.config.ts delete mode 100644 test/restricted/package.json delete mode 100644 test/run-once/package.json delete mode 100644 test/run-once/test/run-once.test.ts delete mode 100644 test/run-once/vitest.config.ts delete mode 100644 test/run/allowed-exec-args-fixtures/vitest.config.ts delete mode 100644 test/run/no-exec-args-fixtures/vitest.config.ts delete mode 100644 test/run/package.json delete mode 100644 test/run/vitest.config.ts delete mode 100644 test/setup/package.json delete mode 100644 test/setup/tests/console-setup.test.ts delete mode 100644 test/setup/tests/empty-setup.test.ts delete mode 100644 test/setup/tests/setup-files.test.ts delete mode 100644 test/shard/package.json delete mode 100644 test/shard/vitest.config.ts delete mode 100644 test/single-thread/package.json delete mode 100644 test/single-thread/test/a.test.ts delete mode 100644 test/single-thread/test/b.test.ts delete mode 100644 test/single-thread/test/c.test.ts delete mode 100644 test/single-thread/test/d.test.ts delete mode 100644 test/single-thread/test/timeout.ts delete mode 100644 test/single-thread/vitest.config.ts rename test/snapshots/test/__snapshots__/{shapshots.test.ts.snap => snapshots.test.ts.snap} (94%) rename test/snapshots/test/{shapshots.test.ts => snapshots.test.ts} (57%) delete mode 100644 test/snapshots/test/workspace.test.ts delete mode 100644 test/stacktraces/package.json delete mode 100644 test/stacktraces/vite.config.ts delete mode 100644 test/utils/package.json delete mode 100644 test/vite-config/package.json delete mode 100644 test/vite-config/src/index.html delete mode 100644 test/vite-config/src/src.ts delete mode 100644 test/vite-config/src/test/root.test.ts delete mode 100644 test/vite-config/vite.config.ts delete mode 100644 test/vm-threads/package.json delete mode 100644 test/wasm-modules/package.json delete mode 100644 test/wasm-modules/vitest.config.ts delete mode 100644 test/web-worker/package.json delete mode 100644 test/web-worker/setup.ts delete mode 100644 test/web-worker/test/clone.test.ts delete mode 100644 test/web-worker/test/init.test.ts delete mode 100644 test/web-worker/test/postMessage.test.ts delete mode 100644 test/web-worker/test/sharedWorker.spec.ts delete mode 100644 test/web-worker/vitest.config.ts create mode 100644 test/workspaces/vitest.config.watch.ts delete mode 100644 test/ws-api/package.json delete mode 100644 test/ws-api/vitest.config.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d020f7cdc12d..0e9991d767fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,22 +32,6 @@ jobs: - name: Lint run: pnpm run lint - typecheck: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: ./.github/actions/setup-and-cache - - - name: Install - run: pnpm i - - - name: Build - run: pnpm run build - - - name: Typecheck - run: pnpm run typecheck - test: runs-on: ${{ matrix.os }} @@ -85,11 +69,8 @@ jobs: - name: Test run: pnpm run test:ci - - name: Test No Threads - run: pnpm run test:ci:no-threads - - - name: Test Vm Threads - run: pnpm run test:ci:vm-threads + - name: Test Examples + run: pnpm run test:examples test-ui: runs-on: ubuntu-latest @@ -147,8 +128,6 @@ jobs: timeout-minutes: 30 - env: - BROWSER: ${{ matrix.browser[0] }} steps: - uses: actions/checkout@v4 @@ -170,6 +149,8 @@ jobs: - name: Test Browser (webdriverio) run: pnpm run test:browser:webdriverio + env: + BROWSER: ${{ matrix.browser[0] }} - name: Test Browser (playwright) run: pnpm run test:browser:playwright @@ -185,8 +166,6 @@ jobs: timeout-minutes: 30 - env: - BROWSER: ${{ matrix.browser[0] }} steps: - uses: actions/checkout@v4 @@ -208,6 +187,8 @@ jobs: - name: Test Browser (webdriverio) run: pnpm run test:browser:webdriverio + env: + BROWSER: ${{ matrix.browser[0] }} - name: Test Browser (playwright) run: pnpm run test:browser:playwright diff --git a/.gitignore b/.gitignore index 67e90a1a3058..c5001571541c 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,4 @@ docs/public/user-avatars docs/public/sponsors .eslintcache docs/.vitepress/cache/ -!test/cwd/**/.cache +!test/cli/fixtures/dotted-files/**/.cache diff --git a/eslint.config.js b/eslint.config.js index 394db5c50f86..115449dcbc65 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -14,7 +14,7 @@ export default antfu( '**/*.timestamp-*', 'test/core/src/self', 'test/cache/cache/.vitest-base/results.json', - 'test/wasm-modules/src/wasm-bindgen-no-cyclic', + 'test/core/src/wasm/wasm-bindgen-no-cyclic', 'test/workspaces/results.json', 'test/workspaces-browser/results.json', 'test/reporters/fixtures/with-syntax-error.test.js', @@ -100,7 +100,7 @@ export default antfu( files: [ `docs/${GLOB_SRC}`, `packages/web-worker/${GLOB_SRC}`, - `test/web-worker/${GLOB_SRC}`, + `test/core/${GLOB_SRC}`, ], rules: { 'no-restricted-globals': 'off', diff --git a/package.json b/package.json index a3c95c6158b6..e42a64bf9ec4 100644 --- a/package.json +++ b/package.json @@ -24,12 +24,9 @@ "lint:fix": "nr lint --fix", "publish-ci": "tsx scripts/publish-ci.ts", "release": "bumpp package.json packages/*/package.json --commit --push --tag && git update-ref refs/heads/release refs/heads/main && git push origin release", - "test": "vitest --api -r test/core", - "test:run": "vitest run -r test/core", - "test:all": "CI=true pnpm -r --stream run test --allowOnly", - "test:ci": "CI=true pnpm -r --reporter-hide-prefix --stream --filter !test-browser --filter !test-esm --filter !test-browser run test --allowOnly", - "test:ci:vm-threads": "CI=true pnpm -r --reporter-hide-prefix --stream --filter !test-coverage --filter !test-single-thread --filter !test-browser --filter !test-esm --filter !test-network-imports --filter !test-browser --filter !example-react-testing-lib-msw run test --allowOnly --pool vmThreads", - "test:ci:no-threads": "CI=true pnpm -r --reporter-hide-prefix --stream --filter !test-vm-threads --filter !test-coverage --filter !test-watch --filter !test-bail --filter !test-esm --filter !test-browser run test --allowOnly --pool forks", + "test": "pnpm --filter test-core test:threads", + "test:ci": "CI=true pnpm -r --reporter-hide-prefix --stream --filter '@vitest/test-*' --filter !test-browser run test", + "test:examples": "CI=true pnpm -r --reporter-hide-prefix --stream --filter '@vitest/example-*' run test", "typecheck": "tsc -p tsconfig.check.json --noEmit", "typecheck:why": "tsc -p tsconfig.check.json --noEmit --explainFiles > explainTypes.txt", "ui:build": "vite build packages/ui", diff --git a/packages/vitest/src/node/pool.ts b/packages/vitest/src/node/pool.ts index 89d4b0764d94..8be517b80fe0 100644 --- a/packages/vitest/src/node/pool.ts +++ b/packages/vitest/src/node/pool.ts @@ -1,6 +1,7 @@ import mm from 'micromatch' import type { Awaitable } from '@vitest/utils' import type { BuiltinPool, Pool } from '../types/pool-options' +import { isWindows } from '../utils/env' import type { Vitest } from './core' import { createForksPool } from './pools/forks' import { createThreadsPool } from './pools/threads' @@ -91,6 +92,12 @@ export function createPool(ctx: Vitest): ProcessPool { }, } + // env are case-insensitive on Windows, but spawned processes don't support it + if (isWindows) { + for (const name in options.env) + options.env[name.toUpperCase()] = options.env[name] + } + const customPools = new Map() async function resolveCustomPool(filepath: string) { if (customPools.has(filepath)) diff --git a/packages/vitest/src/suite.ts b/packages/vitest/src/suite.ts index 14a1b4e279f4..3d7ca1fec5e7 100644 --- a/packages/vitest/src/suite.ts +++ b/packages/vitest/src/suite.ts @@ -1,3 +1,3 @@ -export { getCurrentSuite, createTaskCollector, getFn, setFn, getHooks, setHooks } from '@vitest/runner' +export { getCurrentSuite, getCurrentTest, createTaskCollector, getFn, setFn, getHooks, setHooks } from '@vitest/runner' export { createChainable } from '@vitest/runner/utils' export { getBenchFn, getBenchOptions } from './runtime/benchmark' diff --git a/packages/vitest/src/utils/env.ts b/packages/vitest/src/utils/env.ts index 58a747258f64..891d989af6dc 100644 --- a/packages/vitest/src/utils/env.ts +++ b/packages/vitest/src/utils/env.ts @@ -1,3 +1,4 @@ export const isNode: boolean = typeof process < 'u' && typeof process.stdout < 'u' && !process.versions?.deno && !globalThis.window +export const isWindows = isNode && process.platform === 'win32' export const isBrowser: boolean = typeof window !== 'undefined' export { isCI, provider as stdProvider } from 'std-env' diff --git a/packages/vitest/src/utils/index.ts b/packages/vitest/src/utils/index.ts index 229d489adf57..8edb50dc57ee 100644 --- a/packages/vitest/src/utils/index.ts +++ b/packages/vitest/src/utils/index.ts @@ -1,6 +1,5 @@ import { relative } from 'pathe' import { getWorkerState } from '../utils' -import { isNode } from './env' export * from './graph' export * from './tasks' @@ -10,8 +9,8 @@ export * from './timers' export * from './env' export * from './modules' export * from './serialization' +export { isWindows } from './env' -export const isWindows = isNode && process.platform === 'win32' export function getRunMode() { return getWorkerState().config.mode } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9b625bcd5b4e..0925345a1f7c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1520,27 +1520,6 @@ importers: specifier: workspace:* version: link:../runner - test/bail: - devDependencies: - '@vitest/browser': - specifier: workspace:* - version: link:../../packages/browser - vite: - specifier: ^5.2.6 - version: 5.2.6(@types/node@20.11.5)(less@4.1.3) - vitest: - specifier: workspace:* - version: link:../../packages/vitest - webdriverio: - specifier: latest - version: 8.6.3(typescript@5.2.2) - - test/base: - devDependencies: - vitest: - specifier: workspace:* - version: link:../../packages/vitest - test/benchmark: devDependencies: vitest: @@ -1574,59 +1553,35 @@ importers: specifier: ^8.32.2 version: 8.32.2(typescript@5.2.2) - test/cache: - devDependencies: - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/changed: - devDependencies: - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/cjs: - devDependencies: - '@types/fs-extra': - specifier: ^9.0.13 - version: 9.0.13 - '@types/lodash': - specifier: ^4.14.201 - version: 4.14.201 - '@types/prettier': - specifier: ^2.6.1 - version: 2.7.0 - fs-extra: - specifier: ^10.1.0 - version: 10.1.0 - givens: - specifier: 1.3.9 - version: 1.3.9 - history: - specifier: ^5.3.0 - version: 5.3.0 - lodash: - specifier: ^4.17.21 - version: 4.17.21 - prettier: - specifier: ^2.6.2 - version: 2.7.1 - temp-dir: - specifier: ^2.0.0 - version: 2.0.0 - vitest: - specifier: workspace:* - version: link:../../packages/vitest - test/cli: devDependencies: + '@types/debug': + specifier: ^4.1.12 + version: 4.1.12 + '@types/ws': + specifier: ^8.5.9 + version: 8.5.9 + '@vitejs/plugin-basic-ssl': + specifier: ^1.0.2 + version: 1.0.2(vite@5.2.6) + '@vitest/runner': + specifier: workspace:^ + version: link:../../packages/runner + debug: + specifier: ^4.3.4 + version: 4.3.4(supports-color@8.1.1) + execa: + specifier: ^8.0.1 + version: 8.0.1 vite: specifier: ^5.2.6 version: 5.2.6(@types/node@20.11.5)(less@4.1.3) vitest: specifier: workspace:* version: link:../../packages/vitest + ws: + specifier: ^8.14.2 + version: 8.16.0 test/config: devDependencies: @@ -1648,15 +1603,30 @@ importers: test/core: devDependencies: + '@types/debug': + specifier: ^4.1.12 + version: 4.1.12 '@vitest/expect': specifier: workspace:* version: link:../../packages/expect '@vitest/runner': specifier: workspace:* version: link:../../packages/runner + '@vitest/test-dep1': + specifier: file:./deps/dep1 + version: file:test/core/deps/dep1 + '@vitest/test-dep2': + specifier: file:./deps/dep2 + version: file:test/core/deps/dep2 '@vitest/utils': specifier: workspace:* version: link:../../packages/utils + '@vitest/web-worker': + specifier: workspace:^ + version: link:../../packages/web-worker + debug: + specifier: ^4.3.4 + version: 4.3.4(supports-color@8.1.1) strip-ansi: specifier: ^7.1.0 version: 7.1.0 @@ -1669,6 +1639,9 @@ importers: vitest: specifier: workspace:* version: link:../../packages/vitest + vitest-environment-custom: + specifier: file:./vitest-environment-custom + version: file:test/core/vitest-environment-custom test/coverage-test: devDependencies: @@ -1724,169 +1697,12 @@ importers: specifier: latest version: 8.6.3(typescript@5.2.2) - test/css: - devDependencies: - jsdom: - specifier: ^20.0.0 - version: 20.0.0 - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/cwd: - devDependencies: - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/edge-runtime: - devDependencies: - '@edge-runtime/vm': - specifier: 1.1.0-beta.26 - version: 1.1.0-beta.26 - '@vitest/web-worker': - specifier: workspace:* - version: link:../../packages/web-worker - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/empty-test: - devDependencies: - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/env-custom: - devDependencies: - '@types/debug': - specifier: ^4.1.12 - version: 4.1.12 - debug: - specifier: ^4.3.4 - version: 4.3.4(supports-color@8.1.1) - vitest: - specifier: workspace:* - version: link:../../packages/vitest - vitest-environment-custom: - specifier: file:./vitest-environment-custom - version: file:test/env-custom/vitest-environment-custom - - test/env-custom-file: - devDependencies: - '@types/debug': - specifier: ^4.1.12 - version: 4.1.12 - debug: - specifier: ^4.3.4 - version: 4.3.4(supports-color@8.1.1) - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/env-glob: - devDependencies: - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/env-mixed: - devDependencies: - happy-dom: - specifier: latest - version: 8.9.0 - vite: - specifier: ^5.2.6 - version: 5.2.6(@types/node@20.11.5)(less@4.1.3) - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/esm: - dependencies: - css-what: - specifier: 6.1.0 - version: 6.1.0 - tslib: - specifier: 2.4.0 - version: 2.4.0 - devDependencies: - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/failing: - devDependencies: - '@vitest/runner': - specifier: workspace:* - version: link:../../packages/runner - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/fails: - devDependencies: - '@vitest/coverage-istanbul': - specifier: workspace:* - version: link:../../packages/coverage-istanbul - jsdom: - specifier: ^21.0.0 - version: 21.0.0 - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/filters: - devDependencies: - vite: - specifier: ^5.2.6 - version: 5.2.6(@types/node@20.11.5)(less@4.1.3) - vitest: - specifier: workspace:* - version: link:../../packages/vitest - test/global-setup: devDependencies: vitest: specifier: workspace:* version: link:../../packages/vitest - test/global-setup-fail: - devDependencies: - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/import-meta: - devDependencies: - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/inspect: - devDependencies: - vite: - specifier: ^5.2.6 - version: 5.2.6(@types/node@20.11.5)(less@4.1.3) - vitest: - specifier: workspace:* - version: link:../../packages/vitest - ws: - specifier: ^8.14.2 - version: 8.14.2 - - test/mixed-pools: - devDependencies: - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/network-imports: - devDependencies: - vitest: - specifier: workspace:* - version: link:../../packages/vitest - test/optimize-deps: devDependencies: '@vitest/test-dep-url': @@ -1896,32 +1712,6 @@ importers: specifier: workspace:* version: link:../../packages/vitest - test/path-resolution: - devDependencies: - '@edge-runtime/vm': - specifier: 1.1.0-beta.26 - version: 1.1.0-beta.26 - '@vitest/test-path-resolution-target': - specifier: workspace:* - version: link:../path-resolution-target - '@vitest/web-worker': - specifier: workspace:* - version: link:../../packages/web-worker - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/path-resolution-target: {} - - test/public-api: - devDependencies: - '@vitest/browser': - specifier: workspace:* - version: link:../../packages/browser - vitest: - specifier: workspace:* - version: link:../../packages/vitest - test/reporters: devDependencies: flatted: @@ -1940,75 +1730,12 @@ importers: specifier: 0.4.1 version: 0.4.1(vitest@packages+vitest) - test/resolve: - devDependencies: - happy-dom: - specifier: ^12.10.3 - version: 12.10.3 - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/restricted: - devDependencies: - jsdom: - specifier: ^22.1.0 - version: 22.1.0 - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/run: - devDependencies: - '@vitest/runner': - specifier: workspace:* - version: link:../../packages/runner - execa: - specifier: ^7.1.1 - version: 7.1.1 - vite: - specifier: ^5.2.6 - version: 5.2.6(@types/node@20.11.5)(less@4.1.3) - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/run-once: - devDependencies: - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/setup: - devDependencies: - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/shard: - devDependencies: - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/single-thread: - devDependencies: - vitest: - specifier: workspace:* - version: link:../../packages/vitest - test/snapshots: dependencies: vitest: specifier: workspace:* version: link:../../packages/vitest - test/stacktraces: - devDependencies: - vitest: - specifier: workspace:* - version: link:../../packages/vitest - test/test-utils: devDependencies: execa: @@ -2055,35 +1782,11 @@ importers: specifier: workspace:* version: link:../../packages/vitest - test/utils: - devDependencies: - '@vitest/utils': - specifier: workspace:* - version: link:../../packages/utils - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/vite-config: - devDependencies: - pathe: - specifier: ^1.1.0 - version: 1.1.0 - vitest: - specifier: workspace:* - version: link:../../packages/vitest - test/vite-node: devDependencies: '@types/inquirer': specifier: ^9.0.3 version: 9.0.3 - '@vitest/test-dep1': - specifier: file:./deps/dep1 - version: file:test/vite-node/deps/dep1 - '@vitest/test-dep2': - specifier: file:./deps/dep2 - version: file:test/vite-node/deps/dep2 execa: specifier: ^6.1.0 version: 6.1.0 @@ -2097,21 +1800,6 @@ importers: specifier: workspace:* version: link:../../packages/vitest - test/vm-threads: - devDependencies: - jsdom: - specifier: latest - version: 24.0.0 - vitest: - specifier: workspace:* - version: link:../../packages/vitest - - test/wasm-modules: - devDependencies: - vitest: - specifier: workspace:* - version: link:../../packages/vitest - test/watch: devDependencies: '@vitest/browser': @@ -2123,18 +1811,9 @@ importers: vitest: specifier: workspace:* version: link:../../packages/vitest - webdriverio: - specifier: latest - version: 8.6.3(typescript@5.2.2) - - test/web-worker: - devDependencies: - '@vitest/web-worker': - specifier: workspace:* - version: link:../../packages/web-worker - vitest: - specifier: workspace:* - version: link:../../packages/vitest + webdriverio: + specifier: latest + version: 8.6.3(typescript@5.2.2) test/workspaces: devDependencies: @@ -2163,15 +1842,6 @@ importers: specifier: workspace:* version: link:../../packages/vitest - test/ws-api: - devDependencies: - '@vitejs/plugin-basic-ssl': - specifier: ^1.0.2 - version: 1.0.2(vite@5.2.6) - vitest: - specifier: workspace:* - version: link:../../packages/vitest - packages: /@aashutoshrathi/word-wrap@1.2.6: @@ -5880,6 +5550,7 @@ packages: engines: {node: '>=6.9.0'} dependencies: regenerator-runtime: 0.14.0 + dev: true /@babel/runtime@7.24.4: resolution: {integrity: sha512-dkxf7+hn8mFBwKjs9bvBlArzLVxVbS8usaPUDd5p2a9JCL9tB8OaOVN1isD4+Xyk4ns89/xeOmbQvgdK7IIVdA==} @@ -6162,21 +5833,11 @@ packages: - '@algolia/client-search' dev: true - /@edge-runtime/primitives@1.1.0-beta.31: - resolution: {integrity: sha512-OO1x32aJoxgME1k77RVxVNsazs5NY/SNwYEN8ptlZ6DKUXn0eesXftDsmlypX/OU0ZeJc61/xNVUuoeyDGJDVA==} - dev: true - /@edge-runtime/primitives@4.0.6: resolution: {integrity: sha512-Ahv7SdVJiFryuauSmubY4bVYvVWsf2h/n67TRRT5ERs6eK90xyeCB3hmn1ExTqaZtxO0Q9QTbEUXVxz6o4iSzw==} engines: {node: '>=16'} dev: true - /@edge-runtime/vm@1.1.0-beta.26: - resolution: {integrity: sha512-hxWtmuO13zgNkM3zHvRENfMeavM+PAKSoHhvzt+sHjSothxGlA06XXN38t/NT6LD4ND8p8FmPJ70+fTptL4a/A==} - dependencies: - '@edge-runtime/primitives': 1.1.0-beta.31 - dev: true - /@edge-runtime/vm@3.1.8: resolution: {integrity: sha512-BticbgpQAh8zRXUrpkbwxhEy9eAMp0L0+thAcS+xLD+uhWpTqsyqovdvV6e4FeeRo5sBg+lnMpoSG8bulFHKTQ==} engines: {node: '>=16'} @@ -6192,7 +5853,7 @@ packages: '@babel/core': 7.24.4 '@babel/helper-module-imports': 7.22.5 '@babel/plugin-syntax-jsx': 7.18.6(@babel/core@7.24.4) - '@babel/runtime': 7.23.2 + '@babel/runtime': 7.24.4 '@emotion/hash': 0.9.0 '@emotion/memoize': 0.8.0 '@emotion/serialize': 1.1.0 @@ -7770,7 +7431,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.23.2 + '@babel/runtime': 7.24.4 '@emotion/is-prop-valid': 1.2.0 '@mui/types': 7.2.0(@types/react@18.2.37) '@mui/utils': 5.10.3(react@18.2.0) @@ -7917,7 +7578,7 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.23.2 + '@babel/runtime': 7.24.4 '@emotion/react': 11.10.4(@babel/core@7.24.4)(@types/react@18.2.37)(react@18.2.0) '@emotion/styled': 11.10.4(@babel/core@7.24.4)(@emotion/react@11.10.4)(@types/react@18.2.37)(react@18.2.0) '@mui/private-theming': 5.10.3(@types/react@18.2.37)(react@18.2.0) @@ -7989,7 +7650,7 @@ packages: peerDependencies: react: ^17.0.0 || ^18.0.0 dependencies: - '@babel/runtime': 7.23.2 + '@babel/runtime': 7.24.4 '@types/prop-types': 15.7.9 '@types/react-is': 17.0.3 prop-types: 15.8.1 @@ -10613,7 +10274,7 @@ packages: engines: {node: '>=12'} dependencies: '@babel/code-frame': 7.22.13 - '@babel/runtime': 7.23.2 + '@babel/runtime': 7.24.4 '@types/aria-query': 4.2.2 aria-query: 5.3.0 chalk: 4.1.2 @@ -10776,7 +10437,7 @@ packages: peerDependencies: '@testing-library/dom': '>=7.21.4' dependencies: - '@babel/runtime': 7.23.2 + '@babel/runtime': 7.24.4 '@testing-library/dom': 8.19.0 dev: true @@ -10803,11 +10464,6 @@ packages: engines: {node: '>= 6'} dev: true - /@tootallnate/once@2.0.0: - resolution: {integrity: sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==} - engines: {node: '>= 10'} - dev: true - /@tootallnate/quickjs-emscripten@0.23.0: resolution: {integrity: sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==} dev: true @@ -10989,12 +10645,6 @@ packages: '@types/node': 20.12.7 dev: true - /@types/fs-extra@9.0.13: - resolution: {integrity: sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==} - dependencies: - '@types/node': 20.12.7 - dev: true - /@types/glob@7.2.0: resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==} dependencies: @@ -11240,10 +10890,6 @@ packages: resolution: {integrity: sha512-kUNnecmtkunAoQ3CnjmMkzNU/gtxG8guhi+Fk2U/kOpIKjIMKnXGp4IJCgQJrXSgMsWYimYG4TGjz/UzbGEBTw==} dev: true - /@types/prettier@2.7.0: - resolution: {integrity: sha512-RI1L7N4JnW5gQw2spvL7Sllfuf1SaHdrZpCHiBlCXjIlufi1SMNnbu2teze3/QE67Fg2tBlH7W+mi4hVNk4p0A==} - dev: true - /@types/prettier@2.7.3: resolution: {integrity: sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==} dev: true @@ -13140,6 +12786,7 @@ packages: /abab@2.0.6: resolution: {integrity: sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==} + deprecated: Use your platform's native atob() and btoa() methods instead dev: true /abbrev@1.1.1: @@ -13172,13 +12819,6 @@ packages: acorn-walk: 7.2.0 dev: true - /acorn-globals@7.0.1: - resolution: {integrity: sha512-umOSDSDrfHbTNPuNpC2NSnnA3LUrqpevPb4T9jRx4MagXNS0rs+gwiTcAvqCRmsD6utzsrzNt+ebm00SNWiC3Q==} - dependencies: - acorn: 8.11.3 - acorn-walk: 8.3.2 - dev: true - /acorn-import-assertions@1.8.0(acorn@8.11.3): resolution: {integrity: sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==} peerDependencies: @@ -13219,6 +12859,7 @@ packages: /acorn-walk@8.3.2: resolution: {integrity: sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==} engines: {node: '>=0.4.0'} + dev: false /acorn@6.4.2: resolution: {integrity: sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ==} @@ -13249,12 +12890,6 @@ packages: hasBin: true dev: true - /acorn@8.9.0: - resolution: {integrity: sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==} - engines: {node: '>=0.4.0'} - hasBin: true - dev: true - /address@1.2.0: resolution: {integrity: sha512-tNEZYz5G/zYunxFm7sfhAxkXEuLj3K6BKwv6ZURlsF6yiUQ65z0Q2wZW9L5cPUl9ocofGvXOdFYbFHp0+6MOig==} engines: {node: '>= 10.0.0'} @@ -14380,7 +14015,7 @@ packages: /broadcast-channel@3.7.0: resolution: {integrity: sha512-cIAKJXAxGJceNZGTZSBzMxzyOn72cVgPnKx4dc6LRjQgbaJUQqhy5rzL3zbMxkMWsGKkv2hSFkPRMEXfoMZ2Mg==} dependencies: - '@babel/runtime': 7.23.2 + '@babel/runtime': 7.24.4 detect-node: 2.1.0 js-sha3: 0.8.0 microseconds: 0.2.0 @@ -15724,6 +15359,7 @@ packages: /css-what@6.1.0: resolution: {integrity: sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==} engines: {node: '>= 6'} + dev: true /css.escape@1.5.1: resolution: {integrity: sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==} @@ -15743,10 +15379,6 @@ packages: resolution: {integrity: sha512-p3pvU7r1MyyqbTk+WbNJIgJjG2VmTIaB10rI93LzVPrmDJKkzKYMtxxyAvQXR/NS6otuzveI7+7BBq3SjBS2mw==} dev: true - /cssom@0.5.0: - resolution: {integrity: sha512-iKuQcq+NdHqlAcwUY0o/HL69XQrUaQdMjmStJ8JFmUaiiQErlhrmuigkg/CU4E2J0IyUKUrMAgl36TvN67MqTw==} - dev: true - /cssstyle@2.3.0: resolution: {integrity: sha512-AZL67abkUzIuvcHqk7c09cezpGNcxUxU4Ioi/05xHk4DQeTkWmGYftIE6ctU6AEt+Gn4n1lDStOtj7FKycP71A==} engines: {node: '>=8'} @@ -15754,13 +15386,6 @@ packages: cssom: 0.3.8 dev: true - /cssstyle@3.0.0: - resolution: {integrity: sha512-N4u2ABATi3Qplzf0hWbVCdjenim8F3ojEXpBDF5hBpjzW182MjNGLqfmQ0SkSPeQ+V86ZXgeH8aXj6kayd4jgg==} - engines: {node: '>=14'} - dependencies: - rrweb-cssom: 0.6.0 - dev: true - /cssstyle@4.0.1: resolution: {integrity: sha512-8ZYiJ3A/3OkDd093CBT/0UKDWry7ak4BdPTFP2+QEP7cmhouyq/Up709ASSj2cK02BbZiMgk7kYjZNS4QP5qrQ==} engines: {node: '>=18'} @@ -16004,24 +15629,6 @@ packages: whatwg-url: 8.7.0 dev: true - /data-urls@3.0.2: - resolution: {integrity: sha512-Jy/tj3ldjZJo63sVAvg6LHt2mHvl4V6AgRAmNDtLdm7faqtsx+aJG42rsyCo9JCoRVKwPFzKlIPx3DIibwSIaQ==} - engines: {node: '>=12'} - dependencies: - abab: 2.0.6 - whatwg-mimetype: 3.0.0 - whatwg-url: 11.0.0 - dev: true - - /data-urls@4.0.0: - resolution: {integrity: sha512-/mMTei/JXPqvFqQtfyTowxmJVwr2PVAeCcDxyFf6LhoOu/09TX2OX3kb2wzi4DMXcfj4OItwDOnhl5oziPnT6g==} - engines: {node: '>=14'} - dependencies: - abab: 2.0.6 - whatwg-mimetype: 3.0.0 - whatwg-url: 12.0.1 - dev: true - /data-urls@5.0.0: resolution: {integrity: sha512-ZYP5VBHshaDAiVZxjbRVcFJpc+4xGgT0bK3vzy1HLN8jTO975HEbuYzZJcHoQEY5K1a0z8YayJkyVETa08eNTg==} engines: {node: '>=18'} @@ -16092,10 +15699,6 @@ packages: resolution: {integrity: sha512-qIMFpTMZmny+MMIitAB6D7iVPEorVw6YQRWkvarTkT4tBeSLLiHzcwj6q0MmYSFCiVpiqPJTJEYIrpcPzVEIvg==} dev: false - /decimal.js@10.4.0: - resolution: {integrity: sha512-Nv6ENEzyPQ6AItkGwLE2PGKinZZ9g59vSh2BeH6NqPu0OTKZ5ruJsVqh/orbAnqXc9pBbgXAIrc2EyaCj8NpGg==} - dev: true - /decimal.js@10.4.3: resolution: {integrity: sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==} dev: true @@ -16526,13 +16129,6 @@ packages: webidl-conversions: 5.0.0 dev: true - /domexception@4.0.0: - resolution: {integrity: sha512-A2is4PLG+eeSfoTMA95/s4pvAoSo2mKtiM5jlHkAVewmiO8ISFTFKZjH7UAM1Atli/OT/7JHOrJRJiMKUZKYBw==} - engines: {node: '>=12'} - dependencies: - webidl-conversions: 7.0.0 - dev: true - /domhandler@3.3.0: resolution: {integrity: sha512-J1C5rIANUbuYK+FuFL98650rihynUOEzRLxW+90bKZRWB6A1X1Tf82GxR1qAWLyfNPRvjqfip3Q5tdYlmAa9lA==} engines: {node: '>= 4'} @@ -18749,7 +18345,7 @@ packages: resolution: {integrity: sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==} engines: {node: '>=12'} dependencies: - graceful-fs: 4.2.10 + graceful-fs: 4.2.11 jsonfile: 6.1.0 universalify: 2.0.0 dev: true @@ -19063,10 +18659,6 @@ packages: resolution: {integrity: sha512-w0dzqw/nt51xMVmlaV1+JRzN+oCa1KfcgGEWhxUG16wbdA+Xnt/yoFO8Z8x/V82ZcZ0wy6ln9QDup5avbhiDhQ==} dev: true - /givens@1.3.9: - resolution: {integrity: sha512-4hYlStsEIaYeYvZTZwgD5yOS2WVP0dcDsOBqeImdEM8eLuclvv0IEMlQQ1kuA5DN4he7wVH1jsYtNe9uininxg==} - dev: true - /glob-parent@3.1.0: resolution: {integrity: sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==} dependencies: @@ -19318,10 +18910,6 @@ packages: responselike: 3.0.0 dev: true - /graceful-fs@4.2.10: - resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==} - dev: true - /graceful-fs@4.2.11: resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} @@ -19409,17 +18997,6 @@ packages: uglify-js: 3.17.4 dev: true - /happy-dom@12.10.3: - resolution: {integrity: sha512-JzUXOh0wdNGY54oKng5hliuBkq/+aT1V3YpTM+lrN/GoLQTANZsMaIvmHiHe612rauHvPJnDZkZ+5GZR++1Abg==} - dependencies: - css.escape: 1.5.1 - entities: 4.5.0 - iconv-lite: 0.6.3 - webidl-conversions: 7.0.0 - whatwg-encoding: 2.0.0 - whatwg-mimetype: 3.0.0 - dev: true - /happy-dom@14.3.10: resolution: {integrity: sha512-Rh5li9vA9MF9Gkg85CbFABKTa3uoSAByILRNGb92u/vswDd561gBg2p1UW1ZauvDWWwRxPcbACK5zv3BR+gHnQ==} engines: {node: '>=16.0.0'} @@ -19632,6 +19209,7 @@ packages: resolution: {integrity: sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==} dependencies: '@babel/runtime': 7.18.9 + dev: false /hmac-drbg@1.0.1: resolution: {integrity: sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==} @@ -19678,13 +19256,6 @@ packages: whatwg-encoding: 1.0.5 dev: true - /html-encoding-sniffer@3.0.0: - resolution: {integrity: sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==} - engines: {node: '>=12'} - dependencies: - whatwg-encoding: 2.0.0 - dev: true - /html-encoding-sniffer@4.0.0: resolution: {integrity: sha512-Y22oTqIU4uuPgEemfz7NDJz6OeKf12Lsu+QC+s3BVpda64lTiMYCyGwg5ki4vFxkMwQdeZDl2adZoqUgdFuTgQ==} engines: {node: '>=18'} @@ -19806,17 +19377,6 @@ packages: - supports-color dev: true - /http-proxy-agent@5.0.0: - resolution: {integrity: sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==} - engines: {node: '>= 6'} - dependencies: - '@tootallnate/once': 2.0.0 - agent-base: 6.0.2 - debug: 4.3.4(supports-color@8.1.1) - transitivePeerDependencies: - - supports-color - dev: true - /http-proxy-agent@7.0.0: resolution: {integrity: sha512-+ZT+iBxVUQ1asugqnD6oWoRiS25AkjNfG085dKJGtGxkdwLQrMKU5wJr2bOOFAXzKcTuqq+7fZlTMgG3SRfIYQ==} engines: {node: '>= 14'} @@ -21466,127 +21026,6 @@ packages: - utf-8-validate dev: true - /jsdom@20.0.0: - resolution: {integrity: sha512-x4a6CKCgx00uCmP+QakBDFXwjAJ69IkkIWHmtmjd3wvXPcdOS44hfX2vqkOQrVrq8l9DhNNADZRXaCEWvgXtVA==} - engines: {node: '>=14'} - peerDependencies: - canvas: ^2.5.0 - peerDependenciesMeta: - canvas: - optional: true - dependencies: - abab: 2.0.6 - acorn: 8.9.0 - acorn-globals: 6.0.0 - cssom: 0.5.0 - cssstyle: 2.3.0 - data-urls: 3.0.2 - decimal.js: 10.4.0 - domexception: 4.0.0 - escodegen: 2.0.0 - form-data: 4.0.0 - html-encoding-sniffer: 3.0.0 - http-proxy-agent: 5.0.0 - https-proxy-agent: 5.0.1 - is-potential-custom-element-name: 1.0.1 - nwsapi: 2.2.1 - parse5: 7.0.0 - saxes: 6.0.0 - symbol-tree: 3.2.4 - tough-cookie: 4.1.2 - w3c-hr-time: 1.0.2 - w3c-xmlserializer: 3.0.0 - webidl-conversions: 7.0.0 - whatwg-encoding: 2.0.0 - whatwg-mimetype: 3.0.0 - whatwg-url: 11.0.0 - ws: 8.14.2 - xml-name-validator: 4.0.0 - transitivePeerDependencies: - - bufferutil - - supports-color - - utf-8-validate - dev: true - - /jsdom@21.0.0: - resolution: {integrity: sha512-AIw+3ZakSUtDYvhwPwWHiZsUi3zHugpMEKlNPaurviseYoBqo0zBd3zqoUi3LPCNtPFlEP8FiW9MqCZdjb2IYA==} - engines: {node: '>=14'} - peerDependencies: - canvas: ^2.5.0 - peerDependenciesMeta: - canvas: - optional: true - dependencies: - abab: 2.0.6 - acorn: 8.9.0 - acorn-globals: 7.0.1 - cssom: 0.5.0 - cssstyle: 2.3.0 - data-urls: 3.0.2 - decimal.js: 10.4.3 - domexception: 4.0.0 - escodegen: 2.0.0 - form-data: 4.0.0 - html-encoding-sniffer: 3.0.0 - http-proxy-agent: 5.0.0 - https-proxy-agent: 5.0.1 - is-potential-custom-element-name: 1.0.1 - nwsapi: 2.2.4 - parse5: 7.1.2 - saxes: 6.0.0 - symbol-tree: 3.2.4 - tough-cookie: 4.1.2 - w3c-xmlserializer: 4.0.0 - webidl-conversions: 7.0.0 - whatwg-encoding: 2.0.0 - whatwg-mimetype: 3.0.0 - whatwg-url: 11.0.0 - ws: 8.14.2 - xml-name-validator: 4.0.0 - transitivePeerDependencies: - - bufferutil - - supports-color - - utf-8-validate - dev: true - - /jsdom@22.1.0: - resolution: {integrity: sha512-/9AVW7xNbsBv6GfWho4TTNjEo9fe6Zhf9O7s0Fhhr3u+awPwAJMKwAMXnkk5vBxflqLW9hTHX/0cs+P3gW+cQw==} - engines: {node: '>=16'} - peerDependencies: - canvas: ^2.5.0 - peerDependenciesMeta: - canvas: - optional: true - dependencies: - abab: 2.0.6 - cssstyle: 3.0.0 - data-urls: 4.0.0 - decimal.js: 10.4.3 - domexception: 4.0.0 - form-data: 4.0.0 - html-encoding-sniffer: 3.0.0 - http-proxy-agent: 5.0.0 - https-proxy-agent: 5.0.1 - is-potential-custom-element-name: 1.0.1 - nwsapi: 2.2.7 - parse5: 7.1.2 - rrweb-cssom: 0.6.0 - saxes: 6.0.0 - symbol-tree: 3.2.4 - tough-cookie: 4.1.3 - w3c-xmlserializer: 4.0.0 - webidl-conversions: 7.0.0 - whatwg-encoding: 2.0.0 - whatwg-mimetype: 3.0.0 - whatwg-url: 12.0.1 - ws: 8.14.2 - xml-name-validator: 4.0.0 - transitivePeerDependencies: - - bufferutil - - supports-color - - utf-8-validate - dev: true - /jsdom@23.2.0: resolution: {integrity: sha512-L88oL7D/8ufIES+Zjz7v0aes+oBMh2Xnh3ygWvL0OaICOomKEPKuPnIfBJekiXr+BHbbMjrWn/xqrDQuxFTeyA==} engines: {node: '>=18'} @@ -22437,7 +21876,7 @@ packages: /match-sorter@6.3.1: resolution: {integrity: sha512-mxybbo3pPNuA+ZuCUhm5bwNkXrJTbsk5VWbR5wiwz/GC6LIiegBGn2w3O08UG/jdbYLinw51fSQ5xNU1U3MgBw==} dependencies: - '@babel/runtime': 7.23.2 + '@babel/runtime': 7.24.4 remove-accents: 0.4.2 dev: false @@ -23672,14 +23111,6 @@ packages: resolution: {integrity: sha512-Y1wZESM7VUThYY+4W+X4ySH2maqcA+p7UR+w8VWNWVAd6lwuXXWz/w/Cz43J/dI2I+PS6wD5N+bJUF+gjWvIqg==} dev: true - /nwsapi@2.2.1: - resolution: {integrity: sha512-JYOWTeFoS0Z93587vRJgASD5Ut11fYl5NyihP3KrYBvMe1FRRs6RN7m20SA/16GM4P6hTnZjT+UmDOt38UeXNg==} - dev: true - - /nwsapi@2.2.4: - resolution: {integrity: sha512-NHj4rzRo0tQdijE9ZqAx6kYDcoRwYwSYzCA8MY3JzfxlrvEU0jhnhJT9BhqhJs7I/dKcrDm6TyulaRqZPIhN5g==} - dev: true - /nwsapi@2.2.7: resolution: {integrity: sha512-ub5E4+FBPKwAZx0UwIQOjYWGHTEq5sPqHQNRN8Z9e4A7u3Tj1weLJsL59yH9vmvqEtBHaOmT6cYQKIZOxp35FQ==} dev: true @@ -24158,12 +23589,6 @@ packages: resolution: {integrity: sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==} dev: true - /parse5@7.0.0: - resolution: {integrity: sha512-y/t8IXSPWTuRZqXc0ajH/UwDj4mnqLEbSttNbThcFhGrZuOyoyvNBO85PBp2jQa55wY9d07PBNjsK8ZP3K5U6g==} - dependencies: - entities: 4.5.0 - dev: true - /parse5@7.1.2: resolution: {integrity: sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==} dependencies: @@ -24286,10 +23711,6 @@ packages: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} - /pathe@1.1.0: - resolution: {integrity: sha512-ODbEPR0KKHqECXW1GoxdDb+AZvULmXjVPy4rt+pGo2+TnjJTIPJQSVS6N63n8T2Ip+syHhbn52OewKicV0373w==} - dev: true - /pathe@1.1.1: resolution: {integrity: sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==} @@ -24663,12 +24084,6 @@ packages: hasBin: true dev: true - /prettier@2.7.1: - resolution: {integrity: sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==} - engines: {node: '>=10.13.0'} - hasBin: true - dev: true - /prettier@2.8.8: resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} engines: {node: '>=10.13.0'} @@ -25330,7 +24745,7 @@ packages: react: '>=16.6.0' react-dom: '>=16.6.0' dependencies: - '@babel/runtime': 7.23.2 + '@babel/runtime': 7.24.4 dom-helpers: 5.2.1 loose-envify: 1.4.0 prop-types: 15.8.1 @@ -27901,16 +27316,6 @@ packages: resolution: {integrity: sha512-eM+pCBxXO/njtF7vdFsHuqb+ElbxqtI4r5EAvk6grfAFyJ6IvWlSkfZ5T9ozC6xWw3Fj1fGoSmrl0gUs46JVIw==} engines: {node: '>=6'} - /tough-cookie@4.1.2: - resolution: {integrity: sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ==} - engines: {node: '>=6'} - dependencies: - psl: 1.9.0 - punycode: 2.3.1 - universalify: 0.2.0 - url-parse: 1.5.10 - dev: true - /tough-cookie@4.1.3: resolution: {integrity: sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==} engines: {node: '>=6'} @@ -27937,20 +27342,6 @@ packages: punycode: 2.3.1 dev: true - /tr46@3.0.0: - resolution: {integrity: sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==} - engines: {node: '>=12'} - dependencies: - punycode: 2.3.1 - dev: true - - /tr46@4.1.1: - resolution: {integrity: sha512-2lv/66T7e5yNyhAAC4NaKe5nVavzuGJQVVtRYLyQ2OI8tsJ61PMLlelehb0wi2Hx6+hT/OJUWZcw8MjlSRnxvw==} - engines: {node: '>=14'} - dependencies: - punycode: 2.3.1 - dev: true - /tr46@5.0.0: resolution: {integrity: sha512-tk2G5R2KRwBd+ZN0zaEXpmzdKyOYksXwywulIX95MBODjSzMIuQnQ3m8JxgbhnL1LeVo7lqQKsYa1O3Htl7K5g==} engines: {node: '>=18'} @@ -29366,6 +28757,7 @@ packages: /w3c-hr-time@1.0.2: resolution: {integrity: sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==} + deprecated: Use your platform's native performance.now() and performance.timeOrigin. dependencies: browser-process-hrtime: 1.0.0 dev: true @@ -29377,20 +28769,6 @@ packages: xml-name-validator: 3.0.0 dev: true - /w3c-xmlserializer@3.0.0: - resolution: {integrity: sha512-3WFqGEgSXIyGhOmAFtlicJNMjEps8b1MG31NCA0/vOF9+nKMUW1ckhi9cnNHmf88Rzw5V+dwIwsm2C7X8k9aQg==} - engines: {node: '>=12'} - dependencies: - xml-name-validator: 4.0.0 - dev: true - - /w3c-xmlserializer@4.0.0: - resolution: {integrity: sha512-d+BFHzbiCx6zGfz0HyQ6Rg69w9k19nviJspaj4yNscGjrHu94sVP+aRm75yEbCh+r2/yR+7q6hux9LVtbuTGBw==} - engines: {node: '>=14'} - dependencies: - xml-name-validator: 4.0.0 - dev: true - /w3c-xmlserializer@5.0.0: resolution: {integrity: sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==} engines: {node: '>=18'} @@ -29846,22 +29224,6 @@ packages: engines: {node: '>=18'} dev: true - /whatwg-url@11.0.0: - resolution: {integrity: sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==} - engines: {node: '>=12'} - dependencies: - tr46: 3.0.0 - webidl-conversions: 7.0.0 - dev: true - - /whatwg-url@12.0.1: - resolution: {integrity: sha512-Ed/LrqB8EPlGxjS+TrsXcpUond1mhccS3pchLhzSgPCnTimUCKj3IZE75pAs5m6heB2U2TMerKFUXheyHY+VDQ==} - engines: {node: '>=14'} - dependencies: - tr46: 4.1.1 - webidl-conversions: 7.0.0 - dev: true - /whatwg-url@14.0.0: resolution: {integrity: sha512-1lfMEm2IEr7RIV+f4lUNPOqfFL+pO+Xw3fJSqmjX9AbXcXcYOkCe1P6+9VBZB6n94af16NfZf+sSk0JCBZC9aw==} engines: {node: '>=18'} @@ -30477,24 +29839,24 @@ packages: name: subpackage dev: false - file:test/env-custom/vitest-environment-custom: - resolution: {directory: test/env-custom/vitest-environment-custom, type: directory} - name: vitest-environment-custom + file:test/core/deps/dep1: + resolution: {directory: test/core/deps/dep1, type: directory} + name: '@vitest/test-dep1' dev: true - file:test/optimize-deps/dep-url: - resolution: {directory: test/optimize-deps/dep-url, type: directory} - name: '@vitest/test-deps-url' + file:test/core/deps/dep2: + resolution: {directory: test/core/deps/dep2, type: directory} + name: '@vitest/test-dep2' + dependencies: + '@vitest/test-dep1': file:test/core/deps/dep1 dev: true - file:test/vite-node/deps/dep1: - resolution: {directory: test/vite-node/deps/dep1, type: directory} - name: '@vitest/test-dep1' + file:test/core/vitest-environment-custom: + resolution: {directory: test/core/vitest-environment-custom, type: directory} + name: vitest-environment-custom dev: true - file:test/vite-node/deps/dep2: - resolution: {directory: test/vite-node/deps/dep2, type: directory} - name: '@vitest/test-dep2' - dependencies: - '@vitest/test-dep1': file:test/vite-node/deps/dep1 + file:test/optimize-deps/dep-url: + resolution: {directory: test/optimize-deps/dep-url, type: directory} + name: '@vitest/test-deps-url' dev: true diff --git a/test/README.md b/test/README.md new file mode 100644 index 000000000000..9113210ee935 --- /dev/null +++ b/test/README.md @@ -0,0 +1,31 @@ +Tests are split by categories. Default categories are: + +## core + +These tests are running in different pools with a single config file. If you just need to test a function call, you can place your test here. + +This is the only test category that doesn't start new Vitest instance for every test. + +## config + +Place your test here if you are testing a config opton. + +## cli + +If you are testing a complex interaction, place your tests here. + +## browser + +If you are testing browser mode, add your tests here. + +## ui + +These are e2e tests for UI package. We are using `playwright` to test it. + +## watch + +Place your tests here if you are testing Vitest behaviour when file is created/updated/removed. + +---- + +All other categories just group tests by type. diff --git a/test/bail/package.json b/test/bail/package.json deleted file mode 100644 index 00de0ee5314a..000000000000 --- a/test/bail/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "@vitest/test-bail", - "type": "module", - "private": true, - "scripts": { - "test": "vitest" - }, - "devDependencies": { - "@vitest/browser": "workspace:*", - "vite": "latest", - "vitest": "workspace:*", - "webdriverio": "latest" - } -} diff --git a/test/bail/test/bail.test.ts b/test/bail/test/bail.test.ts deleted file mode 100644 index ea8438f04714..000000000000 --- a/test/bail/test/bail.test.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { type UserConfig, expect, test } from 'vitest' - -import { runVitest } from '../../test-utils' - -const configs: UserConfig[] = [] -const pools: UserConfig[] = [{ pool: 'threads' }, { pool: 'forks' }, { pool: 'threads', poolOptions: { threads: { singleThread: true } } }] - -if (process.platform !== 'win32') - pools.push({ browser: { enabled: true, name: 'chromium', provider: 'playwright' } }) - -for (const isolate of [true, false]) { - for (const pool of pools) { - configs.push({ - ...pool, - poolOptions: { - threads: { - ...pool.poolOptions?.threads, - isolate, - }, - forks: { isolate }, - }, - }) - } -} - -for (const config of configs) { - test(`should bail with "${JSON.stringify(config)}"`, async () => { - const isParallel - = (config.pool === 'threads' && config.poolOptions?.threads?.singleThread !== true) - || (config.pool === 'forks' && config.poolOptions?.forks?.singleFork !== true) - - // THREADS here means that multiple tests are run parallel - process.env.THREADS = isParallel ? 'true' : 'false' - - const { exitCode, stdout } = await runVitest({ - root: './fixtures', - bail: 1, - ...config, - }) - - expect(exitCode).toBe(1) - expect(stdout).toMatch('✓ test/first.test.ts > 1 - first.test.ts - this should pass') - expect(stdout).toMatch('× test/first.test.ts > 2 - first.test.ts - this should fail') - - // Cancelled tests should not be run - expect(stdout).not.toMatch('test/first.test.ts > 3 - first.test.ts - this should be skipped') - expect(stdout).not.toMatch('test/second.test.ts > 1 - second.test.ts - this should be skipped') - expect(stdout).not.toMatch('test/second.test.ts > 2 - second.test.ts - this should be skipped') - expect(stdout).not.toMatch('test/second.test.ts > 3 - second.test.ts - this should be skipped') - }, { - retry: config.browser?.enabled ? 3 : 0, - }) -} diff --git a/test/bail/vitest.config.ts b/test/bail/vitest.config.ts deleted file mode 100644 index 7eed931e44b3..000000000000 --- a/test/bail/vitest.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - test: { - reporters: 'verbose', - include: ['test/**/*.test.*'], - env: { CI: 'true' }, - - // For Windows CI mostly - testTimeout: process.env.CI ? 30_000 : 10_000, - chaiConfig: { - truncateThreshold: 999, - }, - }, -}) diff --git a/test/base/package.json b/test/base/package.json deleted file mode 100644 index a789a6dc65f7..000000000000 --- a/test/base/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "@vitest/test-base", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "vitest": "workspace:*" - } -} diff --git a/test/base/test/mocking-with-base.spec.ts b/test/base/test/mocking-with-base.spec.ts deleted file mode 100644 index 4202ebccb5d8..000000000000 --- a/test/base/test/mocking-with-base.spec.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { expect, test, vi } from 'vitest' -import { foo } from '../src' - -vi.mock('../src', () => ({ - foo: 'baz', -})) - -test('module is mocked', () => { - expect(foo).toBe('baz') -}) diff --git a/test/base/vitest.config.ts b/test/base/vitest.config.ts deleted file mode 100644 index 999c4a2e687c..000000000000 --- a/test/base/vitest.config.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - base: '/some/base/url', -}) diff --git a/test/browser/package.json b/test/browser/package.json index 5744343b81e0..081979e2c6dc 100644 --- a/test/browser/package.json +++ b/test/browser/package.json @@ -4,9 +4,10 @@ "private": true, "scripts": { "test": "pnpm run test:webdriverio && pnpm run test:playwright", - "test:webdriverio": "PROVIDER=webdriverio node --test --test-concurrency=1 specs/", - "test:playwright": "PROVIDER=playwright node --test --test-concurrency=1 specs/", - "test:safaridriver": "PROVIDER=webdriverio BROWSER=safari node --test --test-concurrency=1 specs/", + "test:unit": "vitest --no-watch --config=vitest.config.unit.mts", + "test:webdriverio": "PROVIDER=webdriverio pnpm run test:unit", + "test:playwright": "PROVIDER=playwright pnpm run test:unit", + "test:safaridriver": "PROVIDER=webdriverio BROWSER=safari pnpm run test:unit", "test-fixtures": "vitest", "coverage": "vitest --coverage.enabled --coverage.provider=istanbul --browser.headless=yes" }, diff --git a/test/browser/specs/filter.test.mjs b/test/browser/specs/filter.test.mjs deleted file mode 100644 index 7c5d0815284f..000000000000 --- a/test/browser/specs/filter.test.mjs +++ /dev/null @@ -1,36 +0,0 @@ -import assert from 'node:assert' -import test from 'node:test' -import { execa } from 'execa' - -test('filter', async () => { - let result = execa( - 'npx', - [ - 'vitest', - 'run', - 'test/basic.test.ts', - '--testNamePattern', - 'basic 2', - '--browser.headless', - '--reporter=verbose', - ], - { - env: { - CI: '1', - NO_COLOR: '1', - }, - }, - ) - if (process.env.VITEST_BROWSER_DEBUG) { - result.stderr.on('data', (data) => { - process.stderr.write(data.toString()) - }) - result.stdout.on('data', (data) => { - process.stdout.write(data.toString()) - }) - } - result = await result - assert.match(result.stdout, /✓ test\/basic.test.ts > basic 2/) - assert.match(result.stdout, /Test Files {2}1 passed/) - assert.match(result.stdout, /Tests {2}1 passed | 3 skipped/) -}) diff --git a/test/browser/specs/filter.test.ts b/test/browser/specs/filter.test.ts new file mode 100644 index 000000000000..c07099cfcaf7 --- /dev/null +++ b/test/browser/specs/filter.test.ts @@ -0,0 +1,14 @@ +import { expect, test } from 'vitest' +import { runBrowserTests } from './utils' + +test('filter', async () => { + const { stderr, stdout } = await runBrowserTests({ + testNamePattern: 'basic 2', + reporters: ['verbose'], + }, ['test/basic.test.ts']) + + expect(stderr).toBe('') + expect(stdout).toContain('✓ test/basic.test.ts > basic 2') + expect(stdout).toContain('Test Files 1 passed') + expect(stdout).toContain('Tests 1 passed | 3 skipped') +}) diff --git a/test/browser/specs/fix-4686.test.mjs b/test/browser/specs/fix-4686.test.mjs deleted file mode 100644 index d95964ef866e..000000000000 --- a/test/browser/specs/fix-4686.test.mjs +++ /dev/null @@ -1,20 +0,0 @@ -// fix #4686 - -import assert from 'node:assert' -import test from 'node:test' -import runVitest from './run-vitest.mjs' - -const { - stderr, - browserResultJson, - passedTests, - failedTests, -} = await runVitest(['--config', 'vitest.config-basepath.mts', 'basic.test.ts']) - -await test('tests run in presence of config.base', async () => { - assert.ok(browserResultJson.testResults.length === 1, 'Not all the tests have been run') - assert.ok(passedTests.length === 1, 'Some tests failed') - assert.ok(failedTests.length === 0, 'Some tests have passed but should fail') - - assert.doesNotMatch(stderr, /Unhandled Error/, 'doesn\'t have any unhandled errors') -}) diff --git a/test/browser/specs/fix-4686.test.ts b/test/browser/specs/fix-4686.test.ts new file mode 100644 index 000000000000..56871011cc1c --- /dev/null +++ b/test/browser/specs/fix-4686.test.ts @@ -0,0 +1,19 @@ +// fix #4686 + +import { expect, test } from 'vitest' +import { runBrowserTests } from './utils' + +test('tests run in presence of config.base', async () => { + const { stderr, failedTests, passedTests, browserResultJson } = await runBrowserTests( + { + config: './vitest.config-basepath.mts', + }, + ['test/basic.test.ts'], + ) + + expect(browserResultJson.testResults).toHaveLength(1) + expect(passedTests).toHaveLength(1) + expect(failedTests).toHaveLength(0) + + expect(stderr).toBe('') +}) diff --git a/test/browser/specs/run-vitest.mjs b/test/browser/specs/run-vitest.mjs deleted file mode 100644 index 7fcd2cdd5e28..000000000000 --- a/test/browser/specs/run-vitest.mjs +++ /dev/null @@ -1,39 +0,0 @@ -import { readFile } from 'node:fs/promises' -import { execa } from 'execa' - -const browser = process.env.BROWSER || (process.env.PROVIDER === 'playwright' ? 'chromium' : 'chrome') - -export default async function runVitest(moreArgs = []) { - const argv = ['vitest', '--run', `--browser.name=${browser}`] - - if (browser !== 'safari') - argv.push('--browser.headless') - - const result = execa('npx', argv.concat(moreArgs), { - env: { - ...process.env, - CI: 'true', - NO_COLOR: 'true', - }, - reject: false, - }) - if (process.env.VITEST_BROWSER_DEBUG) { - result.stderr.on('data', (data) => { - process.stderr.write(data.toString()) - }) - result.stdout.on('data', (data) => { - process.stdout.write(data.toString()) - }) - } - const { stderr, stdout } = await result - const browserResult = await readFile('./browser.json', 'utf-8') - const browserResultJson = JSON.parse(browserResult) - - const getPassed = results => results.filter(result => result.status === 'passed' && !result.mesage) - const getFailed = results => results.filter(result => result.status === 'failed') - - const passedTests = getPassed(browserResultJson.testResults) - const failedTests = getFailed(browserResultJson.testResults) - - return { stderr, stdout, browserResultJson, passedTests, failedTests } -} diff --git a/test/browser/specs/runner.test.mjs b/test/browser/specs/runner.test.mjs deleted file mode 100644 index 9667361b09bd..000000000000 --- a/test/browser/specs/runner.test.mjs +++ /dev/null @@ -1,77 +0,0 @@ -import assert from 'node:assert' -import test from 'node:test' -import runVitest from './run-vitest.mjs' - -const cliArguments = [ - ['not parallel', ['--no-browser.fileParallelism']], - ['parallel', []], -] - -for (const [description, args] of cliArguments) { - const { - stderr, - stdout, - browserResultJson, - passedTests, - failedTests, - } = await runVitest(args) - - await test(`[${description}] tests are actually running`, async () => { - assert.equal(browserResultJson.testResults.length, 14, 'Not all the tests have been run') - assert.equal(passedTests.length, 12, 'Some tests failed') - assert.equal(failedTests.length, 2, 'Some tests have passed but should fail') - - assert.doesNotMatch(stderr, /has been externalized for browser compatibility/, 'doesn\'t have any externalized modules') - assert.doesNotMatch(stderr, /Unhandled Error/, 'doesn\'t have any unhandled errors') - }) - - await test(`[${description}] correctly prints error`, () => { - assert.match(stderr, /expected 1 to be 2/, 'prints failing error') - assert.match(stderr, /- 2\s+\+ 1/, 'prints failing diff') - assert.match(stderr, /Expected to be/, 'prints \`Expected to be\`') - assert.match(stderr, /But got/, 'prints \`But got\`') - }) - - await test(`[${description}] logs are redirected to stdout`, async () => { - assert.match(stdout, /stdout | test\/logs.test.ts > logging to stdout/) - assert.match(stdout, /hello from console.log/, 'prints console.log') - assert.match(stdout, /hello from console.info/, 'prints console.info') - assert.match(stdout, /hello from console.debug/, 'prints console.debug') - assert.match(stdout, /{ hello: 'from dir' }/, 'prints console.dir') - assert.match(stdout, /{ hello: 'from dirxml' }/, 'prints console.dixml') - // safari logs the stack files with @https://... - assert.match(stdout, /hello from console.trace\s+(\w+|@)/, 'prints console.trace') - assert.match(stdout, /dom
/, 'prints dom') - assert.match(stdout, /default: 1/, 'prints first default count') - assert.match(stdout, /default: 2/, 'prints second default count') - assert.match(stdout, /default: 3/, 'prints third default count') - assert.match(stdout, /count: 1/, 'prints first custom count') - assert.match(stdout, /count: 2/, 'prints second custom count') - assert.match(stdout, /count: 3/, 'prints third custom count') - assert.match(stdout, /default: [\d.]+ ms/, 'prints default time') - assert.match(stdout, /time: [\d.]+ ms/, 'prints custom time') - }) - - await test(`[${description}] logs are redirected to stderr`, async () => { - assert.match(stderr, /stderr | test\/logs.test.ts > logging to stderr/) - assert.match(stderr, /hello from console.error/, 'prints console.log') - assert.match(stderr, /hello from console.warn/, 'prints console.info') - assert.match(stderr, /Timer "invalid timeLog" does not exist/, 'prints errored timeLog') - assert.match(stderr, /Timer "invalid timeEnd" does not exist/, 'prints errored timeEnd') - }) - - await test(`[${description}] stack trace points to correct file in every browser`, () => { - // dependeing on the browser it references either `.toBe()` or `expect()` - assert.match(stderr, /test\/failing.test.ts:4:(12|17)/, 'prints stack trace') - }) - - await test(`[${description}] popup apis should log a warning`, () => { - assert.ok(stderr.includes('Vitest encountered a \`alert\("test"\)\`'), 'prints warning for alert') - assert.ok(stderr.includes('Vitest encountered a \`confirm\("test"\)\`'), 'prints warning for confirm') - assert.ok(stderr.includes('Vitest encountered a \`prompt\("test"\)\`'), 'prints warning for prompt') - }) - - await test(`[${description}] snapshot inaccessible file debuggability`, () => { - assert.ok(stdout.includes('Access denied to "/inaccesible/path".'), 'file security enforcement explained') - }) -} diff --git a/test/browser/specs/runner.test.ts b/test/browser/specs/runner.test.ts new file mode 100644 index 000000000000..213e673db5ad --- /dev/null +++ b/test/browser/specs/runner.test.ts @@ -0,0 +1,86 @@ +import { beforeAll, describe, expect, test } from 'vitest' +import { runBrowserTests } from './utils' + +describe.each([ + ['non parallel', false], + ['parallel', true], +])('[%s] running browser tests', async (description, fileParallelism) => { + let stderr: string + let stdout: string + let browserResultJson: any + let passedTests: any[] + let failedTests: any[] + + beforeAll(async () => { + ({ + stderr, + stdout, + browserResultJson, + passedTests, + failedTests, + } = await runBrowserTests({ + browser: { + fileParallelism, + }, + })) + }) + + test(`[${description}] tests are actually running`, () => { + expect(browserResultJson.testResults).toHaveLength(14) + expect(passedTests).toHaveLength(12) + expect(failedTests).toHaveLength(2) + + expect(stderr).not.toContain('has been externalized for browser compatibility') + expect(stderr).not.toContain('Unhandled Error') + }) + + test(`[${description}] correctly prints error`, () => { + expect(stderr).toContain('expected 1 to be 2') + expect(stderr).toMatch(/- 2\s+\+ 1/) + expect(stderr).toContain('Expected to be') + expect(stderr).toContain('But got') + }) + + test(`[${description}] logs are redirected to stdout`, () => { + expect(stdout).toContain('stdout | test/logs.test.ts > logging to stdout') + expect(stdout).toContain('hello from console.log') + expect(stdout).toContain('hello from console.info') + expect(stdout).toContain('hello from console.debug') + expect(stdout).toContain('{ hello: \'from dir\' }') + expect(stdout).toContain('{ hello: \'from dirxml\' }') + // safari logs the stack files with @https://... + expect(stdout).toMatch(/hello from console.trace\s+(\w+|@)/) + expect(stdout).toContain('dom
') + expect(stdout).toContain('default: 1') + expect(stdout).toContain('default: 2') + expect(stdout).toContain('default: 3') + expect(stdout).toContain('count: 1') + expect(stdout).toContain('count: 2') + expect(stdout).toContain('count: 3') + expect(stdout).toMatch(/default: [\d.]+ ms/) + expect(stdout).toMatch(/time: [\d.]+ ms/) + }) + + test(`[${description}] logs are redirected to stderr`, () => { + expect(stderr).toContain('stderr | test/logs.test.ts > logging to stderr') + expect(stderr).toContain('hello from console.error') + expect(stderr).toContain('hello from console.warn') + expect(stderr).toContain('Timer "invalid timeLog" does not exist') + expect(stderr).toContain('Timer "invalid timeEnd" does not exist') + }) + + test(`[${description}] stack trace points to correct file in every browser`, () => { + // dependeing on the browser it references either `.toBe()` or `expect()` + expect(stderr).toMatch(/test\/failing.test.ts:4:(12|17)/) + }) + + test(`[${description}] popup apis should log a warning`, () => { + expect(stderr).toContain('Vitest encountered a `alert("test")`') + expect(stderr).toContain('Vitest encountered a `confirm("test")`') + expect(stderr).toContain('Vitest encountered a `prompt("test")`') + }) + + test(`[${description}] snapshot inaccessible file debuggability`, () => { + expect(stderr).toContain('Access denied to "/inaccesible/path".') + }) +}) diff --git a/test/browser/specs/server-url.test.mjs b/test/browser/specs/server-url.test.mjs deleted file mode 100644 index 9060edf41439..000000000000 --- a/test/browser/specs/server-url.test.mjs +++ /dev/null @@ -1,26 +0,0 @@ -import assert from 'node:assert' -import test from 'node:test' -import { execa } from 'execa' - -test('server-url http', async () => { - const result = await execa('npx', ['vitest', 'run', '--root=./fixtures/server-url', '--browser.headless'], { - env: { - CI: '1', - NO_COLOR: '1', - }, - }) - assert.match(result.stdout, /Browser runner started at http:\/\/localhost:5173\//) - assert.match(result.stdout, /Test Files {2}1 passed/) -}) - -test('server-url https', async () => { - const result = await execa('npx', ['vitest', 'run', '--root=./fixtures/server-url', '--browser.headless'], { - env: { - CI: '1', - NO_COLOR: '1', - TEST_HTTPS: '1', - }, - }) - assert.match(result.stdout, /Browser runner started at https:\/\/localhost:5173\//) - assert.match(result.stdout, /Test Files {2}1 passed/) -}) diff --git a/test/browser/specs/server-url.test.ts b/test/browser/specs/server-url.test.ts new file mode 100644 index 000000000000..da129589c9f1 --- /dev/null +++ b/test/browser/specs/server-url.test.ts @@ -0,0 +1,24 @@ +import { afterEach, expect, test } from 'vitest' +import { runBrowserTests } from './utils' + +afterEach(() => { + delete process.env.TEST_HTTPS +}) + +test('server-url http', async () => { + const { stdout, stderr } = await runBrowserTests({ + root: './fixtures/server-url', + }) + expect(stderr).toBe('') + expect(stdout).toContain('Browser runner started at http://localhost:5173/') +}) + +test('server-url https', async () => { + process.env.TEST_HTTPS = '1' + const { stdout, stderr } = await runBrowserTests({ + root: './fixtures/server-url', + }) + expect(stderr).toBe('') + expect(stdout).toContain('Browser runner started at https://localhost:5173/') + expect(stdout).toContain('Test Files 1 passed') +}) diff --git a/test/browser/specs/update-snapshot.test.mjs b/test/browser/specs/update-snapshot.test.mjs deleted file mode 100644 index 7e24ac1f34d7..000000000000 --- a/test/browser/specs/update-snapshot.test.mjs +++ /dev/null @@ -1,70 +0,0 @@ -import assert from 'node:assert' -import fs from 'node:fs' -import test from 'node:test' -import { startVitest } from 'vitest/node' - -let vitest - -test.after(async () => { - await vitest?.close() -}) - -test('update snapshot', async () => { - // setup wrong snapshot value - const snapshotPath = './fixtures/update-snapshot/__snapshots__/basic.test.ts.snap' - await editFile(snapshotPath, data => data.replace('`1`', '`2`')) - - // run vitest watch mode - const result = await wrapExit(() => startVitest('test', [], { - watch: true, - root: './fixtures/update-snapshot', - reporters: ['tap-flat'], // use simple reporter to not pollute stdout - browser: { headless: true }, - })) - vitest = result.value - assert.ok(vitest) - - // test fails - assert.equal(result.exitCode, 1) - assert.equal(vitest.state.getFiles()[0].result.state, 'fail') - - // updateSnapshot API to simulate "u" commmand - await vitest.updateSnapshot() - - // verify snapshot value is updated - const snapshotData = await fs.promises.readFile(snapshotPath, 'utf-8') - assert.match(snapshotData, /`1`/) - - // test passes - assert.equal(vitest.state.getFiles()[0].result.state, 'pass') -}) - -/** - * @param {string} filepath - * @param {(data: string) => string} edit - */ -async function editFile(filepath, edit) { - const data = await fs.promises.readFile(filepath, 'utf-8') - await fs.promises.writeFile(filepath, edit(data)) -} - -/** - * run function and return mutated exitCode while preserving current exitCode - * @param {() => any} f - */ -async function wrapExit(f) { - const prevExitCode = process.exitCode - const prevExit = process.exit - process.exit = () => {} - /** @type {{ value?: any, exitCode?: number }} */ - const result = {} - try { - result.value = await f() - } - finally { - result.exitCode = process.exitCode - process.exitCode = prevExitCode - process.exit = prevExit - } - return result -} diff --git a/test/browser/specs/update-snapshot.test.ts b/test/browser/specs/update-snapshot.test.ts new file mode 100644 index 000000000000..9e564acaf9d0 --- /dev/null +++ b/test/browser/specs/update-snapshot.test.ts @@ -0,0 +1,36 @@ +import fs from 'node:fs' +import { expect, onTestFinished, test } from 'vitest' +import { editFile } from '../../test-utils' +import { runBrowserTests } from './utils' + +test('update snapshot', async () => { + // setup wrong snapshot value + const snapshotPath = './fixtures/update-snapshot/__snapshots__/basic.test.ts.snap' + editFile(snapshotPath, data => data.replace('`1`', '`2`')) + + // run vitest watch mode + const { exitCode, ctx: vitest } = await runBrowserTests({ + watch: true, + root: './fixtures/update-snapshot', + reporters: ['tap-flat'], // use simple reporter to not pollute stdout + browser: { headless: true }, + }) + onTestFinished(() => vitest.close()) + + // test fails + expect(exitCode).toBe(1) + + const files = vitest.state.getFiles() + expect(files).toHaveLength(1) + expect(files[0].result.state).toBe('fail') + + // updateSnapshot API to simulate "u" commmand + await vitest.updateSnapshot() + + // verify snapshot value is updated + const snapshotData = await fs.promises.readFile(snapshotPath, 'utf-8') + expect(snapshotData).toContain('`1`') + + // test passes + expect(vitest.state.getFiles()[0].result.state).toBe('pass') +}) diff --git a/test/browser/specs/utils.ts b/test/browser/specs/utils.ts new file mode 100644 index 000000000000..4a58183d5c6f --- /dev/null +++ b/test/browser/specs/utils.ts @@ -0,0 +1,28 @@ +import { readFile } from 'node:fs/promises' +import type { UserConfig } from 'vitest' +import { runVitest } from '../../test-utils' + +const browser = process.env.BROWSER || (process.env.PROVIDER !== 'playwright' ? 'chromium' : 'chrome') + +export async function runBrowserTests(config?: Omit & { browser?: Partial }, include?: string[]) { + const result = await runVitest({ + watch: false, + reporters: 'none', + ...config, + browser: { + headless: browser !== 'safari', + ...config?.browser, + } as UserConfig['browser'], + }, include) + + const browserResult = await readFile('./browser.json', 'utf-8') + const browserResultJson = JSON.parse(browserResult) + + const getPassed = results => results.filter(result => result.status === 'passed' && !result.mesage) + const getFailed = results => results.filter(result => result.status === 'failed') + + const passedTests = getPassed(browserResultJson.testResults) + const failedTests = getFailed(browserResultJson.testResults) + + return { ...result, browserResultJson, passedTests, failedTests } +} diff --git a/test/browser/tsconfig.json b/test/browser/tsconfig.json index 1b1263fab6c2..183104f0320b 100644 --- a/test/browser/tsconfig.json +++ b/test/browser/tsconfig.json @@ -1,6 +1,5 @@ { "compilerOptions": { - "rootDir": ".", "module": "ESNext", "moduleResolution": "Bundler", "paths": { diff --git a/test/browser/vitest.config.mts b/test/browser/vitest.config.mts index 87bc76d0eb45..3056fad93a08 100644 --- a/test/browser/vitest.config.mts +++ b/test/browser/vitest.config.mts @@ -6,7 +6,7 @@ const dir = dirname(fileURLToPath(import.meta.url)) function noop() {} -const provider = process.env.PROVIDER || 'webdriverio' +const provider = process.env.PROVIDER || 'playwright' const browser = process.env.BROWSER || (provider === 'playwright' ? 'chromium' : 'chrome') export default defineConfig({ diff --git a/test/browser/vitest.config.unit.mts b/test/browser/vitest.config.unit.mts new file mode 100644 index 000000000000..0fa549ea6d1d --- /dev/null +++ b/test/browser/vitest.config.unit.mts @@ -0,0 +1,14 @@ +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + include: ['specs/**/*.{spec,test}.ts'], + poolOptions: { + threads: { + singleThread: true, + }, + }, + hookTimeout: process.env.CI ? 120_000 : 10_000, + testTimeout: process.env.CI ? 120_000 : 10_000, + }, +}) diff --git a/test/changed/package.json b/test/changed/package.json deleted file mode 100644 index 9daa724ab30b..000000000000 --- a/test/changed/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@vitest/test-changed", - "type": "module", - "private": true, - "scripts": { - "test": "vitest" - }, - "devDependencies": { - "vitest": "workspace:*" - } -} diff --git a/test/changed/tests/forceRerunTrigger.test.ts b/test/changed/tests/forceRerunTrigger.test.ts deleted file mode 100644 index a1472b58effb..000000000000 --- a/test/changed/tests/forceRerunTrigger.test.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { unlink, writeFile } from 'node:fs' -import { join } from 'node:path' -import { beforeEach, describe, expect, it } from 'vitest' - -import { runVitest } from '../../test-utils' - -const fileName = 'fixtures/related/rerun.temp' - -describe('forceRerunTrigger', () => { - async function run() { - return runVitest({ - root: join(process.cwd(), 'fixtures/related'), - include: ['related.test.ts'], - forceRerunTriggers: ['**/rerun.temp/**'], - changed: true, - }) - } - - beforeEach(async () => { - unlink(fileName, () => {}) - }) - - it('should run the whole test suite if file exists', async () => { - writeFile(fileName, '', () => {}) - const { stdout, stderr } = await run() - expect(stderr).toBe('') - expect(stdout).toContain('1 passed') - expect(stdout).toContain('related.test.ts') - expect(stdout).not.toContain('not-related.test.ts') - }) - - it('should run no tests if file does not exist', async () => { - const { stdout } = await run() - expect(stdout).toContain('No test files found, exiting with code 0') - }) -}) diff --git a/test/changed/tests/related.test.ts b/test/changed/tests/related.test.ts deleted file mode 100644 index 161064c6594d..000000000000 --- a/test/changed/tests/related.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { expect, it } from 'vitest' - -import { runVitest } from '../../test-utils' - -it('related correctly runs only related tests', async () => { - const { stdout, stderr } = await runVitest({ - related: 'src/sourceA.ts', - root: './fixtures/related', - globals: true, - }) - - expect(stderr).toBe('') - expect(stdout).toContain('3 passed') - expect(stdout).toContain('related.test.ts') - expect(stdout).toContain('deep-related-imports.test.ts') - expect(stdout).toContain('deep-related-exports.test.ts') - expect(stdout).not.toContain('not-related.test.ts') -}) diff --git a/test/changed/tests/workspaceRelated.test.ts b/test/changed/tests/workspaceRelated.test.ts deleted file mode 100644 index d5cffa51afa2..000000000000 --- a/test/changed/tests/workspaceRelated.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { expect, it } from 'vitest' - -import { editFile, resolvePath, runVitest } from '../../test-utils' - -it('doesn\'t run any test in a workspace because there are no changes', async () => { - const { stdout } = await runVitest({ - changed: true, - root: './fixtures/workspace', - }) - - expect(stdout).toContain('No test files found, exiting with code 0') -}) - -// Fixes #4674 -it('related correctly runs only related tests inside a workspace', async () => { - editFile(resolvePath(import.meta.url, '../fixtures/workspace/packages/packageA/index.js'), content => `${content}\n`) - - const { stdout, stderr } = await runVitest({ - changed: true, - root: './fixtures/workspace', - }) - - expect(stderr).toBe('') - expect(stdout).toContain('1 passed') - expect(stdout).toContain('packageA') - expect(stdout).not.toContain('packageB') -}) diff --git a/test/changed/vitest.config.js b/test/changed/vitest.config.js deleted file mode 100644 index aa5c6a9c3705..000000000000 --- a/test/changed/vitest.config.js +++ /dev/null @@ -1,9 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - test: { - include: ['tests/**/*.test.ts'], - testTimeout: 60_000, - hookTimeout: 60_000, - }, -}) diff --git a/test/cjs/package.json b/test/cjs/package.json deleted file mode 100644 index 86fb8de38ba2..000000000000 --- a/test/cjs/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "@vitest/test-cjs", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "@types/fs-extra": "^9.0.13", - "@types/lodash": "^4.14.201", - "@types/prettier": "^2.6.1", - "fs-extra": "^10.1.0", - "givens": "1.3.9", - "history": "^5.3.0", - "lodash": "^4.17.21", - "prettier": "^2.6.2", - "temp-dir": "^2.0.0", - "vitest": "workspace:*" - } -} diff --git a/test/cjs/src/other.cjs b/test/cjs/src/other.cjs deleted file mode 100644 index 35e3bd6e77f9..000000000000 --- a/test/cjs/src/other.cjs +++ /dev/null @@ -1,2 +0,0 @@ -'use strict' -exports.default = 2 diff --git a/test/cjs/src/other.d.cts b/test/cjs/src/other.d.cts deleted file mode 100644 index 6a16fde0c615..000000000000 --- a/test/cjs/src/other.d.cts +++ /dev/null @@ -1,5 +0,0 @@ -declare const defaultExports: { - default: number -} - -export default defaultExports diff --git a/test/cjs/src/prototype.d.cts b/test/cjs/src/prototype.d.cts deleted file mode 100644 index 4b913956249d..000000000000 --- a/test/cjs/src/prototype.d.cts +++ /dev/null @@ -1,2 +0,0 @@ -export const test: () => boolean -export const getPrototype: () => any diff --git a/test/cjs/test/fs-extra.test.ts b/test/cjs/test/fs-extra.test.ts deleted file mode 100644 index f8e0e5e79ab7..000000000000 --- a/test/cjs/test/fs-extra.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import fs, { existsSync } from 'fs-extra' -import { describe, expect, it } from 'vitest' - -describe('fs-extra', () => { - it('default export', () => { - expect(fs.existsSync('test/fs-extra.test.ts')).toBe(true) - }) - - it('named export', () => { - expect(existsSync('test/fs-extra.test.ts')).toBe(true) - }) -}) diff --git a/test/cjs/test/function-default.test.ts b/test/cjs/test/function-default.test.ts deleted file mode 100644 index bf640d2c77a0..000000000000 --- a/test/cjs/test/function-default.test.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { describe, expect, it } from 'vitest' -import format from '../src/default-function.cjs' - -describe('correctly puts default on default', () => { - it('works on default function', () => { - expect(format()).toBe('') - }) - - it('works on nested default function', () => { - // @ts-expect-error types defined only default - expect(format.default).toBeUndefined() - }) -}) diff --git a/test/cjs/test/history.test.ts b/test/cjs/test/history.test.ts deleted file mode 100644 index 5c01f8acc219..000000000000 --- a/test/cjs/test/history.test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { createMemoryHistory } from 'history' -import { describe, expect, it } from 'vitest' - -describe('history', () => { - it('should work', () => { - const history = createMemoryHistory() - expect(history.location.pathname).toBe('/') - }) -}) diff --git a/test/cjs/test/interpret-default.test.tsx b/test/cjs/test/interpret-default.test.tsx deleted file mode 100644 index 68d6e48e97e2..000000000000 --- a/test/cjs/test/interpret-default.test.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { expect, it } from 'vitest' -import { format } from 'prettier' -import givens from 'givens' -import tempDir from 'temp-dir' -import _, { isString } from 'lodash' - -it('prettier', () => { - expect(format('const a : A = \'t\'', { parser: 'typescript' }).trim()) - .toEqual('const a: A = "t";'.trim()) -}) - -it('lodash', () => { - expect(typeof _.isString).toBe('function') - expect(typeof isString).toBe('function') -}) - -it('has nested default', () => { - expect(typeof givens).toBe('function') - expect(givens.name).toBe('getGiven') -}) - -it('nested default is not an object', () => { - expect(typeof tempDir).toBe('string') -}) diff --git a/test/cjs/test/prototype.test.ts b/test/cjs/test/prototype.test.ts deleted file mode 100644 index 7cab942b87e9..000000000000 --- a/test/cjs/test/prototype.test.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { expect, it } from 'vitest' -import * as cjsExports from '../src/prototype.cjs' - -it('has object prototype', () => { - expect(cjsExports.getPrototype()).toBe(Object.prototype) - expect(() => cjsExports.test()).not.toThrow() - expect(cjsExports.test()).toBe(true) -}) diff --git a/test/cjs/tsconfig.json b/test/cjs/tsconfig.json deleted file mode 100644 index 2f98042715ab..000000000000 --- a/test/cjs/tsconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "compilerOptions": { - "esModuleInterop": true - } -} diff --git a/test/cjs/vitest.config.ts b/test/cjs/vitest.config.ts deleted file mode 100644 index 08d877e33e35..000000000000 --- a/test/cjs/vitest.config.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - test: { - deps: { - interopDefault: true, - }, - }, -}) diff --git a/test/env-custom-file/custom.ts b/test/cli/custom.ts similarity index 100% rename from test/env-custom-file/custom.ts rename to test/cli/custom.ts diff --git a/test/env-custom-file/test/base.test.ts b/test/cli/fixtures/custom-file-env/custom-file-env.test.ts similarity index 76% rename from test/env-custom-file/test/base.test.ts rename to test/cli/fixtures/custom-file-env/custom-file-env.test.ts index aa6443e33e02..896413006910 100644 --- a/test/env-custom-file/test/base.test.ts +++ b/test/cli/fixtures/custom-file-env/custom-file-env.test.ts @@ -3,5 +3,5 @@ import { expect, test } from 'vitest' test('custom env is defined', () => { expect(expect.getState().environment).toBe('custom') expect((globalThis as any).testEnvironment).toBe('custom') - expect((globalThis as any).option).toBe('config-option') + expect((globalThis as any).option).toBe('custom-option') }) diff --git a/test/run/pool-custom-fixtures/pool/custom-pool.ts b/test/cli/fixtures/custom-pool/pool/custom-pool.ts similarity index 100% rename from test/run/pool-custom-fixtures/pool/custom-pool.ts rename to test/cli/fixtures/custom-pool/pool/custom-pool.ts diff --git a/test/run/pool-custom-fixtures/tests/custom-not-run.spec.ts b/test/cli/fixtures/custom-pool/tests/custom-not-run.spec.ts similarity index 100% rename from test/run/pool-custom-fixtures/tests/custom-not-run.spec.ts rename to test/cli/fixtures/custom-pool/tests/custom-not-run.spec.ts diff --git a/test/run/pool-custom-fixtures/tests/custom-run.threads.spec.ts b/test/cli/fixtures/custom-pool/tests/custom-run.threads.spec.ts similarity index 100% rename from test/run/pool-custom-fixtures/tests/custom-run.threads.spec.ts rename to test/cli/fixtures/custom-pool/tests/custom-run.threads.spec.ts diff --git a/test/run/pool-custom-fixtures/vitest.config.ts b/test/cli/fixtures/custom-pool/vitest.config.ts similarity index 100% rename from test/run/pool-custom-fixtures/vitest.config.ts rename to test/cli/fixtures/custom-pool/vitest.config.ts diff --git a/test/cwd/.cache/projects/test/.cache/should-not-run.test.ts b/test/cli/fixtures/dotted-files/.cache/projects/test/.cache/should-not-run.test.ts similarity index 100% rename from test/cwd/.cache/projects/test/.cache/should-not-run.test.ts rename to test/cli/fixtures/dotted-files/.cache/projects/test/.cache/should-not-run.test.ts diff --git a/test/cwd/.cache/projects/test/should-run.test.ts b/test/cli/fixtures/dotted-files/.cache/projects/test/should-run.test.ts similarity index 100% rename from test/cwd/.cache/projects/test/should-run.test.ts rename to test/cli/fixtures/dotted-files/.cache/projects/test/should-run.test.ts diff --git a/test/failing/fixtures/expects/soft.test.ts b/test/cli/fixtures/expect-soft/expects/soft.test.ts similarity index 100% rename from test/failing/fixtures/expects/soft.test.ts rename to test/cli/fixtures/expect-soft/expects/soft.test.ts diff --git a/test/failing/fixtures/vite.config.ts b/test/cli/fixtures/expect-soft/vite.config.ts similarity index 100% rename from test/failing/fixtures/vite.config.ts rename to test/cli/fixtures/expect-soft/vite.config.ts diff --git a/test/fails/fixtures/.dot-folder/dot-test.test.ts b/test/cli/fixtures/fails/.dot-folder/dot-test.test.ts similarity index 100% rename from test/fails/fixtures/.dot-folder/dot-test.test.ts rename to test/cli/fixtures/fails/.dot-folder/dot-test.test.ts diff --git a/test/fails/fixtures/each-timeout.test.ts b/test/cli/fixtures/fails/each-timeout.test.ts similarity index 100% rename from test/fails/fixtures/each-timeout.test.ts rename to test/cli/fixtures/fails/each-timeout.test.ts diff --git a/test/empty-test/test/empty.test.ts b/test/cli/fixtures/fails/empty.test.ts similarity index 100% rename from test/empty-test/test/empty.test.ts rename to test/cli/fixtures/fails/empty.test.ts diff --git a/test/fails/fixtures/expect-soft.test.ts b/test/cli/fixtures/fails/expect-soft.test.ts similarity index 100% rename from test/fails/fixtures/expect-soft.test.ts rename to test/cli/fixtures/fails/expect-soft.test.ts diff --git a/test/fails/fixtures/expect-unreachable.test.ts b/test/cli/fixtures/fails/expect-unreachable.test.ts similarity index 100% rename from test/fails/fixtures/expect-unreachable.test.ts rename to test/cli/fixtures/fails/expect-unreachable.test.ts diff --git a/test/fails/fixtures/expect.test.ts b/test/cli/fixtures/fails/expect.test.ts similarity index 100% rename from test/fails/fixtures/expect.test.ts rename to test/cli/fixtures/fails/expect.test.ts diff --git a/test/fails/fixtures/hook-timeout.test.ts b/test/cli/fixtures/fails/hook-timeout.test.ts similarity index 100% rename from test/fails/fixtures/hook-timeout.test.ts rename to test/cli/fixtures/fails/hook-timeout.test.ts diff --git a/test/fails/fixtures/hooks-called.test.ts b/test/cli/fixtures/fails/hooks-called.test.ts similarity index 100% rename from test/fails/fixtures/hooks-called.test.ts rename to test/cli/fixtures/fails/hooks-called.test.ts diff --git a/test/fails/fixtures/inline-snapshop-inside-each.test.ts b/test/cli/fixtures/fails/inline-snapshop-inside-each.test.ts similarity index 100% rename from test/fails/fixtures/inline-snapshop-inside-each.test.ts rename to test/cli/fixtures/fails/inline-snapshop-inside-each.test.ts diff --git a/test/fails/fixtures/mock-import-proxy-module.test.ts b/test/cli/fixtures/fails/mock-import-proxy-module.test.ts similarity index 100% rename from test/fails/fixtures/mock-import-proxy-module.test.ts rename to test/cli/fixtures/fails/mock-import-proxy-module.test.ts diff --git a/test/fails/fixtures/nested-suite.test.ts b/test/cli/fixtures/fails/nested-suite.test.ts similarity index 100% rename from test/fails/fixtures/nested-suite.test.ts rename to test/cli/fixtures/fails/nested-suite.test.ts diff --git a/test/fails/fixtures/primitive-error.test.ts b/test/cli/fixtures/fails/primitive-error.test.ts similarity index 100% rename from test/fails/fixtures/primitive-error.test.ts rename to test/cli/fixtures/fails/primitive-error.test.ts diff --git a/test/fails/fixtures/proxy-module.ts b/test/cli/fixtures/fails/proxy-module.ts similarity index 100% rename from test/fails/fixtures/proxy-module.ts rename to test/cli/fixtures/fails/proxy-module.ts diff --git a/test/fails/fixtures/snapshot-with-not.test.ts b/test/cli/fixtures/fails/snapshot-with-not.test.ts similarity index 100% rename from test/fails/fixtures/snapshot-with-not.test.ts rename to test/cli/fixtures/fails/snapshot-with-not.test.ts diff --git a/test/fails/fixtures/stall.test.ts b/test/cli/fixtures/fails/stall.test.ts similarity index 100% rename from test/fails/fixtures/stall.test.ts rename to test/cli/fixtures/fails/stall.test.ts diff --git a/test/fails/fixtures/test-extend/circular-dependency.test.ts b/test/cli/fixtures/fails/test-extend/circular-dependency.test.ts similarity index 100% rename from test/fails/fixtures/test-extend/circular-dependency.test.ts rename to test/cli/fixtures/fails/test-extend/circular-dependency.test.ts diff --git a/test/fails/fixtures/test-extend/fixture-error.test.ts b/test/cli/fixtures/fails/test-extend/fixture-error.test.ts similarity index 100% rename from test/fails/fixtures/test-extend/fixture-error.test.ts rename to test/cli/fixtures/fails/test-extend/fixture-error.test.ts diff --git a/test/fails/fixtures/test-extend/fixture-rest-params.test.ts b/test/cli/fixtures/fails/test-extend/fixture-rest-params.test.ts similarity index 100% rename from test/fails/fixtures/test-extend/fixture-rest-params.test.ts rename to test/cli/fixtures/fails/test-extend/fixture-rest-params.test.ts diff --git a/test/fails/fixtures/test-extend/fixture-rest-props.test.ts b/test/cli/fixtures/fails/test-extend/fixture-rest-props.test.ts similarity index 100% rename from test/fails/fixtures/test-extend/fixture-rest-props.test.ts rename to test/cli/fixtures/fails/test-extend/fixture-rest-props.test.ts diff --git a/test/fails/fixtures/test-extend/fixture-without-destructuring.test.ts b/test/cli/fixtures/fails/test-extend/fixture-without-destructuring.test.ts similarity index 100% rename from test/fails/fixtures/test-extend/fixture-without-destructuring.test.ts rename to test/cli/fixtures/fails/test-extend/fixture-without-destructuring.test.ts diff --git a/test/fails/fixtures/test-extend/test-rest-params.test.ts b/test/cli/fixtures/fails/test-extend/test-rest-params.test.ts similarity index 100% rename from test/fails/fixtures/test-extend/test-rest-params.test.ts rename to test/cli/fixtures/fails/test-extend/test-rest-params.test.ts diff --git a/test/fails/fixtures/test-extend/test-rest-props.test.ts b/test/cli/fixtures/fails/test-extend/test-rest-props.test.ts similarity index 100% rename from test/fails/fixtures/test-extend/test-rest-props.test.ts rename to test/cli/fixtures/fails/test-extend/test-rest-props.test.ts diff --git a/test/fails/fixtures/test-extend/test-without-destructuring.test.ts b/test/cli/fixtures/fails/test-extend/test-without-destructuring.test.ts similarity index 100% rename from test/fails/fixtures/test-extend/test-without-destructuring.test.ts rename to test/cli/fixtures/fails/test-extend/test-without-destructuring.test.ts diff --git a/test/fails/fixtures/test-timeout.test.ts b/test/cli/fixtures/fails/test-timeout.test.ts similarity index 100% rename from test/fails/fixtures/test-timeout.test.ts rename to test/cli/fixtures/fails/test-timeout.test.ts diff --git a/test/fails/fixtures/unhandled.test.ts b/test/cli/fixtures/fails/unhandled.test.ts similarity index 100% rename from test/fails/fixtures/unhandled.test.ts rename to test/cli/fixtures/fails/unhandled.test.ts diff --git a/test/fails/fixtures/vite.config.ts b/test/cli/fixtures/fails/vite.config.ts similarity index 100% rename from test/fails/fixtures/vite.config.ts rename to test/cli/fixtures/fails/vite.config.ts diff --git a/test/changed/fixtures/related/deep-related-exports.test.ts b/test/cli/fixtures/git-changed/related/deep-related-exports.test.ts similarity index 100% rename from test/changed/fixtures/related/deep-related-exports.test.ts rename to test/cli/fixtures/git-changed/related/deep-related-exports.test.ts diff --git a/test/changed/fixtures/related/deep-related-imports.test.ts b/test/cli/fixtures/git-changed/related/deep-related-imports.test.ts similarity index 100% rename from test/changed/fixtures/related/deep-related-imports.test.ts rename to test/cli/fixtures/git-changed/related/deep-related-imports.test.ts diff --git a/test/changed/fixtures/related/not-related.test.ts b/test/cli/fixtures/git-changed/related/not-related.test.ts similarity index 100% rename from test/changed/fixtures/related/not-related.test.ts rename to test/cli/fixtures/git-changed/related/not-related.test.ts diff --git a/test/changed/fixtures/related/related.test.ts b/test/cli/fixtures/git-changed/related/related.test.ts similarity index 100% rename from test/changed/fixtures/related/related.test.ts rename to test/cli/fixtures/git-changed/related/related.test.ts diff --git a/test/changed/fixtures/related/src/sourceA.ts b/test/cli/fixtures/git-changed/related/src/sourceA.ts similarity index 100% rename from test/changed/fixtures/related/src/sourceA.ts rename to test/cli/fixtures/git-changed/related/src/sourceA.ts diff --git a/test/changed/fixtures/related/src/sourceB.ts b/test/cli/fixtures/git-changed/related/src/sourceB.ts similarity index 100% rename from test/changed/fixtures/related/src/sourceB.ts rename to test/cli/fixtures/git-changed/related/src/sourceB.ts diff --git a/test/changed/fixtures/related/src/sourceC.ts b/test/cli/fixtures/git-changed/related/src/sourceC.ts similarity index 100% rename from test/changed/fixtures/related/src/sourceC.ts rename to test/cli/fixtures/git-changed/related/src/sourceC.ts diff --git a/test/changed/fixtures/related/src/sourceD.ts b/test/cli/fixtures/git-changed/related/src/sourceD.ts similarity index 100% rename from test/changed/fixtures/related/src/sourceD.ts rename to test/cli/fixtures/git-changed/related/src/sourceD.ts diff --git a/test/changed/fixtures/related/vitest.config.js b/test/cli/fixtures/git-changed/related/vitest.config.js similarity index 100% rename from test/changed/fixtures/related/vitest.config.js rename to test/cli/fixtures/git-changed/related/vitest.config.js diff --git a/test/changed/fixtures/workspace/package.json b/test/cli/fixtures/git-changed/workspace/package.json similarity index 100% rename from test/changed/fixtures/workspace/package.json rename to test/cli/fixtures/git-changed/workspace/package.json diff --git a/test/changed/fixtures/workspace/packages/packageA/index.js b/test/cli/fixtures/git-changed/workspace/packages/packageA/index.js similarity index 100% rename from test/changed/fixtures/workspace/packages/packageA/index.js rename to test/cli/fixtures/git-changed/workspace/packages/packageA/index.js diff --git a/test/changed/fixtures/workspace/packages/packageA/index.test.js b/test/cli/fixtures/git-changed/workspace/packages/packageA/index.test.js similarity index 100% rename from test/changed/fixtures/workspace/packages/packageA/index.test.js rename to test/cli/fixtures/git-changed/workspace/packages/packageA/index.test.js diff --git a/test/changed/fixtures/workspace/packages/packageA/vitest.config.mjs b/test/cli/fixtures/git-changed/workspace/packages/packageA/vitest.config.mjs similarity index 100% rename from test/changed/fixtures/workspace/packages/packageA/vitest.config.mjs rename to test/cli/fixtures/git-changed/workspace/packages/packageA/vitest.config.mjs diff --git a/test/changed/fixtures/workspace/packages/packageB/index.js b/test/cli/fixtures/git-changed/workspace/packages/packageB/index.js similarity index 100% rename from test/changed/fixtures/workspace/packages/packageB/index.js rename to test/cli/fixtures/git-changed/workspace/packages/packageB/index.js diff --git a/test/changed/fixtures/workspace/packages/packageB/index.test.js b/test/cli/fixtures/git-changed/workspace/packages/packageB/index.test.js similarity index 100% rename from test/changed/fixtures/workspace/packages/packageB/index.test.js rename to test/cli/fixtures/git-changed/workspace/packages/packageB/index.test.js diff --git a/test/changed/fixtures/workspace/packages/packageB/vitest.config.mjs b/test/cli/fixtures/git-changed/workspace/packages/packageB/vitest.config.mjs similarity index 100% rename from test/changed/fixtures/workspace/packages/packageB/vitest.config.mjs rename to test/cli/fixtures/git-changed/workspace/packages/packageB/vitest.config.mjs diff --git a/test/changed/fixtures/workspace/vitest.config.mjs b/test/cli/fixtures/git-changed/workspace/vitest.config.mjs similarity index 100% rename from test/changed/fixtures/workspace/vitest.config.mjs rename to test/cli/fixtures/git-changed/workspace/vitest.config.mjs diff --git a/test/changed/fixtures/workspace/vitest.workspace.js b/test/cli/fixtures/git-changed/workspace/vitest.workspace.js similarity index 100% rename from test/changed/fixtures/workspace/vitest.workspace.js rename to test/cli/fixtures/git-changed/workspace/vitest.workspace.js diff --git a/test/global-setup-fail/fixtures/example.test.ts b/test/cli/fixtures/global-setup-fail/example.test.ts similarity index 100% rename from test/global-setup-fail/fixtures/example.test.ts rename to test/cli/fixtures/global-setup-fail/example.test.ts diff --git a/test/global-setup-fail/fixtures/globalSetup/error.js b/test/cli/fixtures/global-setup-fail/globalSetup/error.js similarity index 100% rename from test/global-setup-fail/fixtures/globalSetup/error.js rename to test/cli/fixtures/global-setup-fail/globalSetup/error.js diff --git a/test/global-setup-fail/fixtures/vitest.config.ts b/test/cli/fixtures/global-setup-fail/vitest.config.ts similarity index 100% rename from test/global-setup-fail/fixtures/vitest.config.ts rename to test/cli/fixtures/global-setup-fail/vitest.config.ts diff --git a/test/inspect/fixtures/math.test.ts b/test/cli/fixtures/inspect/math.test.ts similarity index 100% rename from test/inspect/fixtures/math.test.ts rename to test/cli/fixtures/inspect/math.test.ts diff --git a/test/inspect/fixtures/vitest.config.ts b/test/cli/fixtures/inspect/vitest.config.ts similarity index 100% rename from test/inspect/fixtures/vitest.config.ts rename to test/cli/fixtures/inspect/vitest.config.ts diff --git a/test/cli/fixtures/inspect/vitest.config.ts.timestamp-1713887058308-b154731a64b17.mjs b/test/cli/fixtures/inspect/vitest.config.ts.timestamp-1713887058308-b154731a64b17.mjs new file mode 100644 index 000000000000..a1d8ca0448cc --- /dev/null +++ b/test/cli/fixtures/inspect/vitest.config.ts.timestamp-1713887058308-b154731a64b17.mjs @@ -0,0 +1,12 @@ +// fixtures/inspect/vitest.config.ts +import { defineConfig } from "file:///Users/sheremet.mac/Projects/vitest/packages/vitest/dist/config.js"; +var vitest_config_default = defineConfig({ + test: { + include: ["./**.test.ts"], + watch: false + } +}); +export { + vitest_config_default as default +}; +//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiZml4dHVyZXMvaW5zcGVjdC92aXRlc3QuY29uZmlnLnRzIl0sCiAgInNvdXJjZXNDb250ZW50IjogWyJjb25zdCBfX3ZpdGVfaW5qZWN0ZWRfb3JpZ2luYWxfZGlybmFtZSA9IFwiL1VzZXJzL3NoZXJlbWV0Lm1hYy9Qcm9qZWN0cy92aXRlc3QvdGVzdC9jbGkvZml4dHVyZXMvaW5zcGVjdFwiO2NvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9maWxlbmFtZSA9IFwiL1VzZXJzL3NoZXJlbWV0Lm1hYy9Qcm9qZWN0cy92aXRlc3QvdGVzdC9jbGkvZml4dHVyZXMvaW5zcGVjdC92aXRlc3QuY29uZmlnLnRzXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ltcG9ydF9tZXRhX3VybCA9IFwiZmlsZTovLy9Vc2Vycy9zaGVyZW1ldC5tYWMvUHJvamVjdHMvdml0ZXN0L3Rlc3QvY2xpL2ZpeHR1cmVzL2luc3BlY3Qvdml0ZXN0LmNvbmZpZy50c1wiO2ltcG9ydCB7IGRlZmluZUNvbmZpZyB9IGZyb20gJ3ZpdGVzdC9jb25maWcnXG5cbmV4cG9ydCBkZWZhdWx0IGRlZmluZUNvbmZpZyh7XG4gIHRlc3Q6IHtcbiAgICBpbmNsdWRlOiBbJy4vKioudGVzdC50cyddLFxuICAgIHdhdGNoOiBmYWxzZSxcbiAgfSxcbn0pXG4iXSwKICAibWFwcGluZ3MiOiAiO0FBQTZXLFNBQVMsb0JBQW9CO0FBRTFZLElBQU8sd0JBQVEsYUFBYTtBQUFBLEVBQzFCLE1BQU07QUFBQSxJQUNKLFNBQVMsQ0FBQyxjQUFjO0FBQUEsSUFDeEIsT0FBTztBQUFBLEVBQ1Q7QUFDRixDQUFDOyIsCiAgIm5hbWVzIjogW10KfQo= diff --git a/test/network-imports/test/basic.test.ts b/test/cli/fixtures/network-imports/basic.test.ts similarity index 100% rename from test/network-imports/test/basic.test.ts rename to test/cli/fixtures/network-imports/basic.test.ts diff --git a/test/network-imports/public/slash@3.0.0.js b/test/cli/fixtures/network-imports/public/slash@3.0.0.js similarity index 100% rename from test/network-imports/public/slash@3.0.0.js rename to test/cli/fixtures/network-imports/public/slash@3.0.0.js diff --git a/test/public-api/fixtures/custom.spec.ts b/test/cli/fixtures/public-api/custom.spec.ts similarity index 100% rename from test/public-api/fixtures/custom.spec.ts rename to test/cli/fixtures/public-api/custom.spec.ts diff --git a/test/public-api/fixtures/vitest.config.ts b/test/cli/fixtures/public-api/vitest.config.ts similarity index 100% rename from test/public-api/fixtures/vitest.config.ts rename to test/cli/fixtures/public-api/vitest.config.ts diff --git a/test/restricted/src/math.js b/test/cli/fixtures/restricted-fs/src/math.js similarity index 100% rename from test/restricted/src/math.js rename to test/cli/fixtures/restricted-fs/src/math.js diff --git a/test/restricted/tests/basic.spec.js b/test/cli/fixtures/restricted-fs/tests/basic.spec.js similarity index 100% rename from test/restricted/tests/basic.spec.js rename to test/cli/fixtures/restricted-fs/tests/basic.spec.js diff --git a/test/restricted/vitest.config.ts b/test/cli/fixtures/restricted-fs/vitest.config.ts similarity index 100% rename from test/restricted/vitest.config.ts rename to test/cli/fixtures/restricted-fs/vitest.config.ts diff --git a/test/restricted/vitest.setup.js b/test/cli/fixtures/restricted-fs/vitest.setup.js similarity index 100% rename from test/restricted/vitest.setup.js rename to test/cli/fixtures/restricted-fs/vitest.setup.js diff --git a/test/setup/setupFiles/console-setup.ts b/test/cli/fixtures/setup-files/console-setup.ts similarity index 100% rename from test/setup/setupFiles/console-setup.ts rename to test/cli/fixtures/setup-files/console-setup.ts diff --git a/test/setup/setupFiles/empty-setup.ts b/test/cli/fixtures/setup-files/empty-setup.ts similarity index 100% rename from test/setup/setupFiles/empty-setup.ts rename to test/cli/fixtures/setup-files/empty-setup.ts diff --git a/test/setup/tests/fixtures/console.test.ts b/test/cli/fixtures/setup-files/empty.test.ts similarity index 100% rename from test/setup/tests/fixtures/console.test.ts rename to test/cli/fixtures/setup-files/empty.test.ts diff --git a/test/stacktraces/fixtures/add-in-imba.test.imba b/test/cli/fixtures/stacktraces/add-in-imba.test.imba similarity index 100% rename from test/stacktraces/fixtures/add-in-imba.test.imba rename to test/cli/fixtures/stacktraces/add-in-imba.test.imba diff --git a/test/stacktraces/fixtures/add-in-js.test.js b/test/cli/fixtures/stacktraces/add-in-js.test.js similarity index 100% rename from test/stacktraces/fixtures/add-in-js.test.js rename to test/cli/fixtures/stacktraces/add-in-js.test.js diff --git a/test/stacktraces/fixtures/add.test.ts b/test/cli/fixtures/stacktraces/add.test.ts similarity index 100% rename from test/stacktraces/fixtures/add.test.ts rename to test/cli/fixtures/stacktraces/add.test.ts diff --git a/test/stacktraces/fixtures/error-in-deps.test.js b/test/cli/fixtures/stacktraces/error-in-deps.test.js similarity index 100% rename from test/stacktraces/fixtures/error-in-deps.test.js rename to test/cli/fixtures/stacktraces/error-in-deps.test.js diff --git a/test/stacktraces/fixtures/error-with-stack.test.js b/test/cli/fixtures/stacktraces/error-with-stack.test.js similarity index 100% rename from test/stacktraces/fixtures/error-with-stack.test.js rename to test/cli/fixtures/stacktraces/error-with-stack.test.js diff --git a/test/stacktraces/fixtures/foo.js b/test/cli/fixtures/stacktraces/foo.js similarity index 100% rename from test/stacktraces/fixtures/foo.js rename to test/cli/fixtures/stacktraces/foo.js diff --git a/test/stacktraces/fixtures/frame.spec.imba b/test/cli/fixtures/stacktraces/frame.spec.imba similarity index 100% rename from test/stacktraces/fixtures/frame.spec.imba rename to test/cli/fixtures/stacktraces/frame.spec.imba diff --git a/test/stacktraces/fixtures/mocked-global.test.js b/test/cli/fixtures/stacktraces/mocked-global.test.js similarity index 100% rename from test/stacktraces/fixtures/mocked-global.test.js rename to test/cli/fixtures/stacktraces/mocked-global.test.js diff --git a/test/stacktraces/fixtures/mocked-imported.test.js b/test/cli/fixtures/stacktraces/mocked-imported.test.js similarity index 100% rename from test/stacktraces/fixtures/mocked-imported.test.js rename to test/cli/fixtures/stacktraces/mocked-imported.test.js diff --git a/test/stacktraces/fixtures/mocked-imported.test.ts b/test/cli/fixtures/stacktraces/mocked-imported.test.ts similarity index 100% rename from test/stacktraces/fixtures/mocked-imported.test.ts rename to test/cli/fixtures/stacktraces/mocked-imported.test.ts diff --git a/test/stacktraces/fixtures/reset-modules.test.ts b/test/cli/fixtures/stacktraces/reset-modules.test.ts similarity index 100% rename from test/stacktraces/fixtures/reset-modules.test.ts rename to test/cli/fixtures/stacktraces/reset-modules.test.ts diff --git a/test/stacktraces/fixtures/setup.js b/test/cli/fixtures/stacktraces/setup.js similarity index 100% rename from test/stacktraces/fixtures/setup.js rename to test/cli/fixtures/stacktraces/setup.js diff --git a/test/stacktraces/fixtures/utils.ts b/test/cli/fixtures/stacktraces/utils.ts similarity index 100% rename from test/stacktraces/fixtures/utils.ts rename to test/cli/fixtures/stacktraces/utils.ts diff --git a/test/stacktraces/fixtures/vite.config.ts b/test/cli/fixtures/stacktraces/vite.config.ts similarity index 100% rename from test/stacktraces/fixtures/vite.config.ts rename to test/cli/fixtures/stacktraces/vite.config.ts diff --git a/test/run/fixtures/example.test.ts b/test/cli/fixtures/tty/example.test.ts similarity index 100% rename from test/run/fixtures/example.test.ts rename to test/cli/fixtures/tty/example.test.ts diff --git a/test/run/fixtures/example.ts b/test/cli/fixtures/tty/example.ts similarity index 100% rename from test/run/fixtures/example.ts rename to test/cli/fixtures/tty/example.ts diff --git a/test/run/fixtures/math.test.ts b/test/cli/fixtures/tty/math.test.ts similarity index 100% rename from test/run/fixtures/math.test.ts rename to test/cli/fixtures/tty/math.test.ts diff --git a/test/run/fixtures/math.ts b/test/cli/fixtures/tty/math.ts similarity index 100% rename from test/run/fixtures/math.ts rename to test/cli/fixtures/tty/math.ts diff --git a/test/run/fixtures/vitest.config.ts b/test/cli/fixtures/tty/vitest.config.ts similarity index 100% rename from test/run/fixtures/vitest.config.ts rename to test/cli/fixtures/tty/vitest.config.ts diff --git a/test/cli/fixtures/vitest.config.js b/test/cli/fixtures/vitest.config.js new file mode 100644 index 000000000000..9e82d37e0c0c --- /dev/null +++ b/test/cli/fixtures/vitest.config.js @@ -0,0 +1,2 @@ +// an empty config so the main one is not accidentaly inherited by the tests +export default {} diff --git a/test/vm-threads/test/import-external-css-assets.test.js b/test/cli/fixtures/vm-threads/import-external-css-assets.test.js similarity index 80% rename from test/vm-threads/test/import-external-css-assets.test.js rename to test/cli/fixtures/vm-threads/import-external-css-assets.test.js index 433fb773d775..cf99a7c57b81 100644 --- a/test/vm-threads/test/import-external-css-assets.test.js +++ b/test/cli/fixtures/vm-threads/import-external-css-assets.test.js @@ -2,14 +2,14 @@ import { describe, expect, test } from 'vitest' -import '../src/external/css/empty.css' -import '../src/external/css/processed.css' +import './src/external/css/empty.css' +import './src/external/css/processed.css' -import processedModule from '../src/external/css/processed.module.css' +import processedModule from './src/external/css/processed.module.css' -import file1 from '../src/external/assets/file1.png' -import file2 from '../src/external/assets/file2.txt' -import file3 from '../src/external/assets/file3.svg' +import file1 from './src/external/assets/file1.png' +import file2 from './src/external/assets/file2.txt' +import file3 from './src/external/assets/file3.svg' describe('import external css', () => { test('when importing empty.css, element doesn\'t change style', () => { diff --git a/test/vm-threads/test/module.test.js b/test/cli/fixtures/vm-threads/module.test.js similarity index 100% rename from test/vm-threads/test/module.test.js rename to test/cli/fixtures/vm-threads/module.test.js diff --git a/test/vm-threads/test/not-found.test.ts b/test/cli/fixtures/vm-threads/not-found.test.ts similarity index 95% rename from test/vm-threads/test/not-found.test.ts rename to test/cli/fixtures/vm-threads/not-found.test.ts index d9a84d13a4b4..67e537ae05c2 100644 --- a/test/vm-threads/test/not-found.test.ts +++ b/test/cli/fixtures/vm-threads/not-found.test.ts @@ -1,7 +1,7 @@ import { expect, it } from 'vitest' // @ts-expect-error untyped -import * as notFound from '../src/external/not-found.js' +import * as notFound from './src/external/not-found.js' it('path', async () => { await expect(() => notFound.importPath()).rejects.toMatchObject({ diff --git a/test/vm-threads/test/require-cjs.test.js b/test/cli/fixtures/vm-threads/require-cjs.test.js similarity index 70% rename from test/vm-threads/test/require-cjs.test.js rename to test/cli/fixtures/vm-threads/require-cjs.test.js index 905a3bf6e528..7f717e1d0190 100644 --- a/test/vm-threads/test/require-cjs.test.js +++ b/test/cli/fixtures/vm-threads/require-cjs.test.js @@ -1,17 +1,15 @@ import { createRequire } from 'node:module' import { describe, expect, test } from 'vitest' -import { createFile, resolvePath } from '../../test-utils' const require = createRequire(import.meta.url) test('can require if package.json is null', () => { - createFile(resolvePath(import.meta.url, '../src/external/package-null/package-null.json'), 'null') - expect(() => require('../src/external/package-null/package-null.js')).not.toThrow() + expect(() => require('./src/external/package-null/package-null.js')).not.toThrow() }) describe('validating nested defaults in isolation', async () => { - const nestedDefaultExternalCjs = await import('../src/external/export-nested-default-cjs.js') - const moduleDefaultCjs = await import('../src/external/export-default-cjs.js') + const nestedDefaultExternalCjs = await import('./src/external/export-nested-default-cjs.js') + const moduleDefaultCjs = await import('./src/external/export-default-cjs.js') test('nested default should be resolved', () => { expect(nestedDefaultExternalCjs).toHaveProperty('default') diff --git a/test/vm-threads/src/external/assets/file1.png b/test/cli/fixtures/vm-threads/src/external/assets/file1.png similarity index 100% rename from test/vm-threads/src/external/assets/file1.png rename to test/cli/fixtures/vm-threads/src/external/assets/file1.png diff --git a/test/vm-threads/src/external/assets/file2.txt b/test/cli/fixtures/vm-threads/src/external/assets/file2.txt similarity index 100% rename from test/vm-threads/src/external/assets/file2.txt rename to test/cli/fixtures/vm-threads/src/external/assets/file2.txt diff --git a/test/vm-threads/src/external/assets/file3.svg b/test/cli/fixtures/vm-threads/src/external/assets/file3.svg similarity index 100% rename from test/vm-threads/src/external/assets/file3.svg rename to test/cli/fixtures/vm-threads/src/external/assets/file3.svg diff --git a/test/vm-threads/src/external/css/empty.css b/test/cli/fixtures/vm-threads/src/external/css/empty.css similarity index 100% rename from test/vm-threads/src/external/css/empty.css rename to test/cli/fixtures/vm-threads/src/external/css/empty.css diff --git a/test/vm-threads/src/external/css/processed.css b/test/cli/fixtures/vm-threads/src/external/css/processed.css similarity index 100% rename from test/vm-threads/src/external/css/processed.css rename to test/cli/fixtures/vm-threads/src/external/css/processed.css diff --git a/test/vm-threads/src/external/css/processed.module.css b/test/cli/fixtures/vm-threads/src/external/css/processed.module.css similarity index 100% rename from test/vm-threads/src/external/css/processed.module.css rename to test/cli/fixtures/vm-threads/src/external/css/processed.module.css diff --git a/test/vm-threads/src/external/default-cjs.cjs b/test/cli/fixtures/vm-threads/src/external/default-cjs.cjs similarity index 100% rename from test/vm-threads/src/external/default-cjs.cjs rename to test/cli/fixtures/vm-threads/src/external/default-cjs.cjs diff --git a/test/vm-threads/src/external/export-default-cjs.js b/test/cli/fixtures/vm-threads/src/external/export-default-cjs.js similarity index 100% rename from test/vm-threads/src/external/export-default-cjs.js rename to test/cli/fixtures/vm-threads/src/external/export-default-cjs.js diff --git a/test/vm-threads/src/external/export-nested-default-cjs.js b/test/cli/fixtures/vm-threads/src/external/export-nested-default-cjs.js similarity index 100% rename from test/vm-threads/src/external/export-nested-default-cjs.js rename to test/cli/fixtures/vm-threads/src/external/export-nested-default-cjs.js diff --git a/test/vm-threads/src/external/nested-default-cjs.cjs b/test/cli/fixtures/vm-threads/src/external/nested-default-cjs.cjs similarity index 100% rename from test/vm-threads/src/external/nested-default-cjs.cjs rename to test/cli/fixtures/vm-threads/src/external/nested-default-cjs.cjs diff --git a/test/vm-threads/src/external/not-found.js b/test/cli/fixtures/vm-threads/src/external/not-found.js similarity index 100% rename from test/vm-threads/src/external/not-found.js rename to test/cli/fixtures/vm-threads/src/external/not-found.js diff --git a/test/vm-threads/src/external/package-null/package-null.js b/test/cli/fixtures/vm-threads/src/external/package-null/package-null.js similarity index 100% rename from test/vm-threads/src/external/package-null/package-null.js rename to test/cli/fixtures/vm-threads/src/external/package-null/package-null.js diff --git a/test/vm-threads/src/external/package.json b/test/cli/fixtures/vm-threads/src/external/package.json similarity index 100% rename from test/vm-threads/src/external/package.json rename to test/cli/fixtures/vm-threads/src/external/package.json diff --git a/test/vm-threads/src/external/primitive-cjs.cjs b/test/cli/fixtures/vm-threads/src/external/primitive-cjs.cjs similarity index 100% rename from test/vm-threads/src/external/primitive-cjs.cjs rename to test/cli/fixtures/vm-threads/src/external/primitive-cjs.cjs diff --git a/test/vm-threads/vitest.config.ts b/test/cli/fixtures/vm-threads/vitest.config.ts similarity index 100% rename from test/vm-threads/vitest.config.ts rename to test/cli/fixtures/vm-threads/vitest.config.ts diff --git a/test/ws-api/fixtures/server-url/basic.test.ts b/test/cli/fixtures/ws-server-url/basic.test.ts similarity index 100% rename from test/ws-api/fixtures/server-url/basic.test.ts rename to test/cli/fixtures/ws-server-url/basic.test.ts diff --git a/test/ws-api/fixtures/server-url/vitest.config.ts b/test/cli/fixtures/ws-server-url/vitest.config.ts similarity index 100% rename from test/ws-api/fixtures/server-url/vitest.config.ts rename to test/cli/fixtures/ws-server-url/vitest.config.ts diff --git a/test/cli/package.json b/test/cli/package.json index 7ed0d533eebb..5d46c5f7bb81 100644 --- a/test/cli/package.json +++ b/test/cli/package.json @@ -3,10 +3,17 @@ "type": "module", "private": true, "scripts": { - "test": "vitest --exclude fixtures/exclude/**/string.test.ts" + "test": "vitest" }, "devDependencies": { + "@types/debug": "^4.1.12", + "@types/ws": "^8.5.9", + "@vitejs/plugin-basic-ssl": "^1.0.2", + "@vitest/runner": "workspace:^", + "debug": "^4.3.4", + "execa": "^8.0.1", "vite": "latest", - "vitest": "workspace:*" + "vitest": "workspace:*", + "ws": "^8.14.2" } } diff --git a/test/fails/test/__snapshots__/runner.test.ts.snap b/test/cli/test/__snapshots__/fails.test.ts.snap similarity index 100% rename from test/fails/test/__snapshots__/runner.test.ts.snap rename to test/cli/test/__snapshots__/fails.test.ts.snap diff --git a/test/stacktraces/test/__snapshots__/runner.test.ts.snap b/test/cli/test/__snapshots__/stacktraces.test.ts.snap similarity index 100% rename from test/stacktraces/test/__snapshots__/runner.test.ts.snap rename to test/cli/test/__snapshots__/stacktraces.test.ts.snap diff --git a/test/run/test/custom-pool.test.ts b/test/cli/test/custom-pool.test.ts similarity index 83% rename from test/run/test/custom-pool.test.ts rename to test/cli/test/custom-pool.test.ts index e521b6348fba..de3137421466 100644 --- a/test/run/test/custom-pool.test.ts +++ b/test/cli/test/custom-pool.test.ts @@ -3,14 +3,14 @@ import { runVitest } from '../../test-utils' test('can run custom pools with Vitest', async () => { const vitest = await runVitest({ - root: 'pool-custom-fixtures', + root: './fixtures/custom-pool', reporters: ['basic'], }) expect(vitest.stderr).toMatchInlineSnapshot(` "[pool] printing: options are respected [pool] array option [ 1, 2, 3 ] - [pool] running tests for custom-pool-test in /pool-custom-fixtures/tests/custom-not-run.spec.ts + [pool] running tests for custom-pool-test in /fixtures/custom-pool/tests/custom-not-run.spec.ts [pool] custom pool is closed! " `) diff --git a/test/cli/test/dotted-files.test.ts b/test/cli/test/dotted-files.test.ts new file mode 100644 index 000000000000..3500c33a4129 --- /dev/null +++ b/test/cli/test/dotted-files.test.ts @@ -0,0 +1,10 @@ +import { resolve } from 'node:path' +import { expect, it } from 'vitest' +import { runVitestCli } from '../../test-utils' + +it('run tests even though they are inside the .cache directory', async () => { + const { stderr } = await runVitestCli({ + cwd: resolve(process.cwd(), 'fixtures/dotted-files/.cache/projects/test'), + }, '--no-watch') + expect(stderr).toBe('') +}) diff --git a/test/failing/test/expect.test.ts b/test/cli/test/expect-soft.test.ts similarity index 86% rename from test/failing/test/expect.test.ts rename to test/cli/test/expect-soft.test.ts index 852684adf778..7857303d6548 100644 --- a/test/failing/test/expect.test.ts +++ b/test/cli/test/expect-soft.test.ts @@ -1,11 +1,18 @@ import { resolve } from 'node:path' import type { UserConfig } from 'vitest' import { describe, expect, test } from 'vitest' -import { getCurrentTest } from '@vitest/runner' +import { getCurrentTest } from 'vitest/suite' import { runVitest } from '../../test-utils' describe('expect.soft', () => { - const run = (config?: UserConfig) => runVitest({ root: resolve('./fixtures'), include: ['expects/soft.test.ts'], setupFiles: [], testNamePattern: getCurrentTest()?.name, testTimeout: 4000, ...config }, ['soft']) + const run = (config?: UserConfig) => runVitest({ + root: resolve('./fixtures/expect-soft'), + include: ['expects/soft.test.ts'], + setupFiles: [], + testNamePattern: getCurrentTest()?.name, + testTimeout: 4000, + ...config, + }, ['soft']) test('basic', async () => { const { stderr } = await run() @@ -51,4 +58,4 @@ describe('expect.soft', () => { expect.soft(stderr).toContain('AssertionError: expected 4 to be 5') expect.soft(stderr).toContain('4/4') }) -}, 4000) +}) diff --git a/test/fails/test/runner.test.ts b/test/cli/test/fails.test.ts similarity index 96% rename from test/fails/test/runner.test.ts rename to test/cli/test/fails.test.ts index 6486ae9416f9..04ef933d2e75 100644 --- a/test/fails/test/runner.test.ts +++ b/test/cli/test/fails.test.ts @@ -4,7 +4,7 @@ import { expect, it } from 'vitest' import { runVitest } from '../../test-utils' -const root = resolve(__dirname, '../fixtures') +const root = resolve(__dirname, '../fixtures/fails') const files = await fg('**/*.test.ts', { cwd: root, dot: true }) it.each(files)('should fail %s', async (file) => { diff --git a/test/cli/test/git-changed.test.ts b/test/cli/test/git-changed.test.ts new file mode 100644 index 000000000000..e0e43c4d2d76 --- /dev/null +++ b/test/cli/test/git-changed.test.ts @@ -0,0 +1,76 @@ +import { join } from 'node:path' +import { describe, expect, it } from 'vitest' + +import { createFile, editFile, resolvePath, runVitest } from '../../test-utils' + +const fileName = 'fixtures/git-changed/related/rerun.temp' + +// NOTE: if there are any changes in fixtures/git-changed, +// most tests will probably fail + +describe('forceRerunTrigger', () => { + async function run() { + return runVitest({ + root: join(process.cwd(), 'fixtures/git-changed/related'), + include: ['related.test.ts'], + forceRerunTriggers: ['**/rerun.temp/**'], + changed: true, + }) + } + + it('should run the whole test suite if file exists', async () => { + createFile(fileName, '') + const { stdout, stderr } = await run() + expect(stderr).toBe('') + expect(stdout).toContain('1 passed') + expect(stdout).toContain('related.test.ts') + expect(stdout).not.toContain('not-related.test.ts') + }) + + it('should run no tests if file does not exist', async () => { + const { stdout } = await run() + expect(stdout).toContain('No test files found, exiting with code 0') + }) +}) + +it('related correctly runs only related tests', async () => { + const { stdout, stderr } = await runVitest({ + related: 'src/sourceA.ts', + root: './fixtures/git-changed/related', + globals: true, + }) + + expect(stderr).toBe('') + expect(stdout).toContain('3 passed') + expect(stdout).toContain('related.test.ts') + expect(stdout).toContain('deep-related-imports.test.ts') + expect(stdout).toContain('deep-related-exports.test.ts') + expect(stdout).not.toContain('not-related.test.ts') +}) + +it('doesn\'t run any test in a workspace because there are no changes', async () => { + const { stdout } = await runVitest({ + changed: true, + root: './fixtures/git-changed/workspace', + }) + + expect(stdout).toContain('No test files found, exiting with code 0') +}) + +// Fixes #4674 +it('related correctly runs only related tests inside a workspace', async () => { + editFile( + resolvePath(import.meta.url, '../fixtures/git-changed/workspace/packages/packageA/index.js'), + content => `${content}\n`, + ) + + const { stdout, stderr } = await runVitest({ + changed: true, + root: './fixtures/git-changed/workspace', + }) + + expect(stderr).toBe('') + expect(stdout).toContain('1 passed') + expect(stdout).toContain('packageA') + expect(stdout).not.toContain('packageB') +}) diff --git a/test/global-setup-fail/test/runner.test.ts b/test/cli/test/global-setup-fail.test.ts similarity index 85% rename from test/global-setup-fail/test/runner.test.ts rename to test/cli/test/global-setup-fail.test.ts index dcc797007e85..ce05eef57abe 100644 --- a/test/global-setup-fail/test/runner.test.ts +++ b/test/cli/test/global-setup-fail.test.ts @@ -4,7 +4,7 @@ import { expect, it } from 'vitest' import { runVitest } from '../../test-utils' it('should fail', async () => { - const root = resolve(__dirname, '../fixtures') + const root = resolve(__dirname, '../fixtures/global-setup-fail') const { stderr } = await runVitest({ root }) expect(stderr).toBeTruthy() diff --git a/test/inspect/test/inspect.test.ts b/test/cli/test/inspect.test.ts similarity index 93% rename from test/inspect/test/inspect.test.ts rename to test/cli/test/inspect.test.ts index fe5bab6df0a7..5d452f2d954d 100644 --- a/test/inspect/test/inspect.test.ts +++ b/test/cli/test/inspect.test.ts @@ -8,7 +8,13 @@ import { runVitestCli } from '../../test-utils' type Message = Partial> test.skipIf(isWindows)('--inspect-brk stops at test file', async () => { - const { vitest, waitForClose } = await runVitestCli('--root', 'fixtures', '--inspect-brk', '--no-file-parallelism') + const { vitest, waitForClose } = await runVitestCli( + '--root', + 'fixtures/inspect', + '--inspect-brk', + '9232', + '--no-file-parallelism', + ) await vitest.waitForStderr('Debugger listening on ') const url = vitest.stderr.split('\n')[0].replace('Debugger listening on ', '') diff --git a/test/cli/test/network-imports.test.ts b/test/cli/test/network-imports.test.ts new file mode 100644 index 000000000000..5e99e649e6a4 --- /dev/null +++ b/test/cli/test/network-imports.test.ts @@ -0,0 +1,37 @@ +import { expect, it } from 'vitest' +import { runVitest } from '../../test-utils' + +const config = { + poolOptions: { + threads: { + execArgv: ['--experimental-network-imports'], + }, + forks: { + execArgv: ['--experimental-network-imports'], + }, + // not supported? + // FAIL test/basic.test.ts [ test/basic.test.ts ] + // Error: ENOENT: no such file or directory, open 'http://localhost:9602/slash@3.0.0.js' + // ❯ Object.openSync node:fs:596:3 + // ❯ readFileSync node:fs:464:35 + vmThreads: { + execArgv: ['--experimental-network-imports'], + }, + }, + // let vite serve public/slash@3.0.0.js + api: 9602, +} + +it.each([ + 'threads', + 'forks', + // 'vmThreads', +])('importing from network in %s', async (pool) => { + const { stderr, exitCode } = await runVitest({ + ...config, + root: './fixtures/network-imports', + pool, + }) + expect(stderr).toBe('') + expect(exitCode).toBe(0) +}) diff --git a/test/public-api/tests/runner.spec.ts b/test/cli/test/public-api.test.ts similarity index 97% rename from test/public-api/tests/runner.spec.ts rename to test/cli/test/public-api.test.ts index 6af6b1eaa8ce..e27fc29cb4e6 100644 --- a/test/public-api/tests/runner.spec.ts +++ b/test/cli/test/public-api.test.ts @@ -20,7 +20,7 @@ it.each([ const finishedFiles: File[] = [] const collectedFiles: File[] = [] const { ctx, stdout, stderr } = await runVitest({ - root: resolve(__dirname, '..', 'fixtures'), + root: resolve(__dirname, '..', 'fixtures', 'public-api'), include: ['**/*.spec.ts'], reporters: [ 'verbose', diff --git a/test/cli/test/restricted-fs.test.ts b/test/cli/test/restricted-fs.test.ts new file mode 100644 index 000000000000..49d89f75085c --- /dev/null +++ b/test/cli/test/restricted-fs.test.ts @@ -0,0 +1,14 @@ +import { expect, test } from 'vitest' + +import { runVitest } from '../../test-utils' + +test('importing files in restricted fs works correctly', async () => { + const { stderr, exitCode } = await runVitest({ + root: './fixtures/restricted-fs', + }) + + // It would fail if setupFile was not added to allowed fs + // Failed to load url fixtures/restricted-fs/vitest.setup.js + expect(stderr).toBe('') + expect(exitCode).toBe(0) +}) diff --git a/test/cli/test/run-custom-env.test.ts b/test/cli/test/run-custom-env.test.ts new file mode 100644 index 000000000000..a252167159bc --- /dev/null +++ b/test/cli/test/run-custom-env.test.ts @@ -0,0 +1,19 @@ +import { expect, test } from 'vitest' + +import { runVitest } from '../../test-utils' + +test('correctly runs tests if custom env is a file', async () => { + const { stderr, exitCode } = await runVitest({ + root: './fixtures/custom-file-env', + config: false, + environment: '../../custom.ts', + environmentOptions: { + custom: { + option: 'custom-option', + }, + }, + }) + + expect(stderr).toBe('') + expect(exitCode).toBe(0) +}) diff --git a/test/ws-api/tests/server-url.test.ts b/test/cli/test/server-url.test.ts similarity index 75% rename from test/ws-api/tests/server-url.test.ts rename to test/cli/test/server-url.test.ts index 5991ad6f6cc6..db63237b2a28 100644 --- a/test/ws-api/tests/server-url.test.ts +++ b/test/cli/test/server-url.test.ts @@ -4,14 +4,14 @@ import { runVitest } from '../../test-utils' it('api server-url http', async () => { delete process.env.TEST_HTTPS - const { stdout } = await runVitest({ root: 'fixtures/server-url', api: true }) + const { stdout } = await runVitest({ root: './fixtures/ws-server-url', api: true }) expect(stdout).toContain('API started at http://localhost:51204/') expect(stdout).toContain('Test Files 1 passed') }) it('api server-url https', async () => { process.env.TEST_HTTPS = '1' - const { stdout } = await runVitest({ root: 'fixtures/server-url', api: true }) + const { stdout } = await runVitest({ root: './fixtures/ws-server-url', api: true }) expect(stdout).toContain('API started at https://localhost:51204/') expect(stdout).toContain('Test Files 1 passed') }) diff --git a/test/cli/test/setup-files.test.ts b/test/cli/test/setup-files.test.ts new file mode 100644 index 000000000000..2e06e58dfede --- /dev/null +++ b/test/cli/test/setup-files.test.ts @@ -0,0 +1,42 @@ +import { promises as fs } from 'node:fs' +import { describe, expect, it, test } from 'vitest' +import { editFile, runVitest } from '../../test-utils' + +test('print stdout and stderr correctly when called in the setup file', async () => { + const { stdout, stderr } = await runVitest({ + root: 'fixtures/setup-files', + include: ['empty.test.ts'], + setupFiles: ['./console-setup.ts'], + }) + + const filepath = 'console-setup.ts' + expect(stdout).toContain(`stdout | ${filepath}`) + expect(stderr).toContain(`stderr | ${filepath}`) +}) + +describe('setup files with forceRerunTrigger', () => { + const file = './fixtures/setup-files/empty-setup.ts' + + async function run() { + return await runVitest({ + root: 'fixtures/setup-files', + include: ['empty.test.ts'], + setupFiles: ['./empty-setup.ts'], + changed: true, + }) + } + + // Note that this test will fail locally if you have uncommitted changes + it.runIf(process.env.GITHUB_ACTIONS)('should run no tests if setup file is not changed', async () => { + const { stdout } = await run() + expect(stdout).toContain('No test files found, exiting with code 0') + }) + + it('should run the whole test suite if setup file is changed', async () => { + const codes = 'export const a = 1' + editFile(file, () => codes) + await fs.writeFile(file, codes, 'utf-8') + const { stdout } = await run() + expect(stdout).toContain('1 passed') + }) +}) diff --git a/test/stacktraces/test/runner.test.ts b/test/cli/test/stacktraces.test.ts similarity index 86% rename from test/stacktraces/test/runner.test.ts rename to test/cli/test/stacktraces.test.ts index c8a7c4edfca1..ed9776f05c25 100644 --- a/test/stacktraces/test/runner.test.ts +++ b/test/cli/test/stacktraces.test.ts @@ -8,7 +8,7 @@ import { runVitest } from '../../test-utils' process.setMaxListeners(20) describe('stacktraces should respect sourcemaps', async () => { - const root = resolve(__dirname, '../fixtures') + const root = resolve(__dirname, '../fixtures/stacktraces') const files = await fg('*.test.*', { cwd: root }) for (const file of files) { @@ -20,12 +20,12 @@ describe('stacktraces should respect sourcemaps', async () => { const index = lines.findIndex(val => val.includes(`${file}:`)) const msg = lines.slice(index, index + 8).join('\n') expect(msg).toMatchSnapshot(file) - }, 30000) + }) } }) describe('stacktraces should pick error frame if present', async () => { - const root = resolve(__dirname, '../fixtures') + const root = resolve(__dirname, '../fixtures/stacktraces') const files = ['frame.spec.imba'] for (const file of files) { @@ -37,12 +37,12 @@ describe('stacktraces should pick error frame if present', async () => { const index = lines.findIndex(val => val.includes('FAIL')) const msg = lines.slice(index, index + 8).join('\n') expect(msg).toMatchSnapshot(file) - }, 30000) + }) } }) describe('stacktrace should print error frame source file correctly', async () => { - const root = resolve(__dirname, '../fixtures') + const root = resolve(__dirname, '../fixtures/stacktraces') const testFile = resolve(root, './error-in-deps.test.js') it('error-in-deps', async () => { @@ -50,11 +50,11 @@ describe('stacktrace should print error frame source file correctly', async () = // expect to print framestack of foo.js expect(stderr).toMatchSnapshot('error-in-deps') - }, 30000) + }) }) describe('stacktrace filtering', async () => { - const root = resolve(__dirname, '../fixtures') + const root = resolve(__dirname, '../fixtures/stacktraces') const testFile = resolve(root, './error-with-stack.test.js') it('filters stacktraces', async () => { @@ -64,11 +64,11 @@ describe('stacktrace filtering', async () => { }, [testFile]) expect(stderr).toMatchSnapshot('stacktrace-filtering') - }, 30000) + }) }) it('stacktrace in vmThreads', async () => { - const root = resolve(__dirname, '../fixtures') + const root = resolve(__dirname, '../fixtures/stacktraces') const testFile = resolve(root, './error-with-stack.test.js') const { stderr } = await runVitest({ root, @@ -76,4 +76,4 @@ it('stacktrace in vmThreads', async () => { }, [testFile]) expect(stderr).toMatchSnapshot() -}, 3000) +}) diff --git a/test/run/test/tty.test.ts b/test/cli/test/tty.test.ts similarity index 85% rename from test/run/test/tty.test.ts rename to test/cli/test/tty.test.ts index a326b11a431e..4df1a84e4864 100644 --- a/test/run/test/tty.test.ts +++ b/test/cli/test/tty.test.ts @@ -2,7 +2,7 @@ import { expect, test } from 'vitest' import { runVitestCli } from '../../test-utils' test('run mode does not get stuck when TTY', async () => { - const { vitest } = await runVitestCli('--root', 'fixtures') + const { vitest } = await runVitestCli('--root', 'fixtures/tty') await vitest.waitForStdout('✓ example.test.ts') await vitest.waitForStdout('✓ math.test.ts') diff --git a/test/cli/test/vm-threads.test.ts b/test/cli/test/vm-threads.test.ts new file mode 100644 index 000000000000..a92b492964b7 --- /dev/null +++ b/test/cli/test/vm-threads.test.ts @@ -0,0 +1,17 @@ +import { expect, test } from 'vitest' + +import { createFile, resolvePath, runVitest } from '../../test-utils' + +test('importing files in restricted fs works correctly', async () => { + createFile( + resolvePath(import.meta.url, '../fixtures/vm-threads/src/external/package-null/package-null.json'), + 'null', + ) + + const { stderr, exitCode } = await runVitest({ + root: './fixtures/vm-threads', + }) + + expect(stderr).toBe('') + expect(exitCode).toBe(0) +}) diff --git a/test/cli/vitest.config.ts b/test/cli/vitest.config.ts index d3d5f5dc2452..beae1bdd76f5 100644 --- a/test/cli/vitest.config.ts +++ b/test/cli/vitest.config.ts @@ -5,6 +5,11 @@ export default defineConfig({ include: ['test/**.test.ts'], reporters: ['verbose'], testTimeout: 60_000, + poolOptions: { + threads: { + singleThread: true, + }, + }, chaiConfig: { truncateThreshold: 999, }, diff --git a/test/run/allowed-exec-args-fixtures/allowed-exec-argv.test.ts b/test/config/fixtures/allowed-exec-args-fixtures/allowed-exec-argv.test.ts similarity index 80% rename from test/run/allowed-exec-args-fixtures/allowed-exec-argv.test.ts rename to test/config/fixtures/allowed-exec-args-fixtures/allowed-exec-argv.test.ts index 7835748e07eb..3dc66cbbf772 100644 --- a/test/run/allowed-exec-args-fixtures/allowed-exec-argv.test.ts +++ b/test/config/fixtures/allowed-exec-args-fixtures/allowed-exec-argv.test.ts @@ -3,8 +3,6 @@ import { describe, expect, it } from 'vitest' describe('exec-args', async () => { it('should have the correct flags', () => { // flags that should go through - expect(process.execArgv).toContain('--cpu-prof') - expect(process.execArgv).toContain('--cpu-prof-name=cpu.prof') expect(process.execArgv).toContain('--heap-prof') expect(process.execArgv).toContain('--heap-prof-name=heap.prof') expect(process.execArgv).toContain('--diagnostic-dir=/tmp/vitest-diagnostics') diff --git a/test/cwd/vitest.config.ts b/test/config/fixtures/allowed-exec-args-fixtures/vitest.config.ts similarity index 100% rename from test/cwd/vitest.config.ts rename to test/config/fixtures/allowed-exec-args-fixtures/vitest.config.ts diff --git a/test/bail/fixtures/test/first.test.ts b/test/config/fixtures/bail/test/first.test.ts similarity index 100% rename from test/bail/fixtures/test/first.test.ts rename to test/config/fixtures/bail/test/first.test.ts diff --git a/test/bail/fixtures/test/second.test.ts b/test/config/fixtures/bail/test/second.test.ts similarity index 100% rename from test/bail/fixtures/test/second.test.ts rename to test/config/fixtures/bail/test/second.test.ts diff --git a/test/bail/fixtures/vitest.config.ts b/test/config/fixtures/bail/vitest.config.ts similarity index 100% rename from test/bail/fixtures/vitest.config.ts rename to test/config/fixtures/bail/vitest.config.ts diff --git a/test/base/src/index.ts b/test/config/fixtures/base-path/src/index.ts similarity index 100% rename from test/base/src/index.ts rename to test/config/fixtures/base-path/src/index.ts diff --git a/test/config/fixtures/base-path/test/mocking-with-base.spec.ts b/test/config/fixtures/base-path/test/mocking-with-base.spec.ts new file mode 100644 index 000000000000..63890f9007ad --- /dev/null +++ b/test/config/fixtures/base-path/test/mocking-with-base.spec.ts @@ -0,0 +1,14 @@ +import { WorkerGlobalState, expect, test, vi } from 'vitest' +import { foo } from '../src' + +vi.mock('../src', () => ({ + foo: 'baz', +})) + +// @ts-expect-error untyped global +const state = globalThis.__vitest_worker__ as WorkerGlobalState + +test('module is mocked', () => { + expect(foo).toBe('baz') + expect(state.config.base).toBe('/some/base/url/') +}) diff --git a/test/css/src/App.css b/test/config/fixtures/css/App.css similarity index 100% rename from test/css/src/App.css rename to test/config/fixtures/css/App.css diff --git a/test/css/src/App.module.css b/test/config/fixtures/css/App.module.css similarity index 100% rename from test/css/src/App.module.css rename to test/config/fixtures/css/App.module.css diff --git a/test/css/test/default-css.spec.ts b/test/config/fixtures/css/test/default-css.spec.ts similarity index 70% rename from test/css/test/default-css.spec.ts rename to test/config/fixtures/css/test/default-css.spec.ts index d7d4f62eebff..e368b79c54ab 100644 --- a/test/css/test/default-css.spec.ts +++ b/test/config/fixtures/css/test/default-css.spec.ts @@ -1,11 +1,11 @@ import { describe, expect, test } from 'vitest' -import { useRemoveStyles } from './utils' +import { useRemoveStyles } from '../utils' describe('don\'t process css by default', () => { useRemoveStyles() test('doesn\'t apply css', async () => { - await import('../src/App.css') + await import('../App.css') const element = document.createElement('div') element.className = 'main' @@ -19,19 +19,19 @@ describe('don\'t process css by default', () => { }) test('module is not processed', async () => { - const { default: styles } = await import('../src/App.module.css') + const { default: styles } = await import('../App.module.css') // HASH is static, based on the filepath to root - expect(styles.module).toBe('_module_6dc87e') - expect(styles.someRandomValue).toBe('_someRandomValue_6dc87e') + expect(styles.module).toBe('_module_c70a46') + expect(styles.someRandomValue).toBe('_someRandomValue_c70a46') const element = document.createElement('div') - element.className = '_module_6dc87e' + element.className = '_module_c70a46' const computed = window.getComputedStyle(element) expect(computed.display).toBe('block') expect(computed.width).toBe('') expect(element).toMatchInlineSnapshot(`
`) }) diff --git a/test/css/test/non-scope-module.spec.ts b/test/config/fixtures/css/test/non-scope-module.spec.ts similarity index 87% rename from test/css/test/non-scope-module.spec.ts rename to test/config/fixtures/css/test/non-scope-module.spec.ts index 20aae1621771..253850b33513 100644 --- a/test/css/test/non-scope-module.spec.ts +++ b/test/config/fixtures/css/test/non-scope-module.spec.ts @@ -1,7 +1,7 @@ import { expect, test } from 'vitest' test('module is processed', async () => { - const { default: styles } = await import('../src/App.module.css') + const { default: styles } = await import('../App.module.css') expect(styles.module).toBe('module') expect(styles.someRandomValue).toBeUndefined() diff --git a/test/css/test/process-css.spec.ts b/test/config/fixtures/css/test/process-css.spec.ts similarity index 69% rename from test/css/test/process-css.spec.ts rename to test/config/fixtures/css/test/process-css.spec.ts index 9e3130c78a6e..1353130778cc 100644 --- a/test/css/test/process-css.spec.ts +++ b/test/config/fixtures/css/test/process-css.spec.ts @@ -1,11 +1,11 @@ import { describe, expect, test } from 'vitest' -import { useRemoveStyles } from './utils' +import { useRemoveStyles } from '../utils' describe('process only css, not module css', () => { useRemoveStyles() test('apply css', async () => { - await import('../src/App.css') + await import('../App.css') const element = document.createElement('div') element.className = 'main' @@ -19,18 +19,18 @@ describe('process only css, not module css', () => { }) test('module is not processed', async () => { - const { default: styles } = await import('../src/App.module.css') + const { default: styles } = await import('../App.module.css') - expect(styles.module).toBe('_module_6dc87e') - expect(styles.someRandomValue).toBe('_someRandomValue_6dc87e') + expect(styles.module).toBe('_module_c70a46') + expect(styles.someRandomValue).toBe('_someRandomValue_c70a46') const element = document.createElement('div') - element.className = '_module_6dc87e' + element.className = '_module_c70a46' const computed = window.getComputedStyle(element) expect(computed.display).toBe('block') expect(computed.width).toBe('') expect(element).toMatchInlineSnapshot(`
`) }) diff --git a/test/css/test/process-inline.spec.ts b/test/config/fixtures/css/test/process-inline.spec.ts similarity index 73% rename from test/css/test/process-inline.spec.ts rename to test/config/fixtures/css/test/process-inline.spec.ts index 35ff2e7474e4..6d59eace60f8 100644 --- a/test/css/test/process-inline.spec.ts +++ b/test/config/fixtures/css/test/process-inline.spec.ts @@ -1,11 +1,11 @@ import { describe, expect, test } from 'vitest' -import { useRemoveStyles } from './utils' +import { useRemoveStyles } from '../utils' describe('processing inline css', () => { useRemoveStyles() test('doesn\'t apply css', async () => { - await import('../src/App.module.css?inline') + await import('../App.module.css?inline') const element = document.createElement('div') element.className = 'main' @@ -14,7 +14,7 @@ describe('processing inline css', () => { }) test('returns a string', async () => { - const { default: style } = await import('../src/App.module.css?inline') + const { default: style } = await import('../App.module.css?inline') expect(typeof style).toBe('string') }) }) diff --git a/test/css/test/process-module.spec.ts b/test/config/fixtures/css/test/process-module.spec.ts similarity index 71% rename from test/css/test/process-module.spec.ts rename to test/config/fixtures/css/test/process-module.spec.ts index 5510a95f536e..e36a4c3219ef 100644 --- a/test/css/test/process-module.spec.ts +++ b/test/config/fixtures/css/test/process-module.spec.ts @@ -1,11 +1,11 @@ import { describe, expect, test } from 'vitest' -import { useRemoveStyles } from './utils' +import { useRemoveStyles } from '../utils' describe('processing module css', () => { useRemoveStyles() test('doesn\'t apply css', async () => { - await import('../src/App.css') + await import('../App.css') const element = document.createElement('div') element.className = 'main' @@ -14,18 +14,18 @@ describe('processing module css', () => { }) test('module is processed', async () => { - const { default: styles } = await import('../src/App.module.css') + const { default: styles } = await import('../App.module.css') - expect(styles.module).toBe('_module_6dc87e') + expect(styles.module).toBe('_module_c70a46') expect(styles.someRandomValue).toBeUndefined() const element = document.createElement('div') - element.className = '_main_6dc87e _module_6dc87e' + element.className = '_main_c70a46 _module_c70a46' const computed = window.getComputedStyle(element) expect(computed.display, 'css is processed').toBe('flex') expect(computed.width).toBe('100px') expect(element).toMatchInlineSnapshot(`
`) }) diff --git a/test/css/test/scope-module.spec.ts b/test/config/fixtures/css/test/scope-module.spec.ts similarity index 93% rename from test/css/test/scope-module.spec.ts rename to test/config/fixtures/css/test/scope-module.spec.ts index 4dfc786f23d0..0d8a1a2274b0 100644 --- a/test/css/test/scope-module.spec.ts +++ b/test/config/fixtures/css/test/scope-module.spec.ts @@ -1,7 +1,7 @@ import { expect, test } from 'vitest' test('module is processed and scoped', async () => { - const { default: styles } = await import('../src/App.module.css') + const { default: styles } = await import('../App.module.css') expect(styles.module).toMatch(/_module_\w+_\w/) expect(styles.someRandomValue).toBeUndefined() diff --git a/test/css/test/utils.ts b/test/config/fixtures/css/utils.ts similarity index 100% rename from test/css/test/utils.ts rename to test/config/fixtures/css/utils.ts diff --git a/test/cli/fixtures/exclude/math.test.ts b/test/config/fixtures/exclude/math.test.ts similarity index 100% rename from test/cli/fixtures/exclude/math.test.ts rename to test/config/fixtures/exclude/math.test.ts diff --git a/test/cli/fixtures/exclude/math.ts b/test/config/fixtures/exclude/math.ts similarity index 100% rename from test/cli/fixtures/exclude/math.ts rename to test/config/fixtures/exclude/math.ts diff --git a/test/cli/fixtures/exclude/string.test.ts b/test/config/fixtures/exclude/string.test.ts similarity index 100% rename from test/cli/fixtures/exclude/string.test.ts rename to test/config/fixtures/exclude/string.test.ts diff --git a/test/cli/fixtures/exclude/string.ts b/test/config/fixtures/exclude/string.ts similarity index 100% rename from test/cli/fixtures/exclude/string.ts rename to test/config/fixtures/exclude/string.ts diff --git a/test/cli/fixtures/exclude/vitest.exclude.config.ts b/test/config/fixtures/exclude/vitest.exclude.config.ts similarity index 100% rename from test/cli/fixtures/exclude/vitest.exclude.config.ts rename to test/config/fixtures/exclude/vitest.exclude.config.ts diff --git a/test/run/exec-args-fixtures/forks.test.ts b/test/config/fixtures/exec-args-fixtures/forks.test.ts similarity index 100% rename from test/run/exec-args-fixtures/forks.test.ts rename to test/config/fixtures/exec-args-fixtures/forks.test.ts diff --git a/test/run/exec-args-fixtures/threads.test.ts b/test/config/fixtures/exec-args-fixtures/threads.test.ts similarity index 100% rename from test/run/exec-args-fixtures/threads.test.ts rename to test/config/fixtures/exec-args-fixtures/threads.test.ts diff --git a/test/run/exec-args-fixtures/vmThreads.test.ts b/test/config/fixtures/exec-args-fixtures/vmThreads.test.ts similarity index 100% rename from test/run/exec-args-fixtures/vmThreads.test.ts rename to test/config/fixtures/exec-args-fixtures/vmThreads.test.ts diff --git a/test/filters/fixtures-slash/test/basic-foo/a.test.ts b/test/config/fixtures/filters-slash/test/basic-foo/a.test.ts similarity index 100% rename from test/filters/fixtures-slash/test/basic-foo/a.test.ts rename to test/config/fixtures/filters-slash/test/basic-foo/a.test.ts diff --git a/test/filters/fixtures-slash/test/basic.test.ts b/test/config/fixtures/filters-slash/test/basic.test.ts similarity index 100% rename from test/filters/fixtures-slash/test/basic.test.ts rename to test/config/fixtures/filters-slash/test/basic.test.ts diff --git a/test/filters/fixtures-slash/test/basic/a.test.ts b/test/config/fixtures/filters-slash/test/basic/a.test.ts similarity index 100% rename from test/filters/fixtures-slash/test/basic/a.test.ts rename to test/config/fixtures/filters-slash/test/basic/a.test.ts diff --git a/test/filters/fixtures-slash/test/foo-basic/a.test.ts b/test/config/fixtures/filters-slash/test/foo-basic/a.test.ts similarity index 100% rename from test/filters/fixtures-slash/test/foo-basic/a.test.ts rename to test/config/fixtures/filters-slash/test/foo-basic/a.test.ts diff --git a/test/empty-test/vitest.config.ts b/test/config/fixtures/filters-slash/vitest.config.ts similarity index 100% rename from test/empty-test/vitest.config.ts rename to test/config/fixtures/filters-slash/vitest.config.ts diff --git a/test/filters/fixtures/test/filters.test.ts b/test/config/fixtures/filters/test/config.test.ts similarity index 100% rename from test/filters/fixtures/test/filters.test.ts rename to test/config/fixtures/filters/test/config.test.ts diff --git a/test/filters/fixtures/test/dont-run-this.test.ts b/test/config/fixtures/filters/test/dont-run-this.test.ts similarity index 100% rename from test/filters/fixtures/test/dont-run-this.test.ts rename to test/config/fixtures/filters/test/dont-run-this.test.ts diff --git a/test/filters/fixtures/test/example.test.ts b/test/config/fixtures/filters/test/example.test.ts similarity index 100% rename from test/filters/fixtures/test/example.test.ts rename to test/config/fixtures/filters/test/example.test.ts diff --git a/test/env-mixed/fixtures/project/test/happy-dom.test.ts b/test/config/fixtures/mixed-environments/project/test/happy-dom.test.ts similarity index 100% rename from test/env-mixed/fixtures/project/test/happy-dom.test.ts rename to test/config/fixtures/mixed-environments/project/test/happy-dom.test.ts diff --git a/test/env-mixed/fixtures/project/test/jsdom.test.ts b/test/config/fixtures/mixed-environments/project/test/jsdom.test.ts similarity index 100% rename from test/env-mixed/fixtures/project/test/jsdom.test.ts rename to test/config/fixtures/mixed-environments/project/test/jsdom.test.ts diff --git a/test/env-mixed/fixtures/project/test/node.test.ts b/test/config/fixtures/mixed-environments/project/test/node.test.ts similarity index 100% rename from test/env-mixed/fixtures/project/test/node.test.ts rename to test/config/fixtures/mixed-environments/project/test/node.test.ts diff --git a/test/env-mixed/fixtures/project/test/workspace-project.test.ts b/test/config/fixtures/mixed-environments/project/test/workspace-project.test.ts similarity index 100% rename from test/env-mixed/fixtures/project/test/workspace-project.test.ts rename to test/config/fixtures/mixed-environments/project/test/workspace-project.test.ts diff --git a/test/env-mixed/fixtures/vitest.config.ts b/test/config/fixtures/mixed-environments/vitest.config.ts similarity index 100% rename from test/env-mixed/fixtures/vitest.config.ts rename to test/config/fixtures/mixed-environments/vitest.config.ts diff --git a/test/env-mixed/fixtures/vitest.workspace.ts b/test/config/fixtures/mixed-environments/vitest.workspace.ts similarity index 100% rename from test/env-mixed/fixtures/vitest.workspace.ts rename to test/config/fixtures/mixed-environments/vitest.workspace.ts diff --git a/test/run/no-exec-args-fixtures/no-exec-argv.test.ts b/test/config/fixtures/no-exec-args-fixtures/no-exec-argv.test.ts similarity index 100% rename from test/run/no-exec-args-fixtures/no-exec-argv.test.ts rename to test/config/fixtures/no-exec-args-fixtures/no-exec-argv.test.ts diff --git a/test/filters/fixtures-slash/vitest.config.ts b/test/config/fixtures/no-exec-args-fixtures/vitest.config.ts similarity index 100% rename from test/filters/fixtures-slash/vitest.config.ts rename to test/config/fixtures/no-exec-args-fixtures/vitest.config.ts diff --git a/test/fails/fixtures/empty.test.ts b/test/config/fixtures/pass-empty-files/empty.test.ts similarity index 100% rename from test/fails/fixtures/empty.test.ts rename to test/config/fixtures/pass-empty-files/empty.test.ts diff --git a/test/cli/fixtures/project/packages/project_1/base.test.ts b/test/config/fixtures/project/packages/project_1/base.test.ts similarity index 100% rename from test/cli/fixtures/project/packages/project_1/base.test.ts rename to test/config/fixtures/project/packages/project_1/base.test.ts diff --git a/test/cli/fixtures/project/packages/project_2/base.test.ts b/test/config/fixtures/project/packages/project_2/base.test.ts similarity index 100% rename from test/cli/fixtures/project/packages/project_2/base.test.ts rename to test/config/fixtures/project/packages/project_2/base.test.ts diff --git a/test/cli/fixtures/project/packages/space_1/base.test.ts b/test/config/fixtures/project/packages/space_1/base.test.ts similarity index 100% rename from test/cli/fixtures/project/packages/space_1/base.test.ts rename to test/config/fixtures/project/packages/space_1/base.test.ts diff --git a/test/cli/fixtures/project/vitest.config.ts b/test/config/fixtures/project/vitest.config.ts similarity index 100% rename from test/cli/fixtures/project/vitest.config.ts rename to test/config/fixtures/project/vitest.config.ts diff --git a/test/cli/fixtures/project/vitest.workspace.ts b/test/config/fixtures/project/vitest.workspace.ts similarity index 100% rename from test/cli/fixtures/project/vitest.workspace.ts rename to test/config/fixtures/project/vitest.workspace.ts diff --git a/test/shard/test/1.test.js b/test/config/fixtures/shard/test/1.test.js similarity index 100% rename from test/shard/test/1.test.js rename to test/config/fixtures/shard/test/1.test.js diff --git a/test/shard/test/2.test.js b/test/config/fixtures/shard/test/2.test.js similarity index 100% rename from test/shard/test/2.test.js rename to test/config/fixtures/shard/test/2.test.js diff --git a/test/shard/test/3.test.js b/test/config/fixtures/shard/test/3.test.js similarity index 100% rename from test/shard/test/3.test.js rename to test/config/fixtures/shard/test/3.test.js diff --git a/test/config/fixtures/shard/vitest.config.js b/test/config/fixtures/shard/vitest.config.js new file mode 100644 index 000000000000..56004c9f9e06 --- /dev/null +++ b/test/config/fixtures/shard/vitest.config.js @@ -0,0 +1 @@ +export default {} \ No newline at end of file diff --git a/test/config/fixtures/test/vitest.config.js b/test/config/fixtures/test/vitest.config.js new file mode 100644 index 000000000000..b73af3f68d4b --- /dev/null +++ b/test/config/fixtures/test/vitest.config.js @@ -0,0 +1,7 @@ +export default { + test: { + coverage: { + reporter: [], + }, + } +} \ No newline at end of file diff --git a/test/config/fixtures/vitest.config.js b/test/config/fixtures/vitest.config.js new file mode 100644 index 000000000000..c6bcfed02690 --- /dev/null +++ b/test/config/fixtures/vitest.config.js @@ -0,0 +1,3 @@ +export default { + test: {} +} \ No newline at end of file diff --git a/test/config/test/bail.test.ts b/test/config/test/bail.test.ts new file mode 100644 index 000000000000..2fcc995b6f31 --- /dev/null +++ b/test/config/test/bail.test.ts @@ -0,0 +1,57 @@ +import { type UserConfig, expect, test } from 'vitest' + +import { runVitest } from '../../test-utils' + +const configs: UserConfig[] = [] +const pools: UserConfig[] = [{ pool: 'threads' }, { pool: 'forks' }, { pool: 'threads', poolOptions: { threads: { singleThread: true } } }] + +if (process.platform !== 'win32') + pools.push({ browser: { enabled: true, name: 'chromium', provider: 'playwright' } }) + +for (const isolate of [true, false]) { + for (const pool of pools) { + configs.push({ + ...pool, + poolOptions: { + threads: { + ...pool.poolOptions?.threads, + isolate, + }, + forks: { isolate }, + }, + }) + } +} + +for (const config of configs) { + test( + `should bail with "${JSON.stringify(config)}"`, + { + retry: config.browser?.enabled ? 3 : 0, + }, + async () => { + const isParallel + = (config.pool === 'threads' && config.poolOptions?.threads?.singleThread !== true) + || (config.pool === 'forks' && config.poolOptions?.forks?.singleFork !== true) + + // THREADS here means that multiple tests are run parallel + process.env.THREADS = isParallel ? 'true' : 'false' + + const { exitCode, stdout } = await runVitest({ + root: './fixtures/bail', + bail: 1, + ...config, + }) + + expect(exitCode).toBe(1) + expect(stdout).toMatch('✓ test/first.test.ts > 1 - first.test.ts - this should pass') + expect(stdout).toMatch('× test/first.test.ts > 2 - first.test.ts - this should fail') + + // Cancelled tests should not be run + expect(stdout).not.toMatch('test/first.test.ts > 3 - first.test.ts - this should be skipped') + expect(stdout).not.toMatch('test/second.test.ts > 1 - second.test.ts - this should be skipped') + expect(stdout).not.toMatch('test/second.test.ts > 2 - second.test.ts - this should be skipped') + expect(stdout).not.toMatch('test/second.test.ts > 3 - second.test.ts - this should be skipped') + }, + ) +} diff --git a/test/config/test/base-path.test.ts b/test/config/test/base-path.test.ts new file mode 100644 index 000000000000..e83b817b10b6 --- /dev/null +++ b/test/config/test/base-path.test.ts @@ -0,0 +1,12 @@ +import { expect, it } from 'vitest' +import { runVitest } from '../../test-utils' + +it('correctly runs tests with a "base" specified in the config', async () => { + const { stderr, exitCode } = await runVitest({ + root: './fixtures/base-path', + }, [], 'test', { + base: '/some/base/url', + }) + expect(stderr).toBe('') + expect(exitCode).toBe(0) +}) diff --git a/test/config/test/css-configs.test.ts b/test/config/test/css-configs.test.ts new file mode 100644 index 000000000000..95c557d74799 --- /dev/null +++ b/test/config/test/css-configs.test.ts @@ -0,0 +1,21 @@ +import { expect, it } from 'vitest' +import { runVitest } from '../../test-utils' + +it.each([ + ['test/default-css', {}], + ['test/process-css', { include: [/App\.css/] }], + [['test/process-module', 'test/process-inline'], { include: [/App\.module\.css/] }], + ['test/scope-module', { include: [/App\.module\.css/], modules: { classNameStrategy: 'scoped' as const } }], + ['test/non-scope-module', { include: [/App\.module\.css/], modules: { classNameStrategy: 'non-scoped' as const } }], +])('testing %s', async (name, config) => { + const names = Array.isArray(name) ? name : [name] + const { stderr } = await runVitest({ + config: false, + root: './fixtures/css', + css: config, + update: true, + environment: 'jsdom', + }, names) + + expect(stderr).toBe('') +}) diff --git a/test/cli/test/exclude.test.ts b/test/config/test/exclude.test.ts similarity index 100% rename from test/cli/test/exclude.test.ts rename to test/config/test/exclude.test.ts diff --git a/test/run/test/exec-args.test.ts b/test/config/test/exec-args.test.ts similarity index 85% rename from test/run/test/exec-args.test.ts rename to test/config/test/exec-args.test.ts index 6d402bf50af4..ad22f4942172 100644 --- a/test/run/test/exec-args.test.ts +++ b/test/config/test/exec-args.test.ts @@ -17,9 +17,11 @@ test.each([ { pool: 'threads', execArgv: ['--inspect-brk'] }, { pool: 'vmThreads', execArgv: ['--inspect-brk'] }, ] as const)('should pass execArgv to { pool: $pool } ', async ({ pool, execArgv }) => { - const fileToTest = `exec-args-fixtures/${pool}.test.ts` + const root = './fixtures/exec-args-fixtures' + const fileToTest = `${pool}.test.ts` const vitest = await runVitest({ + root, include: [fileToTest], pool, poolOptions: { @@ -30,16 +32,17 @@ test.each([ }) expect(vitest.stdout).toContain(`✓ ${fileToTest}`) + expect(vitest.stderr).toBe('') }) test('should not pass execArgv to workers when not specified in the config', async () => { const { stdout, stderr } = await execa('node', [ '--title', 'this-works-only-on-main-thread', - '../node_modules/vitest/vitest.mjs', + '../../../../node_modules/vitest/vitest.mjs', '--run', ], { - cwd: `${process.cwd()}/no-exec-args-fixtures`, + cwd: `${process.cwd()}/fixtures/no-exec-args-fixtures`, reject: false, env: { VITE_NODE_DEPS_MODULE_DIRECTORIES: '/node_modules/,/packages/', @@ -54,15 +57,13 @@ test('should not pass execArgv to workers when not specified in the config', asy test('should let allowed args pass to workers', async () => { const { stdout, stderr } = await execa('node', [ - '--cpu-prof', '--heap-prof', '--diagnostic-dir=/tmp/vitest-diagnostics', - '--cpu-prof-name=cpu.prof', '--heap-prof-name=heap.prof', - '../node_modules/vitest/vitest.mjs', + '../../../../node_modules/vitest/vitest.mjs', '--run', ], { - cwd: `${process.cwd()}/allowed-exec-args-fixtures`, + cwd: `${process.cwd()}/fixtures/allowed-exec-args-fixtures`, reject: false, env: { VITE_NODE_DEPS_MODULE_DIRECTORIES: '/node_modules/,/packages/', diff --git a/test/config/test/failures.test.ts b/test/config/test/failures.test.ts index cc65dd796e80..85a2973d7f84 100644 --- a/test/config/test/failures.test.ts +++ b/test/config/test/failures.test.ts @@ -6,7 +6,7 @@ import { normalize, resolve } from 'pathe' import * as testUtils from '../../test-utils' function runVitest(config: NonNullable & { shard?: any }) { - return testUtils.runVitest(config, ['fixtures/test/']) + return testUtils.runVitest({ root: './fixtures/test', ...config }, []) } function runVitestCli(...cliArgs: string[]) { @@ -70,6 +70,7 @@ test('v8 coverage provider cannot be used with browser in workspace', async () = test('coverage reportsDirectory cannot be current working directory', async () => { const { stderr } = await runVitest({ + root: undefined, coverage: { enabled: true, reportsDirectory: './', @@ -88,7 +89,7 @@ test('coverage reportsDirectory cannot be current working directory', async () = test('coverage reportsDirectory cannot be root', async () => { const { stderr } = await runVitest({ - root: './fixtures', + root: './fixtures/test', coverage: { enabled: true, reportsDirectory: './', @@ -101,7 +102,7 @@ test('coverage reportsDirectory cannot be root', async () => { }, }) - const directory = normalize(resolve('./fixtures')) + const directory = normalize(resolve('./fixtures/test')) expect(stderr).toMatch(`Error: You cannot set "coverage.reportsDirectory" as ${directory}. Vitest needs to be able to remove this directory before test run`) }) @@ -145,7 +146,7 @@ test('nextTick cannot be mocked inside child_process', async () => { const { stderr } = await runVitest({ pool: 'forks', fakeTimers: { toFake: ['nextTick'] }, - include: ['./fixtures/test/fake-timers.test.ts'], + include: ['./fake-timers.test.ts'], }) expect(stderr).toMatch('Error: vi.useFakeTimers({ toFake: ["nextTick"] }) is not supported in node:child_process. Use --pool=threads if mocking nextTick is required.') diff --git a/test/env-mixed/test/mixed-environments.test.ts b/test/config/test/mixed-environments.test.ts similarity index 96% rename from test/env-mixed/test/mixed-environments.test.ts rename to test/config/test/mixed-environments.test.ts index 695e2da025f6..e7f1d470114d 100644 --- a/test/env-mixed/test/mixed-environments.test.ts +++ b/test/config/test/mixed-environments.test.ts @@ -12,7 +12,7 @@ const configs: UserConfig[] = [ test.each(configs)('should isolate environments when %s', async (config) => { const { stderr, stdout } = await runVitest({ - root: './fixtures', + root: './fixtures/mixed-environments', ...config, }) diff --git a/test/config/test/resolution.test.ts b/test/config/test/override.test.ts similarity index 100% rename from test/config/test/resolution.test.ts rename to test/config/test/override.test.ts diff --git a/test/config/test/pass-empty-files.test.ts b/test/config/test/pass-empty-files.test.ts new file mode 100644 index 000000000000..fb5589604ab8 --- /dev/null +++ b/test/config/test/pass-empty-files.test.ts @@ -0,0 +1,10 @@ +import { expect, it } from 'vitest' +import { runVitest } from '../../test-utils' + +it('vitest doesnt fail when running empty files', async () => { + const { exitCode } = await runVitest({ + root: './fixtures/pass-empty-files', + passWithNoTests: true, + }) + expect(exitCode).toBe(0) +}) diff --git a/test/cli/test/project.test.ts b/test/config/test/project.test.ts similarity index 100% rename from test/cli/test/project.test.ts rename to test/config/test/project.test.ts diff --git a/test/shard/shard-test.test.ts b/test/config/test/shard.test.ts similarity index 90% rename from test/shard/shard-test.test.ts rename to test/config/test/shard.test.ts index 0cd167f7689c..e1d26f8836ce 100644 --- a/test/shard/shard-test.test.ts +++ b/test/config/test/shard.test.ts @@ -1,10 +1,10 @@ import { type UserConfig, expect, test } from 'vitest' import { basename } from 'pathe' -import * as testUtils from '../test-utils' +import * as testUtils from '../../test-utils' function runVitest(config: UserConfig) { - return testUtils.runVitest({ ...config, dir: './test' }) + return testUtils.runVitest({ ...config, root: './fixtures/shard' }) } function parsePaths(stdout: string) { diff --git a/test/filters/test/testname-pattern.test.ts b/test/config/test/testname-pattern.test.ts similarity index 73% rename from test/filters/test/testname-pattern.test.ts rename to test/config/test/testname-pattern.test.ts index eb050efd050d..b89e4afb0d9e 100644 --- a/test/filters/test/testname-pattern.test.ts +++ b/test/config/test/testname-pattern.test.ts @@ -6,18 +6,18 @@ import { runVitest } from '../../test-utils' test.each([ { filter: 'example' }, { filter: '/example' }, - { filter: resolve('./fixtures/test/example') }, + { filter: resolve('./fixtures/filters/test/example') }, ])('match by partial pattern $filter', async ({ filter }) => { - const { stdout } = await runVitest({ root: './fixtures' }, [filter]) + const { stdout } = await runVitest({ root: './fixtures/filters' }, [filter]) expect(stdout).toMatch('✓ test/example.test.ts > this will pass') expect(stdout).toMatch('Test Files 1 passed (1)') - expect(stdout).not.toMatch('test/filters.test.ts') + expect(stdout).not.toMatch('test/config.test.ts') }) test('match by full test file name', async () => { - const filename = resolve('./fixtures/test/example.test.ts') - const { stdout } = await runVitest({ root: './fixtures' }, [filename]) + const filename = resolve('./fixtures/filters/test/example.test.ts') + const { stdout } = await runVitest({ root: './fixtures/filters' }, [filename]) expect(stdout).toMatch('✓ test/example.test.ts > this will pass') expect(stdout).toMatch('Test Files 1 passed (1)') @@ -25,12 +25,12 @@ test('match by full test file name', async () => { }) test('match by pattern that also matches current working directory', async () => { - const filter = 'filters' + const filter = 'config' expect(process.cwd()).toMatch(filter) - const { stdout } = await runVitest({ root: './fixtures' }, [filter]) + const { stdout } = await runVitest({ root: './fixtures/filters' }, [filter]) - expect(stdout).toMatch('✓ test/filters.test.ts > this will pass') + expect(stdout).toMatch('✓ test/config.test.ts > this will pass') expect(stdout).toMatch('Test Files 1 passed (1)') expect(stdout).not.toMatch('test/example.test.ts') }) @@ -40,9 +40,9 @@ test.each([ ['the parent of CWD with slash', join(resolve(process.cwd(), '..'), '/')], ['the parent of a parent of CWD', resolve(process.cwd(), '..', '..')], ])('match by pattern that also matches %s: %s', async (_, filter) => { - const { stdout } = await runVitest({ root: './fixtures' }, [filter]) + const { stdout } = await runVitest({ root: './fixtures/filters' }, [filter]) - expect(stdout).toMatch('✓ test/filters.test.ts > this will pass') + expect(stdout).toMatch('✓ test/config.test.ts > this will pass') expect(stdout).toMatch('× test/dont-run-this.test.ts > this will fail') expect(stdout).toMatch('✓ test/example.test.ts > this will pass') }) @@ -79,7 +79,7 @@ test.each([ ], }, ])('filter with slash $filter', async ({ filter, files }) => { - const { stdout } = await runVitest({ root: './fixtures-slash' }, [filter]) + const { stdout } = await runVitest({ root: './fixtures/filters-slash' }, [filter]) expect(stdout).toMatch(`Test Files ${files.length} passed (${files.length})`) for (const file of files) expect(stdout).toMatch(`✓ ${file}`) diff --git a/test/config/tsconfig.json b/test/config/tsconfig.json index 824464b4032e..321bfb22fb30 100644 --- a/test/config/tsconfig.json +++ b/test/config/tsconfig.json @@ -1,5 +1,9 @@ { "extends": "../../tsconfig.base.json", + "compilerOptions": { + "lib": ["DOM", "ESNext"], + "types": ["vite/client"] + }, "exclude": [ "**/dist/**" ] diff --git a/test/config/vitest.config.ts b/test/config/vitest.config.ts index 3cf9037293b6..305c00017565 100644 --- a/test/config/vitest.config.ts +++ b/test/config/vitest.config.ts @@ -6,6 +6,11 @@ export default defineConfig({ include: ['test/**.test.ts'], reporters: ['verbose'], testTimeout: 60_000, + poolOptions: { + threads: { + singleThread: true, + }, + }, chaiConfig: { truncateThreshold: 999, }, diff --git a/test/vite-node/deps/dep1/esm/index.js b/test/core/deps/dep1/esm/index.js similarity index 100% rename from test/vite-node/deps/dep1/esm/index.js rename to test/core/deps/dep1/esm/index.js diff --git a/test/vite-node/deps/dep1/package.json b/test/core/deps/dep1/package.json similarity index 100% rename from test/vite-node/deps/dep1/package.json rename to test/core/deps/dep1/package.json diff --git a/test/vite-node/deps/dep2/index.js b/test/core/deps/dep2/index.js similarity index 100% rename from test/vite-node/deps/dep2/index.js rename to test/core/deps/dep2/index.js diff --git a/test/vite-node/deps/dep2/package.json b/test/core/deps/dep2/package.json similarity index 100% rename from test/vite-node/deps/dep2/package.json rename to test/core/deps/dep2/package.json diff --git a/test/core/index.html b/test/core/index.html new file mode 100644 index 000000000000..104a6b6d841e --- /dev/null +++ b/test/core/index.html @@ -0,0 +1,11 @@ + + + + + + Core Tests + + + Nothing is rendered + + \ No newline at end of file diff --git a/test/core/package.json b/test/core/package.json index 98fe7d9d0ef9..5dcee839006f 100644 --- a/test/core/package.json +++ b/test/core/package.json @@ -4,16 +4,25 @@ "private": true, "scripts": { "test": "vitest", + "test:threads": "vitest --project threads", + "test:forks": "vitest --project forks", + "test:vmThreads": "vitest --project vmThreads", "dev": "vite", "coverage": "vitest run --coverage" }, "devDependencies": { + "@types/debug": "^4.1.12", "@vitest/expect": "workspace:*", "@vitest/runner": "workspace:*", + "@vitest/test-dep1": "file:./deps/dep1", + "@vitest/test-dep2": "file:./deps/dep2", "@vitest/utils": "workspace:*", + "@vitest/web-worker": "workspace:^", + "debug": "^4.3.4", "strip-ansi": "^7.1.0", "tinyspy": "^1.0.2", "url": "^0.11.0", - "vitest": "workspace:*" + "vitest": "workspace:*", + "vitest-environment-custom": "file:./vitest-environment-custom" } } diff --git a/test/cjs/src/default-function.d.cts b/test/core/src/cjs/default-function.d.ts similarity index 100% rename from test/cjs/src/default-function.d.cts rename to test/core/src/cjs/default-function.d.ts diff --git a/test/cjs/src/default-function.cjs b/test/core/src/cjs/default-function.js similarity index 100% rename from test/cjs/src/default-function.cjs rename to test/core/src/cjs/default-function.js diff --git a/test/cjs/src/prototype.cjs b/test/core/src/cjs/prototype-cjs.js similarity index 100% rename from test/cjs/src/prototype.cjs rename to test/core/src/cjs/prototype-cjs.js diff --git a/test/resolve/pkg-browser/index.d.ts b/test/core/src/external/pkg-browser/index.d.ts similarity index 100% rename from test/resolve/pkg-browser/index.d.ts rename to test/core/src/external/pkg-browser/index.d.ts diff --git a/test/resolve/pkg-browser/package.json b/test/core/src/external/pkg-browser/package.json similarity index 100% rename from test/resolve/pkg-browser/package.json rename to test/core/src/external/pkg-browser/package.json diff --git a/test/resolve/pkg-browser/ssr.js b/test/core/src/external/pkg-browser/ssr.js similarity index 100% rename from test/resolve/pkg-browser/ssr.js rename to test/core/src/external/pkg-browser/ssr.js diff --git a/test/resolve/pkg-browser/web.js b/test/core/src/external/pkg-browser/web.js similarity index 100% rename from test/resolve/pkg-browser/web.js rename to test/core/src/external/pkg-browser/web.js diff --git a/test/resolve/pkg-node/index.d.ts b/test/core/src/external/pkg-node/index.d.ts similarity index 100% rename from test/resolve/pkg-node/index.d.ts rename to test/core/src/external/pkg-node/index.d.ts diff --git a/test/resolve/pkg-node/package.json b/test/core/src/external/pkg-node/package.json similarity index 100% rename from test/resolve/pkg-node/package.json rename to test/core/src/external/pkg-node/package.json diff --git a/test/resolve/pkg-node/ssr.js b/test/core/src/external/pkg-node/ssr.js similarity index 100% rename from test/resolve/pkg-node/ssr.js rename to test/core/src/external/pkg-node/ssr.js diff --git a/test/resolve/pkg-node/web.js b/test/core/src/external/pkg-node/web.js similarity index 100% rename from test/resolve/pkg-node/web.js rename to test/core/src/external/pkg-node/web.js diff --git a/test/import-meta/src/add.ts b/test/core/src/in-source/add.ts similarity index 100% rename from test/import-meta/src/add.ts rename to test/core/src/in-source/add.ts diff --git a/test/import-meta/src/fibonacci.ts b/test/core/src/in-source/fibonacci.ts similarity index 100% rename from test/import-meta/src/fibonacci.ts rename to test/core/src/in-source/fibonacci.ts diff --git a/test/import-meta/src/index.ts b/test/core/src/in-source/index.ts similarity index 100% rename from test/import-meta/src/index.ts rename to test/core/src/in-source/index.ts diff --git a/test/wasm-modules/src/add.wasm b/test/core/src/wasm/add.wasm similarity index 100% rename from test/wasm-modules/src/add.wasm rename to test/core/src/wasm/add.wasm diff --git a/test/wasm-modules/src/wasm-bindgen-no-cyclic/README.md b/test/core/src/wasm/wasm-bindgen-no-cyclic/README.md similarity index 100% rename from test/wasm-modules/src/wasm-bindgen-no-cyclic/README.md rename to test/core/src/wasm/wasm-bindgen-no-cyclic/README.md diff --git a/test/wasm-modules/src/wasm-bindgen-no-cyclic/index.d.ts b/test/core/src/wasm/wasm-bindgen-no-cyclic/index.d.ts similarity index 100% rename from test/wasm-modules/src/wasm-bindgen-no-cyclic/index.d.ts rename to test/core/src/wasm/wasm-bindgen-no-cyclic/index.d.ts diff --git a/test/wasm-modules/src/wasm-bindgen-no-cyclic/index.js b/test/core/src/wasm/wasm-bindgen-no-cyclic/index.js similarity index 100% rename from test/wasm-modules/src/wasm-bindgen-no-cyclic/index.js rename to test/core/src/wasm/wasm-bindgen-no-cyclic/index.js diff --git a/test/wasm-modules/src/wasm-bindgen-no-cyclic/index_bg.js b/test/core/src/wasm/wasm-bindgen-no-cyclic/index_bg.js similarity index 100% rename from test/wasm-modules/src/wasm-bindgen-no-cyclic/index_bg.js rename to test/core/src/wasm/wasm-bindgen-no-cyclic/index_bg.js diff --git a/test/wasm-modules/src/wasm-bindgen-no-cyclic/index_bg.wasm b/test/core/src/wasm/wasm-bindgen-no-cyclic/index_bg.wasm similarity index 100% rename from test/wasm-modules/src/wasm-bindgen-no-cyclic/index_bg.wasm rename to test/core/src/wasm/wasm-bindgen-no-cyclic/index_bg.wasm diff --git a/test/wasm-modules/src/wasm-bindgen-no-cyclic/index_bg.wasm.d.ts b/test/core/src/wasm/wasm-bindgen-no-cyclic/index_bg.wasm.d.ts similarity index 100% rename from test/wasm-modules/src/wasm-bindgen-no-cyclic/index_bg.wasm.d.ts rename to test/core/src/wasm/wasm-bindgen-no-cyclic/index_bg.wasm.d.ts diff --git a/test/wasm-modules/src/wasm-bindgen-no-cyclic/package.json b/test/core/src/wasm/wasm-bindgen-no-cyclic/package.json similarity index 100% rename from test/wasm-modules/src/wasm-bindgen-no-cyclic/package.json rename to test/core/src/wasm/wasm-bindgen-no-cyclic/package.json diff --git a/test/wasm-modules/src/wasm-bindgen/README.md b/test/core/src/wasm/wasm-bindgen/README.md similarity index 100% rename from test/wasm-modules/src/wasm-bindgen/README.md rename to test/core/src/wasm/wasm-bindgen/README.md diff --git a/test/wasm-modules/src/wasm-bindgen/index.js b/test/core/src/wasm/wasm-bindgen/index.js similarity index 100% rename from test/wasm-modules/src/wasm-bindgen/index.js rename to test/core/src/wasm/wasm-bindgen/index.js diff --git a/test/wasm-modules/src/wasm-bindgen/index_bg.js b/test/core/src/wasm/wasm-bindgen/index_bg.js similarity index 100% rename from test/wasm-modules/src/wasm-bindgen/index_bg.js rename to test/core/src/wasm/wasm-bindgen/index_bg.js diff --git a/test/wasm-modules/src/wasm-bindgen/index_bg.wasm b/test/core/src/wasm/wasm-bindgen/index_bg.wasm similarity index 100% rename from test/wasm-modules/src/wasm-bindgen/index_bg.wasm rename to test/core/src/wasm/wasm-bindgen/index_bg.wasm diff --git a/test/wasm-modules/src/wasm-bindgen/package.json b/test/core/src/wasm/wasm-bindgen/package.json similarity index 100% rename from test/wasm-modules/src/wasm-bindgen/package.json rename to test/core/src/wasm/wasm-bindgen/package.json diff --git a/test/web-worker/src/eventListenerWorker.ts b/test/core/src/web-worker/eventListenerWorker.ts similarity index 100% rename from test/web-worker/src/eventListenerWorker.ts rename to test/core/src/web-worker/eventListenerWorker.ts diff --git a/test/web-worker/src/objectWorker.ts b/test/core/src/web-worker/objectWorker.ts similarity index 100% rename from test/web-worker/src/objectWorker.ts rename to test/core/src/web-worker/objectWorker.ts diff --git a/test/web-worker/src/selfWorker.ts b/test/core/src/web-worker/selfWorker.ts similarity index 100% rename from test/web-worker/src/selfWorker.ts rename to test/core/src/web-worker/selfWorker.ts diff --git a/test/web-worker/src/selfWorkerDep.ts b/test/core/src/web-worker/selfWorkerDep.ts similarity index 100% rename from test/web-worker/src/selfWorkerDep.ts rename to test/core/src/web-worker/selfWorkerDep.ts diff --git a/test/web-worker/src/sharedWorker.ts b/test/core/src/web-worker/sharedWorker.ts similarity index 100% rename from test/web-worker/src/sharedWorker.ts rename to test/core/src/web-worker/sharedWorker.ts diff --git a/test/web-worker/src/worker.ts b/test/core/src/web-worker/worker.ts similarity index 100% rename from test/web-worker/src/worker.ts rename to test/core/src/web-worker/worker.ts diff --git a/test/snapshots/test/__snapshots__/shapshots-concurrent-sync.test.ts.snap b/test/core/test/__snapshots__/snapshot-concurrent-sync.test.ts.snap similarity index 93% rename from test/snapshots/test/__snapshots__/shapshots-concurrent-sync.test.ts.snap rename to test/core/test/__snapshots__/snapshot-concurrent-sync.test.ts.snap index aedefeaaf723..131422f935c1 100644 --- a/test/snapshots/test/__snapshots__/shapshots-concurrent-sync.test.ts.snap +++ b/test/core/test/__snapshots__/snapshot-concurrent-sync.test.ts.snap @@ -1,7 +1,7 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`concurrent suite > snapshot 1`] = ` -Object { +{ "foo": "bar", } `; diff --git a/test/snapshots/test/__snapshots__/shapshots-concurrent.test.ts.snap b/test/core/test/__snapshots__/snapshot-concurrent.test.ts.snap similarity index 100% rename from test/snapshots/test/__snapshots__/shapshots-concurrent.test.ts.snap rename to test/core/test/__snapshots__/snapshot-concurrent.test.ts.snap diff --git a/test/core/test/__snapshots__/snapshot.test.ts.snap b/test/core/test/__snapshots__/snapshot.test.ts.snap index f3d33dccdfa1..e61bf4f9e133 100644 --- a/test/core/test/__snapshots__/snapshot.test.ts.snap +++ b/test/core/test/__snapshots__/snapshot.test.ts.snap @@ -7,6 +7,17 @@ exports[`multiline 1`] = ` " `; +exports[`multiline strings 1`] = ` +" +export default function () { + function Foo() { + } + + return Foo; +} +" +`; + exports[`object 1`] = ` { "this": { diff --git a/test/mixed-pools/test/child-specific.child_process.test.ts b/test/core/test/child-specific.child_process.test.ts similarity index 100% rename from test/mixed-pools/test/child-specific.child_process.test.ts rename to test/core/test/child-specific.child_process.test.ts diff --git a/test/vite-node/test/external.test.ts b/test/core/test/dual-package-hazard.test.ts similarity index 100% rename from test/vite-node/test/external.test.ts rename to test/core/test/dual-package-hazard.test.ts diff --git a/test/edge-runtime/test/edge.test.ts b/test/core/test/edge.test.ts similarity index 85% rename from test/edge-runtime/test/edge.test.ts rename to test/core/test/edge.test.ts index 4f00d045b39f..8df48e043550 100644 --- a/test/edge-runtime/test/edge.test.ts +++ b/test/core/test/edge.test.ts @@ -9,7 +9,8 @@ describe('edge runtime api', () => { }) it('allows to run fetch', async () => { - const response = await fetch('https://github.com/robots.txt') + // 3023 is the default port + const response = await fetch('http://localhost:3023/') expect(response.status).toEqual(200) }) diff --git a/test/env-glob/test/dom/overrides.spec.ts b/test/core/test/env-glob-dom/env-glob.overrides.spec.ts similarity index 100% rename from test/env-glob/test/dom/overrides.spec.ts rename to test/core/test/env-glob-dom/env-glob.overrides.spec.ts diff --git a/test/env-glob/test/dom/base.spec.ts b/test/core/test/env-glob-dom/env-glob.spec.ts similarity index 100% rename from test/env-glob/test/dom/base.spec.ts rename to test/core/test/env-glob-dom/env-glob.spec.ts diff --git a/test/env-glob/test/base.dom.test.ts b/test/core/test/env-glob.dom.test.ts similarity index 100% rename from test/env-glob/test/base.dom.test.ts rename to test/core/test/env-glob.dom.test.ts diff --git a/test/env-glob/test/base.test.ts b/test/core/test/env-glob.test.ts similarity index 100% rename from test/env-glob/test/base.test.ts rename to test/core/test/env-glob.test.ts diff --git a/test/core/test/env.test.ts b/test/core/test/env.test.ts index 71c4eb432b64..10c5436cae1b 100644 --- a/test/core/test/env.test.ts +++ b/test/core/test/env.test.ts @@ -73,3 +73,9 @@ test('PROD, DEV, SSR should be boolean', () => { import.meta.env.SSR = false expect(import.meta.env.SSR).toEqual(false) }) + +test.runIf(process.platform === 'win32')('main process env variables are case insentive', () => { + expect(process.env.PROGRAMFILES).toBeDefined() + expect(process.env['PROGRAMFILES(X86)']).toBeDefined() + expect(process.env['ProgramFiles(x86)']).toBeDefined() +}) diff --git a/test/env-custom/test/base.test.ts b/test/core/test/environments/custom-env.test.ts similarity index 89% rename from test/env-custom/test/base.test.ts rename to test/core/test/environments/custom-env.test.ts index aa6443e33e02..9029e6465b9d 100644 --- a/test/env-custom/test/base.test.ts +++ b/test/core/test/environments/custom-env.test.ts @@ -1,3 +1,5 @@ +// @vitest-environment custom + import { expect, test } from 'vitest' test('custom env is defined', () => { diff --git a/test/snapshots/test/fixtures/basic/input.json b/test/core/test/fixtures/snapshots/basic/input.json similarity index 100% rename from test/snapshots/test/fixtures/basic/input.json rename to test/core/test/fixtures/snapshots/basic/input.json diff --git a/test/snapshots/test/fixtures/basic/output.css b/test/core/test/fixtures/snapshots/basic/output.css similarity index 100% rename from test/snapshots/test/fixtures/basic/output.css rename to test/core/test/fixtures/snapshots/basic/output.css diff --git a/test/snapshots/test/fixtures/multiple/input.json b/test/core/test/fixtures/snapshots/multiple/input.json similarity index 100% rename from test/snapshots/test/fixtures/multiple/input.json rename to test/core/test/fixtures/snapshots/multiple/input.json diff --git a/test/snapshots/test/fixtures/multiple/output.css b/test/core/test/fixtures/snapshots/multiple/output.css similarity index 100% rename from test/snapshots/test/fixtures/multiple/output.css rename to test/core/test/fixtures/snapshots/multiple/output.css diff --git a/test/core/test/module.test.ts b/test/core/test/module.test.ts index 08986d544701..88fb306a8354 100644 --- a/test/core/test/module.test.ts +++ b/test/core/test/module.test.ts @@ -12,6 +12,9 @@ import primitiveCjs, { a as primitiveA } from '../src/cjs/primitive-cjs' // @ts-expect-error is not typed with imports import * as primitiveAll from '../src/cjs/primitive-cjs' +// @ts-expect-error is not typed with imports +import * as prototypeCjs from '../src/cjs/prototype-cjs' + // @ts-expect-error is not typed with imports import * as arrayCjs from '../src/cjs/array-cjs' @@ -21,6 +24,8 @@ import * as classCjs from '../src/cjs/class-cjs' // @ts-expect-error is not typed with imports import * as nestedDefaultCjs from '../src/cjs/nested-default-cjs' +import format from '../src/cjs/default-function' + // @ts-expect-error is not typed with imports import * as nestedDefaultExternalCjs from '../src/external/nested-default-cjs' @@ -29,6 +34,10 @@ import * as moduleDefaultCjs from '../src/external/default-cjs' // @ts-expect-error is not typed with imports import * as internalEsm from '../src/esm/internal-esm.mjs' + +// @ts-expect-error is not typed with imports +import * as prototypeEsm from '../src/esm/esm.js' + import c, { d } from '../src/module-esm' import * as timeout from '../src/timeout' @@ -99,3 +108,27 @@ it('should work when using esm module', () => { it('exports all from native ESM module', () => { expect(internalEsm).toHaveProperty('restoreAll') }) + +it('cjs has object prototype', () => { + expect(prototypeCjs.getPrototype()).toBe(Object.prototype) + expect(() => prototypeCjs.test()).not.toThrow() + expect(prototypeCjs.test()).toBe(true) +}) + +it('esm prototype is null', () => { + expect(Object.getPrototypeOf(prototypeEsm)).toBe(null) + expect({}.hasOwnProperty).toBeTypeOf('function') + + expect(prototypeEsm.hasOwnProperty).toBeTypeOf('undefined') +}) + +describe('correctly puts default on default', () => { + it('works on default function', () => { + expect(format()).toBe('') + }) + + it('works on nested default function', () => { + // @ts-expect-error types defined only default + expect(format.default).toBeUndefined() + }) +}) diff --git a/test/resolve/test/ssr.test.ts b/test/core/test/resolve-ssr.test.ts similarity index 66% rename from test/resolve/test/ssr.test.ts rename to test/core/test/resolve-ssr.test.ts index 0f6f23150dd5..8f6757907fd3 100644 --- a/test/resolve/test/ssr.test.ts +++ b/test/core/test/resolve-ssr.test.ts @@ -1,6 +1,8 @@ +// @vitest-environment node + import { expect, test } from 'vitest' -import pkgNode from '../pkg-node' -import pkgBrowser from '../pkg-browser' +import pkgNode from '../src/external/pkg-node' +import pkgBrowser from '../src/external/pkg-browser' test('[ssr] resolves to ssr, when node is first in conditions', () => { expect(pkgNode).toBe('ssr') diff --git a/test/resolve/test/web.test.ts b/test/core/test/resolve-web.test.ts similarity index 65% rename from test/resolve/test/web.test.ts rename to test/core/test/resolve-web.test.ts index 956b15636ec9..0850f6272aa2 100644 --- a/test/resolve/test/web.test.ts +++ b/test/core/test/resolve-web.test.ts @@ -1,6 +1,8 @@ +// @vitest-environment happy-dom + import { expect, test } from 'vitest' -import pkgNode from '../pkg-node' -import pkgBrowser from '../pkg-browser' +import pkgNode from '../src/external/pkg-node' +import pkgBrowser from '../src/external/pkg-browser' test('[web] resolves to ssr, when node is first in conditions', () => { expect(pkgNode).toBe('ssr') diff --git a/test/snapshots/test/snapshots-async.test.ts b/test/core/test/snapshot-async.test.ts similarity index 100% rename from test/snapshots/test/snapshots-async.test.ts rename to test/core/test/snapshot-async.test.ts diff --git a/test/snapshots/test/shapshots-concurrent-sync.test.ts b/test/core/test/snapshot-concurrent-sync.test.ts similarity index 100% rename from test/snapshots/test/shapshots-concurrent-sync.test.ts rename to test/core/test/snapshot-concurrent-sync.test.ts diff --git a/test/snapshots/test/shapshots-concurrent.test.ts b/test/core/test/snapshot-concurrent.test.ts similarity index 100% rename from test/snapshots/test/shapshots-concurrent.test.ts rename to test/core/test/snapshot-concurrent.test.ts diff --git a/test/snapshots/test/shapshots-file.test.ts b/test/core/test/snapshot-file.test.ts similarity index 79% rename from test/snapshots/test/shapshots-file.test.ts rename to test/core/test/snapshot-file.test.ts index dafb3c69ccd3..c1eb01cf77fb 100644 --- a/test/snapshots/test/shapshots-file.test.ts +++ b/test/core/test/snapshot-file.test.ts @@ -1,4 +1,4 @@ -import { expect, test } from 'vitest' +import { describe, expect, test } from 'vitest' function objectToCSS(selector: string, obj: Record) { const body = Object.entries(obj) @@ -8,7 +8,7 @@ function objectToCSS(selector: string, obj: Record) { } describe('snapshots', () => { - const files = import.meta.glob('./fixtures/**/input.json', { as: 'raw' }) + const files = import.meta.glob('./fixtures/snapshots/**/input.json', { as: 'raw' }) for (const [path, file] of Object.entries(files)) { test(path, async () => { diff --git a/test/core/test/snapshot.test.ts b/test/core/test/snapshot.test.ts index 044a4624e1ee..5f763dbe5319 100644 --- a/test/core/test/snapshot.test.ts +++ b/test/core/test/snapshot.test.ts @@ -134,3 +134,30 @@ test('renders inline mock snapshot', () => { } `) }) + +function println() { + const message = ` +export default function () { + function Foo() { + } + + return Foo; +} +` + return message +} + +test('multiline strings ', () => { + expect(println()).toMatchSnapshot() +}) + +test('updateInlineSnapshot should not remove end whitespace', () => { + // issue #922 + expect(` +my string +`).toMatchInlineSnapshot(` + " + my string + " +`) +}) diff --git a/test/mixed-pools/test/threads-specific.threads.test.ts b/test/core/test/threads-specific.threads.test.ts similarity index 100% rename from test/mixed-pools/test/threads-specific.threads.test.ts rename to test/core/test/threads-specific.threads.test.ts diff --git a/test/utils/test/display.spec.ts b/test/core/test/utils-display.spec.ts similarity index 100% rename from test/utils/test/display.spec.ts rename to test/core/test/utils-display.spec.ts diff --git a/test/wasm-modules/test/basic.test.ts b/test/core/test/wasm.test.ts similarity index 89% rename from test/wasm-modules/test/basic.test.ts rename to test/core/test/wasm.test.ts index 25a6984f7539..2bf37c80f306 100644 --- a/test/wasm-modules/test/basic.test.ts +++ b/test/core/test/wasm.test.ts @@ -3,9 +3,9 @@ import { resolve } from 'node:path' import { expect, test, vi } from 'vitest' // @ts-expect-error wasm is not typed -import { add } from '../src/add.wasm' +import { add } from '../src/wasm/add.wasm' -const wasmFileBuffer = readFileSync(resolve(__dirname, '../src/add.wasm')) +const wasmFileBuffer = readFileSync(resolve(__dirname, '../src/wasm/add.wasm')) test('supports native wasm imports', () => { expect(add(1, 2)).toBe(3) @@ -28,7 +28,7 @@ test('supports native wasm imports', () => { test('supports dynamic wasm imports', async () => { // @ts-expect-error wasm is not typed - const { add: dynamicAdd } = await import('../src/add.wasm') + const { add: dynamicAdd } = await import('../src/wasm/add.wasm') expect(dynamicAdd(1, 2)).toBe(3) }) @@ -73,7 +73,7 @@ test('supports wasm/js cyclic import (old wasm-bindgen output)', async () => { globalThis.alert = vi.fn() // @ts-expect-error not typed - const { greet } = await import('../src/wasm-bindgen/index.js') + const { greet } = await import('../src/wasm/wasm-bindgen/index.js') greet('World') expect(globalThis.alert).toHaveBeenCalledWith('Hello, World!') @@ -82,7 +82,7 @@ test('supports wasm/js cyclic import (old wasm-bindgen output)', async () => { test('supports wasm-bindgen', async () => { globalThis.alert = vi.fn() - const { greet } = await import('../src/wasm-bindgen-no-cyclic/index.js') + const { greet } = await import('../src/wasm/wasm-bindgen-no-cyclic/index.js') greet('No Cyclic') expect(globalThis.alert).toHaveBeenCalledWith('Hello, No Cyclic!') diff --git a/test/web-worker/test/jsdom.test.ts b/test/core/test/web-worker-jsdom.test.ts similarity index 85% rename from test/web-worker/test/jsdom.test.ts rename to test/core/test/web-worker-jsdom.test.ts index cd2427691fa7..c5f5b00c1cdb 100644 --- a/test/web-worker/test/jsdom.test.ts +++ b/test/core/test/web-worker-jsdom.test.ts @@ -1,10 +1,12 @@ // @vitest-environment jsdom +import '@vitest/web-worker' + import { expect, it } from 'vitest' it('worker with invalid url throws an error', async () => { const url = import.meta.url - const worker = new Worker(new URL('../src/workerInvalid-path.ts', url)) + const worker = new Worker(new URL('../src/web-worker/workerInvalid-path.ts', url)) const event = await new Promise((resolve) => { worker.onerror = (e) => { resolve(e) @@ -19,7 +21,7 @@ it('worker with invalid url throws an error', async () => { it('throws an error on invalid path', async () => { expect(SharedWorker).toBeDefined() - const worker = new SharedWorker('./some-invalid-path') + const worker = new SharedWorker('./web-worker/some-invalid-path') const event = await new Promise((resolve) => { worker.onerror = (e) => { resolve(e) diff --git a/test/core/test/web-worker-node.test.ts b/test/core/test/web-worker-node.test.ts new file mode 100644 index 000000000000..03b498c94852 --- /dev/null +++ b/test/core/test/web-worker-node.test.ts @@ -0,0 +1,271 @@ +// @vitest-environment node + +import '@vitest/web-worker' + +import { version } from 'node:process' +import { beforeEach, describe, expect, it, vi } from 'vitest' + +import MyWorker from '../src/web-worker/worker?worker' +import MyObjectWorker from '../src/web-worker/objectWorker?worker' +import MyEventListenerWorker from '../src/web-worker/eventListenerWorker?worker' +import MySelfWorker from '../src/web-worker/selfWorker?worker' +import MySharedWorker from '../src/web-worker/sharedWorker?sharedworker' + +const major = Number(version.split('.')[0].slice(1)) + +describe.runIf(major >= 17)('when node supports structuredClone', () => { + it('uses native structure clone', () => { + expect.assertions(4) + + expect(structuredClone).toBeDefined() + + const worker = new MyObjectWorker() + const buffer = new ArrayBuffer(1) + const obj = { hello: 'world', buffer } + worker.postMessage(obj, [buffer]) + + return new Promise((resolve, reject) => { + worker.onmessage = (e) => { + try { + expect(e).toBeInstanceOf(MessageEvent) + expect(e.data, 'doesn\'t keep reference').not.toBe(obj) + expect(e.data, 'shape is equal').toEqual(obj) + resolve() + } + catch (err) { + reject(err) + } + finally { + worker.terminate() + } + } + }) + }) + + it('throws error, if passing down unserializable data', () => { + expect.assertions(4) + + expect(structuredClone).toBeDefined() + + const worker = new MyObjectWorker() + const obj = { hello: 'world', name() {} } + worker.postMessage(obj) + + return new Promise((resolve, reject) => { + worker.onmessageerror = (e) => { + try { + expect(e.type).toBe('messageerror') + expect(e).toBeInstanceOf(MessageEvent) + expect(e.data.message).toContain( + 'could not be cloned.', + ) + resolve() + } + catch (err) { + reject(err) + } + } + }) + }) +}) + +describe('when passing down custom clone', () => { + const { warn } = console + + beforeEach(() => { + console.warn = warn + process.env.VITEST_WEB_WORKER_CLONE = undefined + }) + + it('uses ponyfill clone', () => { + expect.assertions(4) + + console.warn = vi.fn() + process.env.VITEST_WEB_WORKER_CLONE = 'ponyfill' + + const worker = new MyObjectWorker() + const buffer = new ArrayBuffer(1) + const obj = { hello: 'world' } + worker.postMessage(obj, [buffer]) + + return new Promise((resolve, reject) => { + worker.onmessageerror = (e) => { + reject(e.data) + } + worker.onmessage = (e) => { + try { + expect(e).toBeInstanceOf(MessageEvent) + expect(e.data, 'doesn\'t keep reference').not.toBe(obj) + expect(e.data, 'shape is not equal, don\'t transfer buffer').toEqual({ hello: 'world' }) + expect(console.warn).toBeCalledWith(expect.stringContaining('[@vitest/web-worker] `structuredClone` is not supported in this')) + resolve() + } + catch (err) { + reject(err) + } + finally { + worker.terminate() + } + } + }) + }) + + it('doesn\'t clone, if asked to', () => { + expect.assertions(3) + + console.warn = vi.fn() + process.env.VITEST_WEB_WORKER_CLONE = 'none' + + const worker = new MyObjectWorker() + const buffer = new ArrayBuffer(1) + const obj = { hello: 'world', buffer } + worker.postMessage(obj, [buffer]) + + return new Promise((resolve, reject) => { + worker.onmessageerror = (e) => { + reject(e.data) + } + worker.onmessage = (e) => { + try { + expect(e).toBeInstanceOf(MessageEvent) + expect(e.data, 'keeps reference').toBe(obj) + expect(console.warn).not.toHaveBeenCalled() + resolve() + } + catch (err) { + reject(err) + } + finally { + worker.terminate() + } + } + }) + }) +}) + +function sleep(time: number) { + return new Promise(resolve => setTimeout(resolve, time)) +} + +function testWorker(worker: Worker) { + return new Promise((resolve) => { + worker.postMessage('hello') + worker.onmessage = (e) => { + expect(e.data).toBe('hello world') + + resolve() + } + }) +} + +function testSelfWorker(worker: Worker) { + return new Promise((resolve) => { + worker.onmessage = (e) => { + resolve(e.data) + } + }) +} + +it('worker exists', async () => { + expect(Worker).toBeDefined() +}) + +it('simple worker', async () => { + expect.assertions(1) + + await testWorker(new MyWorker()) +}) + +it('event listener worker', async () => { + expect.assertions(1) + + await testWorker(new MyEventListenerWorker()) +}) + +it('can test workers several times', async () => { + expect.assertions(1) + + await testWorker(new MyWorker()) +}) + +it('worker with url', async () => { + expect.assertions(1) + const url = import.meta.url + + await testWorker(new Worker(new URL('../src/web-worker/worker.ts', url))) +}) + +it('self injected into worker and its deps should be equal', async () => { + expect.assertions(4) + expect(await testSelfWorker(new MySelfWorker())).toBeTruthy() + // wait for clear worker mod cache + await sleep(0) + expect(await testSelfWorker(new MySelfWorker())).toBeTruthy() + + await sleep(0) + + expect(await testSelfWorker(new Worker(new URL('../src/web-worker/selfWorker.ts', import.meta.url)))).toBeTruthy() + // wait for clear worker mod cache + await sleep(0) + expect(await testSelfWorker(new Worker(new URL('../src/web-worker/selfWorker.ts', import.meta.url)))).toBeTruthy() +}) + +it('throws syntax error if no arguments are provided', () => { + const worker = new MyWorker() + + // @ts-expect-error requires at least one argument + expect(() => worker.postMessage()).toThrowError(SyntaxError) + expect(() => worker.postMessage(undefined)).not.toThrowError() + expect(() => worker.postMessage(null)).not.toThrowError() +}) + +function sendEventMessage(worker: SharedWorker, msg: any) { + worker.port.postMessage(msg) + return new Promise((resolve) => { + worker.port.addEventListener('message', function onmessage(e) { + worker.port.removeEventListener('message', onmessage) + resolve(e.data as string) + }) + }) +} + +function sendOnMessage(worker: SharedWorker, msg: any) { + worker.port.postMessage(msg) + return new Promise((resolve) => { + worker.port.onmessage = function onmessage(e) { + worker.port.onmessage = null + resolve(e.data as string) + } + }) +} + +it('vite shared worker works', async () => { + expect(MySharedWorker).toBeDefined() + expect(SharedWorker).toBeDefined() + const worker = new MySharedWorker() + expect(worker).toBeInstanceOf(SharedWorker) + + await expect(sendEventMessage(worker, 'event')).resolves.toBe('event') + await expect(sendOnMessage(worker, 'event')).resolves.toBe('event') +}) + +it('shared worker with path works', async () => { + expect(SharedWorker).toBeDefined() + const worker = new SharedWorker(new URL('../src/web-worker/sharedWorker.ts', import.meta.url)) + expect(worker).toBeTruthy() + + await expect(sendEventMessage(worker, 'event')).resolves.toBe('event') + await expect(sendOnMessage(worker, 'event')).resolves.toBe('event') +}) + +it('doesn\'t trigger events, if closed', async () => { + const worker = new MySharedWorker() + worker.port.close() + await new Promise((resolve) => { + worker.port.addEventListener('message', () => { + expect.fail('should not trigger message') + }) + worker.port.postMessage('event') + setTimeout(resolve, 100) + }) +}) diff --git a/test/core/vite.config.ts b/test/core/vite.config.ts index ff8ff6b20be2..7686c8a0675e 100644 --- a/test/core/vite.config.ts +++ b/test/core/vite.config.ts @@ -36,6 +36,7 @@ export default defineConfig({ '__NULL__': null, '__ZERO__': 0, '__FALSE__': false, + 'import.meta.vitest': false, }, resolve: { alias: [ @@ -48,10 +49,16 @@ export default defineConfig({ port: 3022, }, test: { + api: { + port: 3023, + }, name: 'core', + includeSource: [ + 'src/in-source/*.ts', + ], exclude: ['**/fixtures/**', ...defaultExclude], slowTestThreshold: 1000, - testTimeout: 2000, + testTimeout: process.env.CI ? 10_000 : 5_000, setupFiles: [ './test/setup.ts', ], @@ -60,6 +67,27 @@ export default defineConfig({ provider: 'istanbul', reporter: ['text', 'html'], }, + environmentMatchGlobs: [ + ['**/*.dom.test.ts', 'happy-dom'], + ['test/env-glob-dom/**', 'jsdom'], + ], + poolMatchGlobs: [ + ['**/test/*.child_process.test.ts', 'forks'], + ['**/test/*.threads.test.ts', 'threads'], + ], + environmentOptions: { + custom: { + option: 'config-option', + }, + }, + poolOptions: { + threads: { + execArgv: ['--experimental-wasm-modules'], + }, + forks: { + execArgv: ['--experimental-wasm-modules'], + }, + }, env: { CUSTOM_ENV: 'foo', }, @@ -71,12 +99,20 @@ export default defineConfig({ sequence: { seed: 101, }, + allowOnly: true, deps: { moduleDirectories: ['node_modules', 'projects', 'packages'], }, server: { deps: { - external: ['tinyspy', /src\/external/, /esm\/esm/], + external: [ + 'tinyspy', + /src\/external/, + /esm\/esm/, + /packages\/web-worker/, + /\.wasm$/, + /\/wasm-bindgen-no-cyclic\/index_bg.js/, + ], inline: ['inline-lib'], }, }, @@ -88,5 +124,11 @@ export default defineConfig({ customResolver: () => resolve(__dirname, 'src', 'aliased-mod.ts'), }, ], + onConsoleLog(log) { + if (log.includes('Failed to load url') && log.includes('web-worker')) + return false + if (log.includes('Importing WebAssembly ')) + return false + }, }, }) diff --git a/test/env-custom/vitest-environment-custom/index.ts b/test/core/vitest-environment-custom/index.ts similarity index 100% rename from test/env-custom/vitest-environment-custom/index.ts rename to test/core/vitest-environment-custom/index.ts diff --git a/test/env-custom/vitest-environment-custom/package.json b/test/core/vitest-environment-custom/package.json similarity index 100% rename from test/env-custom/vitest-environment-custom/package.json rename to test/core/vitest-environment-custom/package.json diff --git a/test/core/vitest.workspace.ts b/test/core/vitest.workspace.ts new file mode 100644 index 000000000000..9314d2ee507d --- /dev/null +++ b/test/core/vitest.workspace.ts @@ -0,0 +1,18 @@ +import type { Pool } from 'vitest' +import { defineWorkspace } from 'vitest/config' + +function project(pool: Pool) { + return { + extends: './vite.config.ts', + test: { + name: pool, + pool, + }, + } +} + +export default defineWorkspace([ + project('threads'), + project('forks'), + project('vmThreads'), +]) diff --git a/test/css/package.json b/test/css/package.json deleted file mode 100644 index c9d1f2ebcf71..000000000000 --- a/test/css/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "@vitest/test-css", - "type": "module", - "private": true, - "scripts": { - "test": "node testing.mjs", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "jsdom": "^20.0.0", - "vitest": "workspace:*" - } -} diff --git a/test/css/testing.mjs b/test/css/testing.mjs deleted file mode 100644 index a98313eca5ae..000000000000 --- a/test/css/testing.mjs +++ /dev/null @@ -1,28 +0,0 @@ -import { startVitest } from 'vitest/node' - -const configs = [ - ['test/default-css', {}], - ['test/process-css', { include: [/App\.css/] }], - [['test/process-module', 'test/process-inline'], { include: [/App\.module\.css/] }], - ['test/scope-module', { include: [/App\.module\.css/], modules: { classNameStrategy: 'scoped' } }], - ['test/non-scope-module', { include: [/App\.module\.css/], modules: { classNameStrategy: 'non-scoped' } }], -] - -async function runTests() { - for (const [name, config] of configs) { - const names = Array.isArray(name) ? name : [name] - await startVitest('test', names, { - run: true, - css: config, - update: false, - teardownTimeout: 1000_000_000, - }) - - if (process.exitCode) - process.exit() - } - - process.exit(0) -} - -runTests() diff --git a/test/css/vitest.config.ts b/test/css/vitest.config.ts deleted file mode 100644 index 68e3449dc6ee..000000000000 --- a/test/css/vitest.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - test: { - environment: 'jsdom', - }, -}) diff --git a/test/cwd/package.json b/test/cwd/package.json deleted file mode 100644 index 121a7ce4632a..000000000000 --- a/test/cwd/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@vitest/test-cwd", - "type": "module", - "private": true, - "scripts": { - "test": "cd $(pwd)/.cache/projects/test && vitest run" - }, - "devDependencies": { - "vitest": "workspace:*" - } -} diff --git a/test/edge-runtime/package.json b/test/edge-runtime/package.json deleted file mode 100644 index 38952bd6321a..000000000000 --- a/test/edge-runtime/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "@vitest/test-edge-runtime", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "@edge-runtime/vm": "1.1.0-beta.26", - "@vitest/web-worker": "workspace:*", - "vitest": "workspace:*" - } -} diff --git a/test/edge-runtime/vitest.config.ts b/test/edge-runtime/vitest.config.ts deleted file mode 100644 index b9c5dc4894e3..000000000000 --- a/test/edge-runtime/vitest.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { defineConfig } from 'vite' - -export default defineConfig({ - test: { - environment: 'node', - }, -}) diff --git a/test/empty-test/package.json b/test/empty-test/package.json deleted file mode 100644 index 37af68d324f3..000000000000 --- a/test/empty-test/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@vitest/test-empty-test", - "type": "module", - "private": true, - "scripts": { - "test": "vitest run --passWithNoTests" - }, - "devDependencies": { - "vitest": "workspace:*" - } -} diff --git a/test/empty-test/test/one.test.ts b/test/empty-test/test/one.test.ts deleted file mode 100644 index c68d89ac3c7c..000000000000 --- a/test/empty-test/test/one.test.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { expect, test } from 'vitest' - -test('two', () => expect(1 + 1).toBe(2)) diff --git a/test/env-custom-file/package.json b/test/env-custom-file/package.json deleted file mode 100644 index 766864d9c819..000000000000 --- a/test/env-custom-file/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "@vitest/test-env-custom-file", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "@types/debug": "^4.1.12", - "debug": "^4.3.4", - "vitest": "workspace:*" - } -} diff --git a/test/env-custom-file/vitest.config.ts b/test/env-custom-file/vitest.config.ts deleted file mode 100644 index 86c87e310c31..000000000000 --- a/test/env-custom-file/vitest.config.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - test: { - environment: './custom.ts', - environmentOptions: { - custom: { - option: 'config-option', - }, - }, - }, -}) diff --git a/test/env-custom/package.json b/test/env-custom/package.json deleted file mode 100644 index a8636f8234ab..000000000000 --- a/test/env-custom/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "@vitest/test-env-custom", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "@types/debug": "^4.1.12", - "debug": "^4.3.4", - "vitest": "workspace:*", - "vitest-environment-custom": "file:./vitest-environment-custom" - } -} diff --git a/test/env-custom/vitest.config.ts b/test/env-custom/vitest.config.ts deleted file mode 100644 index 7703df7c1d44..000000000000 --- a/test/env-custom/vitest.config.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - test: { - environment: 'custom', - environmentOptions: { - custom: { - option: 'config-option', - }, - }, - }, -}) diff --git a/test/env-glob/package.json b/test/env-glob/package.json deleted file mode 100644 index b872870dcf0e..000000000000 --- a/test/env-glob/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "@vitest/test-env-glob", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "vitest": "workspace:*" - } -} diff --git a/test/env-glob/vitest.config.ts b/test/env-glob/vitest.config.ts deleted file mode 100644 index 03fe62fe142e..000000000000 --- a/test/env-glob/vitest.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - test: { - environmentMatchGlobs: [ - ['**/*.dom.test.ts', 'happy-dom'], - ['test/dom/**', 'jsdom'], - ], - }, -}) diff --git a/test/env-mixed/package.json b/test/env-mixed/package.json deleted file mode 100644 index 34d6659e5d16..000000000000 --- a/test/env-mixed/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "@vitest/test-env-mixed", - "type": "module", - "private": true, - "scripts": { - "test": "vitest" - }, - "devDependencies": { - "happy-dom": "latest", - "vite": "latest", - "vitest": "workspace:*" - } -} diff --git a/test/env-mixed/vitest.config.ts b/test/env-mixed/vitest.config.ts deleted file mode 100644 index e8f66bb7fb92..000000000000 --- a/test/env-mixed/vitest.config.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - test: { - include: ['./test/**/*'], - testTimeout: process.env.CI ? 30_000 : 10_000, - chaiConfig: { - truncateThreshold: 0, - }, - }, -}) diff --git a/test/esm/package.json b/test/esm/package.json deleted file mode 100644 index 64cae1c23681..000000000000 --- a/test/esm/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "@vitest/test-esm", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "coverage": "vitest run --coverage" - }, - "dependencies": { - "css-what": "6.1.0", - "tslib": "2.4.0" - }, - "devDependencies": { - "vitest": "workspace:*" - } -} diff --git a/test/esm/src/prototype.d.mts b/test/esm/src/prototype.d.mts deleted file mode 100644 index d424a6707c48..000000000000 --- a/test/esm/src/prototype.d.mts +++ /dev/null @@ -1 +0,0 @@ -declare export const test: number diff --git a/test/esm/src/prototype.mjs b/test/esm/src/prototype.mjs deleted file mode 100644 index ae67ddada465..000000000000 --- a/test/esm/src/prototype.mjs +++ /dev/null @@ -1 +0,0 @@ -export const test = 1 diff --git a/test/esm/test/executes.spec.ts b/test/esm/test/executes.spec.ts deleted file mode 100644 index de94ea0707dd..000000000000 --- a/test/esm/test/executes.spec.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { __assign } from 'tslib' -import { parse } from 'css-what' -import { expect, test } from 'vitest' - -// TODO check on Linux Node 14 -test.skip('imported libs have incorrect ESM, but still work', () => { - expect(__assign({}, { a: 1 })).toEqual({ a: 1 }) - expect(parse('a')).toBeDefined() -}) diff --git a/test/esm/test/prototype.spec.ts b/test/esm/test/prototype.spec.ts deleted file mode 100644 index 021a52715ccb..000000000000 --- a/test/esm/test/prototype.spec.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { expect, it } from 'vitest' -import * as exports from '../src/prototype.mjs' - -it('prototype is null', () => { - expect(Object.getPrototypeOf(exports)).toBe(null) - expect({}.hasOwnProperty).toBeTypeOf('function') - - expect(exports.hasOwnProperty).toBeTypeOf('undefined') -}) diff --git a/test/esm/vite.config.ts b/test/esm/vite.config.ts deleted file mode 100644 index 6db29e984936..000000000000 --- a/test/esm/vite.config.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - test: { - deps: { - external: [/tslib/, /css-what/, /prototype\.mjs/], - }, - }, -}) diff --git a/test/failing/package.json b/test/failing/package.json deleted file mode 100644 index cf7159d7f782..000000000000 --- a/test/failing/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "@vitest/test-failing", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "@vitest/runner": "workspace:*", - "vitest": "workspace:*" - } -} diff --git a/test/failing/vite.config.ts b/test/failing/vite.config.ts deleted file mode 100644 index 34f75a43a597..000000000000 --- a/test/failing/vite.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { defineConfig } from 'vite' - -export default defineConfig({ - test: { - include: ['test/*.test.ts'], - chaiConfig: { - truncateThreshold: 0, - }, - }, -}) diff --git a/test/fails/package.json b/test/fails/package.json deleted file mode 100644 index 8493633c4d69..000000000000 --- a/test/fails/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "@vitest/test-fails", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "@vitest/coverage-istanbul": "workspace:*", - "jsdom": "^21.0.0", - "vitest": "workspace:*" - } -} diff --git a/test/fails/vite.config.ts b/test/fails/vite.config.ts deleted file mode 100644 index 34f75a43a597..000000000000 --- a/test/fails/vite.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { defineConfig } from 'vite' - -export default defineConfig({ - test: { - include: ['test/*.test.ts'], - chaiConfig: { - truncateThreshold: 0, - }, - }, -}) diff --git a/test/filters/package.json b/test/filters/package.json deleted file mode 100644 index 6185d605cefb..000000000000 --- a/test/filters/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "@vitest/test-filters", - "type": "module", - "private": true, - "scripts": { - "test": "vitest" - }, - "devDependencies": { - "vite": "latest", - "vitest": "workspace:*" - } -} diff --git a/test/filters/vitest.config.ts b/test/filters/vitest.config.ts deleted file mode 100644 index 7e66d6e731c6..000000000000 --- a/test/filters/vitest.config.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - test: { - reporters: 'verbose', - include: ['test/**/*.test.*'], - }, -}) diff --git a/test/global-setup-fail/package.json b/test/global-setup-fail/package.json deleted file mode 100644 index 9244af279411..000000000000 --- a/test/global-setup-fail/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@vitest/test-global-setup-fail", - "type": "module", - "private": true, - "scripts": { - "test": "vitest" - }, - "devDependencies": { - "vitest": "workspace:*" - } -} diff --git a/test/global-setup-fail/vitest.config.ts b/test/global-setup-fail/vitest.config.ts deleted file mode 100644 index 41bc8c0ff39f..000000000000 --- a/test/global-setup-fail/vitest.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { defineConfig } from 'vite' - -export default defineConfig({ - test: { - include: ['test/*.test.ts'], - }, -}) diff --git a/test/global-setup/setupFiles/add-something-to-global.ts b/test/global-setup/setupFiles/add-something-to-global.ts index d8eaedfd188a..8630267d751c 100644 --- a/test/global-setup/setupFiles/add-something-to-global.ts +++ b/test/global-setup/setupFiles/add-something-to-global.ts @@ -1,4 +1,4 @@ -import { afterAll, beforeAll } from 'vitest' +import { afterAll, beforeAll, beforeEach } from 'vitest' beforeAll(() => { // @ts-expect-error type diff --git a/test/global-setup/test/global-setup.test.ts b/test/global-setup/test/global-setup.test.ts index 13ab1ab30c3d..288fce6041c2 100644 --- a/test/global-setup/test/global-setup.test.ts +++ b/test/global-setup/test/global-setup.test.ts @@ -1,4 +1,4 @@ -import { expect } from 'vitest' +import { afterEach, beforeEach, expect, test } from 'vitest' beforeEach(async () => { await new Promise((resolve) => { diff --git a/test/global-setup/test/setup-files.test.ts b/test/global-setup/test/setup-files.test.ts index 4c61bdec4e54..7c0f6b267cf0 100644 --- a/test/global-setup/test/setup-files.test.ts +++ b/test/global-setup/test/setup-files.test.ts @@ -1,4 +1,4 @@ -import { expect } from 'vitest' +import { expect, test } from 'vitest' test('something has been added to global by setupFiles entry', async () => { // @ts-expect-error type diff --git a/test/global-setup/vitest.config.ts b/test/global-setup/vitest.config.ts index 738bf88c358c..e330ce975bf8 100644 --- a/test/global-setup/vitest.config.ts +++ b/test/global-setup/vitest.config.ts @@ -15,7 +15,6 @@ export default defineConfig({ }, ], test: { - globals: true, globalSetup: [ './globalSetup/default-export.js', './globalSetup/named-exports.js', diff --git a/test/import-meta/package.json b/test/import-meta/package.json deleted file mode 100644 index 48675b6657e1..000000000000 --- a/test/import-meta/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "@vitest/test-import-meta", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "build": "vite build", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "vitest": "workspace:*" - } -} diff --git a/test/import-meta/vite.config.ts b/test/import-meta/vite.config.ts deleted file mode 100644 index f82c49b28e05..000000000000 --- a/test/import-meta/vite.config.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { resolve } from 'pathe' -import { defineConfig } from 'vite' - -export default defineConfig({ - test: { - includeSource: [ - 'src/**/*.ts', - ], - }, - define: { - 'import.meta.vitest': false, - }, - build: { - lib: { - formats: ['es', 'cjs'], - entry: resolve(__dirname, 'src/index.ts'), - fileName: 'index', - }, - }, -}) diff --git a/test/inspect/package.json b/test/inspect/package.json deleted file mode 100644 index ed5e2c5d23c7..000000000000 --- a/test/inspect/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "@vitest/test-inspect", - "type": "module", - "private": true, - "scripts": { - "test": "vitest" - }, - "devDependencies": { - "vite": "latest", - "vitest": "workspace:*", - "ws": "^8.14.2" - } -} diff --git a/test/inspect/vitest.config.ts b/test/inspect/vitest.config.ts deleted file mode 100644 index 654ae2aa887a..000000000000 --- a/test/inspect/vitest.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - test: { - include: ['./test/**'], - }, -}) diff --git a/test/mixed-pools/package.json b/test/mixed-pools/package.json deleted file mode 100644 index f492c216d7c6..000000000000 --- a/test/mixed-pools/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "@vitest/test-mixed-pools", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "vitest": "workspace:*" - } -} diff --git a/test/mixed-pools/vitest.config.ts b/test/mixed-pools/vitest.config.ts deleted file mode 100644 index f90018d58c12..000000000000 --- a/test/mixed-pools/vitest.config.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { defineConfig } from 'vite' - -export default defineConfig({ - test: { - include: ['test/*.test.ts'], - poolMatchGlobs: [ - ['**/test/*.child_process.test.ts', 'forks'], - ['**/test/*.threads.test.ts', 'threads'], - ], - }, -}) diff --git a/test/network-imports/package.json b/test/network-imports/package.json deleted file mode 100644 index a8463ad9787e..000000000000 --- a/test/network-imports/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@vitest/test-network-imports", - "type": "module", - "private": true, - "scripts": { - "test": "vitest" - }, - "devDependencies": { - "vitest": "workspace:*" - } -} diff --git a/test/network-imports/vitest.config.ts b/test/network-imports/vitest.config.ts deleted file mode 100644 index d4fdcc4e457e..000000000000 --- a/test/network-imports/vitest.config.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - test: { - poolOptions: { - threads: { - execArgv: ['--experimental-network-imports'], - }, - forks: { - execArgv: ['--experimental-network-imports'], - }, - // not supported? - // FAIL test/basic.test.ts [ test/basic.test.ts ] - // Error: ENOENT: no such file or directory, open 'http://localhost:9602/slash@3.0.0.js' - // ❯ Object.openSync node:fs:596:3 - // ❯ readFileSync node:fs:464:35 - vmThreads: { - execArgv: ['--experimental-network-imports'], - }, - }, - // let vite serve public/slash@3.0.0.js - api: 9602, - }, -}) diff --git a/test/path-resolution-target/.eslintignore b/test/path-resolution-target/.eslintignore deleted file mode 100644 index af18ca9559d2..000000000000 --- a/test/path-resolution-target/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -!dist/ diff --git a/test/path-resolution-target/.gitignore b/test/path-resolution-target/.gitignore deleted file mode 100644 index af18ca9559d2..000000000000 --- a/test/path-resolution-target/.gitignore +++ /dev/null @@ -1 +0,0 @@ -!dist/ diff --git a/test/path-resolution-target/README.md b/test/path-resolution-target/README.md deleted file mode 100644 index 79839556fa38..000000000000 --- a/test/path-resolution-target/README.md +++ /dev/null @@ -1,2 +0,0 @@ -This package is here just to be a sibling package to `path-resolution`. It -contains no tests of its own. diff --git a/test/path-resolution-target/dist/index.d.ts b/test/path-resolution-target/dist/index.d.ts deleted file mode 100644 index 3b9981e05940..000000000000 --- a/test/path-resolution-target/dist/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export function sub(a: number, b: number): number diff --git a/test/path-resolution-target/dist/index.js b/test/path-resolution-target/dist/index.js deleted file mode 100644 index cb92ed2e794b..000000000000 --- a/test/path-resolution-target/dist/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export function sub(a, b) { - return a - b; -} diff --git a/test/path-resolution-target/package.json b/test/path-resolution-target/package.json deleted file mode 100644 index 8b66a23ae3c1..000000000000 --- a/test/path-resolution-target/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "@vitest/test-path-resolution-target", - "type": "module", - "private": true, - "main": "./dist/index.js" -} diff --git a/test/path-resolution/package.json b/test/path-resolution/package.json deleted file mode 100644 index 8e9d53a622e1..000000000000 --- a/test/path-resolution/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "@vitest/test-path-resolution", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "@edge-runtime/vm": "1.1.0-beta.26", - "@vitest/test-path-resolution-target": "workspace:*", - "@vitest/web-worker": "workspace:*", - "vitest": "workspace:*" - } -} diff --git a/test/path-resolution/test/sister-package.test.ts b/test/path-resolution/test/sister-package.test.ts deleted file mode 100644 index abc20c44e2eb..000000000000 --- a/test/path-resolution/test/sister-package.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { expect, it, vitest } from 'vitest' - -import { sub } from '@vitest/test-path-resolution-target' - -vitest.mock('@vitest/test-path-resolution-target') - -it('should be mocked', () => { - expect(sub).toHaveProperty('mock') - expect(sub(5, 3)).toBeUndefined() -}) - -it('should import actual', async () => { - const { sub } = await vitest.importActual('@vitest/test-path-resolution-target') - - expect(sub).not.toHaveProperty('mock') - expect(sub(5, 3)).toBe(2) -}) diff --git a/test/path-resolution/vitest.config.ts b/test/path-resolution/vitest.config.ts deleted file mode 100644 index 41bc8c0ff39f..000000000000 --- a/test/path-resolution/vitest.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { defineConfig } from 'vite' - -export default defineConfig({ - test: { - include: ['test/*.test.ts'], - }, -}) diff --git a/test/public-api/package.json b/test/public-api/package.json deleted file mode 100644 index 3d4808f6a8eb..000000000000 --- a/test/public-api/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "@vitest/test-public-api", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "fixtures": "vitest --root ./fixtures" - }, - "devDependencies": { - "@vitest/browser": "workspace:*", - "vitest": "workspace:*" - } -} diff --git a/test/public-api/vitest.config.ts b/test/public-api/vitest.config.ts deleted file mode 100644 index edd2f59d33a3..000000000000 --- a/test/public-api/vitest.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - test: { - include: ['tests/**/*.spec.ts'], - chaiConfig: { - truncateThreshold: 0, - }, - }, -}) diff --git a/test/resolve/package.json b/test/resolve/package.json deleted file mode 100644 index 200869030d4b..000000000000 --- a/test/resolve/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "@vitest/test-resolve", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "happy-dom": "^12.10.3", - "vitest": "workspace:*" - } -} diff --git a/test/resolve/vitest.config.ts b/test/resolve/vitest.config.ts deleted file mode 100644 index ccd1abd987b3..000000000000 --- a/test/resolve/vitest.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from 'vite' - -export default defineConfig({ - test: { - environmentMatchGlobs: [ - ['**/web.test.ts', 'happy-dom'], - ['**/ssr.test.ts', 'node'], - ], - server: { - deps: { - external: [/pkg-/], - }, - }, - }, -}) diff --git a/test/restricted/package.json b/test/restricted/package.json deleted file mode 100644 index 0945027f31bc..000000000000 --- a/test/restricted/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "@vitest/test-restricted", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "jsdom": "^22.1.0", - "vitest": "workspace:*" - } -} diff --git a/test/run-once/package.json b/test/run-once/package.json deleted file mode 100644 index c5b3c3075e4e..000000000000 --- a/test/run-once/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "@vitest/test-run-once", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "vitest": "workspace:*" - } -} diff --git a/test/run-once/test/run-once.test.ts b/test/run-once/test/run-once.test.ts deleted file mode 100644 index 3afeedf786ab..000000000000 --- a/test/run-once/test/run-once.test.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { expect, isFirstRun, it, runOnce } from 'vitest' - -let dummy = 0 - -const one = runOnce(() => { - dummy += 1 - return 1 -}) - -const two = await runOnce(async () => { - dummy += 1 - return 2 -}) - -it('runOnce', async () => { - expect(one).toBe(1) - expect(two).toBe(2) - - // edit the file to trigger the hmr and dummy should be 0 - expect(dummy).toBe(2) -}) - -it('isFirstRun', () => { - // edit the file and this will fail - expect(isFirstRun()).toBe(true) -}) diff --git a/test/run-once/vitest.config.ts b/test/run-once/vitest.config.ts deleted file mode 100644 index 9ca84b2b94b0..000000000000 --- a/test/run-once/vitest.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { defineConfig } from 'vite' - -export default defineConfig({ - test: { - isolate: false, - }, -}) diff --git a/test/run/allowed-exec-args-fixtures/vitest.config.ts b/test/run/allowed-exec-args-fixtures/vitest.config.ts deleted file mode 100644 index abed6b2116e1..000000000000 --- a/test/run/allowed-exec-args-fixtures/vitest.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({}) diff --git a/test/run/no-exec-args-fixtures/vitest.config.ts b/test/run/no-exec-args-fixtures/vitest.config.ts deleted file mode 100644 index abed6b2116e1..000000000000 --- a/test/run/no-exec-args-fixtures/vitest.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({}) diff --git a/test/run/package.json b/test/run/package.json deleted file mode 100644 index d3599cd88044..000000000000 --- a/test/run/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "@vitest/test-run", - "type": "module", - "private": true, - "scripts": { - "test": "vitest" - }, - "devDependencies": { - "@vitest/runner": "workspace:*", - "execa": "^7.1.1", - "vite": "latest", - "vitest": "workspace:*" - } -} diff --git a/test/run/vitest.config.ts b/test/run/vitest.config.ts deleted file mode 100644 index f25db59f31e3..000000000000 --- a/test/run/vitest.config.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - test: { - reporters: 'verbose', - include: ['test/**/*.test.*'], - chaiConfig: { - truncateThreshold: 0, - }, - testTimeout: process.env.CI ? 60_000 : 10_000, - }, -}) diff --git a/test/setup/package.json b/test/setup/package.json deleted file mode 100644 index e98152a9cbb2..000000000000 --- a/test/setup/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@vitest/test-setup", - "type": "module", - "private": true, - "scripts": { - "test": "vitest" - }, - "devDependencies": { - "vitest": "workspace:*" - } -} diff --git a/test/setup/tests/console-setup.test.ts b/test/setup/tests/console-setup.test.ts deleted file mode 100644 index 8ab6a2bf71eb..000000000000 --- a/test/setup/tests/console-setup.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { normalize } from 'node:path' -import { describe, expect, test } from 'vitest' -import { runVitest } from '../../test-utils' - -async function run() { - return await runVitest({ - include: ['tests/fixtures/console.test.ts'], - setupFiles: ['setupFiles/console-setup.ts'], - }) -} - -describe('setup files console', () => { - test('print stdout and stderr correctly', async () => { - const { stdout, stderr } = await run() - const filepath = normalize('setupFiles/console-setup.ts') - expect(stdout).toContain(`stdout | ${filepath}`) - expect(stderr).toContain(`stderr | ${filepath}`) - }) -}) diff --git a/test/setup/tests/empty-setup.test.ts b/test/setup/tests/empty-setup.test.ts deleted file mode 100644 index 2621a8919ec2..000000000000 --- a/test/setup/tests/empty-setup.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { expect, it } from 'vitest' - -it('should success', async () => { - expect(1 + 1).toBe(2) -}) diff --git a/test/setup/tests/setup-files.test.ts b/test/setup/tests/setup-files.test.ts deleted file mode 100644 index 984126800aa2..000000000000 --- a/test/setup/tests/setup-files.test.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { promises as fs } from 'node:fs' -import { afterEach, describe, expect, it } from 'vitest' - -import { runVitest } from '../../test-utils' - -async function run() { - return await runVitest({ - include: ['tests/empty-setup.test.ts'], - setupFiles: ['setupFiles/empty-setup.ts'], - changed: true, - }) -} - -describe('setup files with forceRerunTrigger', () => { - const file = './setupFiles/empty-setup.ts' - - afterEach(async () => { - await fs.writeFile(file, '', 'utf-8') - }) - - // Note that this test will fail locally if you have uncommitted changes - it.runIf(process.env.GITHUB_ACTIONS)('should run no tests if setup file is not changed', async () => { - const { stdout } = await run() - expect(stdout).toContain('No test files found, exiting with code 0') - }, 60_000) - - it('should run the whole test suite if setup file is changed', async () => { - const codes = 'export const a = 1' - await fs.writeFile(file, codes, 'utf-8') - const { stdout } = await run() - expect(stdout).toContain('1 passed') - }, 60_000) -}) diff --git a/test/shard/package.json b/test/shard/package.json deleted file mode 100644 index 705e8af50bae..000000000000 --- a/test/shard/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@vitest/test-shard", - "type": "module", - "private": true, - "scripts": { - "test": "vitest run shard-test.test.ts" - }, - "devDependencies": { - "vitest": "workspace:*" - } -} diff --git a/test/shard/vitest.config.ts b/test/shard/vitest.config.ts deleted file mode 100644 index 99017865e5bd..000000000000 --- a/test/shard/vitest.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - test: { - testTimeout: 50_000, - }, -}) diff --git a/test/single-thread/package.json b/test/single-thread/package.json deleted file mode 100644 index efc8e44b26a0..000000000000 --- a/test/single-thread/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "@vitest/test-single-thread", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "vitest": "workspace:*" - } -} diff --git a/test/single-thread/test/a.test.ts b/test/single-thread/test/a.test.ts deleted file mode 100644 index 3324f2317d15..000000000000 --- a/test/single-thread/test/a.test.ts +++ /dev/null @@ -1,11 +0,0 @@ -import fs from 'node:fs' -import { expect, it, vi } from 'vitest' -import { timeout } from './timeout' - -// this file is running first, it should not affect file "b.test.ts" -it('mock is mocked', () => { - vi.spyOn(fs, 'readFileSync').mockReturnValue('mocked') - expect(fs.readFileSync('')).toBe('mocked') -}) - -it('timeout', () => new Promise(resolve => setTimeout(resolve, timeout))) diff --git a/test/single-thread/test/b.test.ts b/test/single-thread/test/b.test.ts deleted file mode 100644 index e4b82b89bae0..000000000000 --- a/test/single-thread/test/b.test.ts +++ /dev/null @@ -1,18 +0,0 @@ -import fs from 'node:fs' -import { fileURLToPath } from 'node:url' -import { dirname, resolve } from 'pathe' -import { expect, it } from 'vitest' -import { timeout } from './timeout' - -// this file is running second, it should not be affected by mock in "a.test.ts" -it('mock is mocked', () => { - expect(fs.readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), './timeout.ts'), 'utf-8')).toMatchInlineSnapshot(` - "export const timeout = 200 - export const mockedFn = function () { - return 'original' - } - " - `) -}) - -it('timeout', () => new Promise(resolve => setTimeout(resolve, timeout))) diff --git a/test/single-thread/test/c.test.ts b/test/single-thread/test/c.test.ts deleted file mode 100644 index 52a107225e3d..000000000000 --- a/test/single-thread/test/c.test.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { it } from 'vitest' -import { timeout } from './timeout' - -it('timeout', () => new Promise(resolve => setTimeout(resolve, timeout))) diff --git a/test/single-thread/test/d.test.ts b/test/single-thread/test/d.test.ts deleted file mode 100644 index 8ebc37fccaae..000000000000 --- a/test/single-thread/test/d.test.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { expect, it } from 'vitest' -import { timeout } from './timeout' - -it('timeout', () => new Promise(resolve => setTimeout(resolve, timeout))) - -it('1', () => { - expect(1).toEqual(1) -}) diff --git a/test/single-thread/test/timeout.ts b/test/single-thread/test/timeout.ts deleted file mode 100644 index 980598ac3d05..000000000000 --- a/test/single-thread/test/timeout.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const timeout = 200 -export const mockedFn = function () { - return 'original' -} diff --git a/test/single-thread/vitest.config.ts b/test/single-thread/vitest.config.ts deleted file mode 100644 index eee4c946dc84..000000000000 --- a/test/single-thread/vitest.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { defineConfig } from 'vite' -import { BaseSequencer, type WorkspaceSpec } from 'vitest/node' - -export default defineConfig({ - test: { - pool: 'forks', - sequence: { - sequencer: class Sequences extends BaseSequencer { - public async sort(files: WorkspaceSpec[]): Promise { - return files.sort() - } - }, - }, - }, -}) diff --git a/test/snapshots/test/__snapshots__/shapshots.test.ts.snap b/test/snapshots/test/__snapshots__/snapshots.test.ts.snap similarity index 94% rename from test/snapshots/test/__snapshots__/shapshots.test.ts.snap rename to test/snapshots/test/__snapshots__/snapshots.test.ts.snap index a3d90fc6be12..d42ea091ab42 100644 --- a/test/snapshots/test/__snapshots__/shapshots.test.ts.snap +++ b/test/snapshots/test/__snapshots__/snapshots.test.ts.snap @@ -89,14 +89,3 @@ describe('snapshots with properties', () => { }) " `; - -exports[`multiline strings 1`] = ` -" -export default function () { - function Foo() { - } - - return Foo; -} -" -`; diff --git a/test/snapshots/test/shapshots.test.ts b/test/snapshots/test/snapshots.test.ts similarity index 57% rename from test/snapshots/test/shapshots.test.ts rename to test/snapshots/test/snapshots.test.ts index 4c7adbedea64..5fa0cdf61d6c 100644 --- a/test/snapshots/test/shapshots.test.ts +++ b/test/snapshots/test/snapshots.test.ts @@ -1,18 +1,8 @@ import fs from 'node:fs/promises' -import pathe from 'pathe' import { expect, test } from 'vitest' +import pathe from 'pathe' -function println() { - const message = ` -export default function () { - function Foo() { - } - - return Foo; -} -` - return message -} +import { editFile, runVitest } from '../../test-utils' test('non default snapshot format', () => { expect({ foo: ['bar'] }).toMatchInlineSnapshot(` @@ -24,21 +14,6 @@ test('non default snapshot format', () => { `) }) -test('multiline strings ', () => { - expect(println()).toMatchSnapshot() -}) - -test('updateInlineSnapshot should not remove end whitespace', () => { - // issue #922 - expect(` -my string -`).toMatchInlineSnapshot(` - " - my string - " -`) -}) - test('js snapshots generated correctly', async () => { const path = pathe.resolve(__dirname, '../test-update/snapshots-inline-js.test.js') const content = await fs.readFile(path, 'utf8') @@ -50,3 +25,20 @@ test('concurrent snapshot update', async () => { const content = await fs.readFile(path, 'utf8') expect(content).toMatchSnapshot() }) + +test('--update works for workspace project', async () => { + // setup wrong snapshot value + editFile( + 'test/fixtures/workspace/packages/space/test/__snapshots__/basic.test.ts.snap', + data => data.replace('`1`', '`2`'), + ) + + // run with --update + const { stdout, exitCode } = await runVitest({ + update: true, + root: 'test/fixtures/workspace', + workspace: 'vitest.workspace.ts', + }) + expect.soft(stdout).include('Snapshots 1 updated') + expect.soft(exitCode).toBe(0) +}) diff --git a/test/snapshots/test/workspace.test.ts b/test/snapshots/test/workspace.test.ts deleted file mode 100644 index 50ebd751e2c2..000000000000 --- a/test/snapshots/test/workspace.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { expect, test } from 'vitest' -import { editFile, runVitest } from '../../test-utils' - -test('--update works for workspace project', async () => { - // setup wrong snapshot value - editFile( - 'test/fixtures/workspace/packages/space/test/__snapshots__/basic.test.ts.snap', - data => data.replace('`1`', '`2`'), - ) - - // run with --update - const { stdout, exitCode } = await runVitest({ - update: true, - root: 'test/fixtures/workspace', - workspace: 'vitest.workspace.ts', - }) - expect.soft(stdout).include('Snapshots 1 updated') - expect.soft(exitCode).toBe(0) -}) diff --git a/test/stacktraces/package.json b/test/stacktraces/package.json deleted file mode 100644 index 94844f2d9d3e..000000000000 --- a/test/stacktraces/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "@vitest/test-stacktraces", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "vitest": "workspace:*" - } -} diff --git a/test/stacktraces/vite.config.ts b/test/stacktraces/vite.config.ts deleted file mode 100644 index f2e0a568e16b..000000000000 --- a/test/stacktraces/vite.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { defineConfig } from 'vite' - -export default defineConfig({ - esbuild: { - sourcemap: 'both', - }, - test: { - include: ['test/*.test.ts'], - }, -}) diff --git a/test/test-utils/index.ts b/test/test-utils/index.ts index a828234e7cea..01efdf63c856 100644 --- a/test/test-utils/index.ts +++ b/test/test-utils/index.ts @@ -2,7 +2,7 @@ import { Readable, Writable } from 'node:stream' import fs from 'node:fs' import { fileURLToPath } from 'node:url' import type { UserConfig as ViteUserConfig } from 'vite' -import { type UserConfig, type VitestRunMode, afterEach } from 'vitest' +import { type UserConfig, type VitestRunMode, type WorkerGlobalState, afterEach } from 'vitest' import type { Vitest } from 'vitest/node' import { startVitest } from 'vitest/node' import { type Options, execa } from 'execa' @@ -135,6 +135,11 @@ export async function runViteNodeCli(_options?: Options | string, ...args: strin return { viteNode: vitest, ...rest } } +export function getInternalState(): WorkerGlobalState { + // @ts-expect-error untyped global + return globalThis.__vitest_worker__ +} + const originalFiles = new Map() const createdFiles = new Set() afterEach(() => { diff --git a/test/utils/package.json b/test/utils/package.json deleted file mode 100644 index b7eb906e2622..000000000000 --- a/test/utils/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "@vitest/test-utils", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "@vitest/utils": "workspace:*", - "vitest": "workspace:*" - } -} diff --git a/test/vite-config/package.json b/test/vite-config/package.json deleted file mode 100644 index 03f0eaf42c44..000000000000 --- a/test/vite-config/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "@vitest/test-vite-config", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "pathe": "^1.1.0", - "vitest": "workspace:*" - } -} diff --git a/test/vite-config/src/index.html b/test/vite-config/src/index.html deleted file mode 100644 index 4676e1058a0e..000000000000 --- a/test/vite-config/src/index.html +++ /dev/null @@ -1 +0,0 @@ -Hello Vitest diff --git a/test/vite-config/src/src.ts b/test/vite-config/src/src.ts deleted file mode 100644 index cb356468240d..000000000000 --- a/test/vite-config/src/src.ts +++ /dev/null @@ -1 +0,0 @@ -export const foo = 'foo' diff --git a/test/vite-config/src/test/root.test.ts b/test/vite-config/src/test/root.test.ts deleted file mode 100644 index 5f0edf39e390..000000000000 --- a/test/vite-config/src/test/root.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { expect, it, vi } from 'vitest' -import { foo } from '../src' - -vi.mock('../src.ts', () => ({ foo: 'baz' })) - -it('should work', () => { - expect(1).toBe(1) -}) - -it('mocking with root works', () => { - expect(foo).toBe('baz') -}) diff --git a/test/vite-config/vite.config.ts b/test/vite-config/vite.config.ts deleted file mode 100644 index 26fef2659c2e..000000000000 --- a/test/vite-config/vite.config.ts +++ /dev/null @@ -1,17 +0,0 @@ -import assert from 'node:assert' -import { join } from 'pathe' -import { defineConfig } from 'vite' - -const configRoot = join(__dirname, 'src') - -export default defineConfig({ - root: configRoot, - plugins: [ - { - name: 'root-checker', - configResolved(config) { - assert.equal(config.root, configRoot) - }, - }, - ], -}) diff --git a/test/vite-node/package.json b/test/vite-node/package.json index c655543de30a..6bb382c179f7 100644 --- a/test/vite-node/package.json +++ b/test/vite-node/package.json @@ -11,8 +11,6 @@ }, "devDependencies": { "@types/inquirer": "^9.0.3", - "@vitest/test-dep1": "file:./deps/dep1", - "@vitest/test-dep2": "file:./deps/dep2", "execa": "^6.1.0", "inquirer": "^9.2.7", "vite-node": "workspace:*", diff --git a/test/vm-threads/package.json b/test/vm-threads/package.json deleted file mode 100644 index 732e72fe87ac..000000000000 --- a/test/vm-threads/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "@vitest/test-vm-threads", - "type": "module", - "private": true, - "scripts": { - "test": "vitest" - }, - "devDependencies": { - "jsdom": "latest", - "vitest": "workspace:*" - } -} diff --git a/test/wasm-modules/package.json b/test/wasm-modules/package.json deleted file mode 100644 index 729aeadc950f..000000000000 --- a/test/wasm-modules/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@vitest/test-wasm-modules", - "type": "module", - "private": true, - "scripts": { - "test": "vitest" - }, - "devDependencies": { - "vitest": "workspace:*" - } -} diff --git a/test/wasm-modules/vitest.config.ts b/test/wasm-modules/vitest.config.ts deleted file mode 100644 index d27828b8088c..000000000000 --- a/test/wasm-modules/vitest.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - test: { - poolOptions: { - threads: { - execArgv: ['--experimental-wasm-modules'], - }, - forks: { - execArgv: ['--experimental-wasm-modules'], - }, - }, - server: { - deps: { - external: [/\.wasm$/, /\/wasm-bindgen-no-cyclic\/index_bg.js/], - }, - }, - }, -}) diff --git a/test/watch/test/workspaces.test.ts b/test/watch/test/workspaces.test.ts index 6ea40633613d..30fcdbeb0c69 100644 --- a/test/watch/test/workspaces.test.ts +++ b/test/watch/test/workspaces.test.ts @@ -8,7 +8,7 @@ import { runVitestCli } from '../../test-utils' const file = fileURLToPath(import.meta.url) const dir = dirname(file) const root = resolve(dir, '..', '..', 'workspaces') -const config = resolve(root, 'vitest.config.ts') +const config = resolve(root, 'vitest.config.watch.ts') const cleanups: (() => void)[] = [] const srcMathFile = resolve(root, 'src', 'math.ts') diff --git a/test/web-worker/package.json b/test/web-worker/package.json deleted file mode 100644 index 7a4bb2073acb..000000000000 --- a/test/web-worker/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "@vitest/test-web-worker", - "type": "module", - "private": true, - "scripts": { - "test": "vitest", - "coverage": "vitest run --coverage" - }, - "devDependencies": { - "@vitest/web-worker": "workspace:*", - "vitest": "workspace:*" - } -} diff --git a/test/web-worker/setup.ts b/test/web-worker/setup.ts deleted file mode 100644 index dc039a879677..000000000000 --- a/test/web-worker/setup.ts +++ /dev/null @@ -1 +0,0 @@ -import '@vitest/web-worker' diff --git a/test/web-worker/test/clone.test.ts b/test/web-worker/test/clone.test.ts deleted file mode 100644 index 69448a7b00a7..000000000000 --- a/test/web-worker/test/clone.test.ts +++ /dev/null @@ -1,136 +0,0 @@ -import { version } from 'node:process' -import { beforeEach, describe, expect, it, vi } from 'vitest' - -import MyWorker from '../src/objectWorker?worker' - -const major = Number(version.split('.')[0].slice(1)) - -describe.runIf(major >= 17)('when node supports structuredClone', () => { - it('uses native structure clone', () => { - expect.assertions(4) - - expect(structuredClone).toBeDefined() - - const worker = new MyWorker() - const buffer = new ArrayBuffer(1) - const obj = { hello: 'world', buffer } - worker.postMessage(obj, [buffer]) - - return new Promise((resolve, reject) => { - worker.onmessage = (e) => { - try { - expect(e).toBeInstanceOf(MessageEvent) - expect(e.data, 'doesn\'t keep reference').not.toBe(obj) - expect(e.data, 'shape is equal').toEqual(obj) - resolve() - } - catch (err) { - reject(err) - } - finally { - worker.terminate() - } - } - }) - }) - - it('throws error, if passing down unserializable data', () => { - expect.assertions(4) - - expect(structuredClone).toBeDefined() - - const worker = new MyWorker() - const obj = { hello: 'world', name() {} } - worker.postMessage(obj) - - return new Promise((resolve, reject) => { - worker.onmessageerror = (e) => { - try { - expect(e.type).toBe('messageerror') - expect(e).toBeInstanceOf(MessageEvent) - expect(e.data.message).toContain( - 'could not be cloned.', - ) - resolve() - } - catch (err) { - reject(err) - } - } - }) - }) -}) - -describe('when passing down custom clone', () => { - const { warn } = console - - beforeEach(() => { - console.warn = warn - process.env.VITEST_WEB_WORKER_CLONE = undefined - }) - - it('uses ponyfill clone', () => { - expect.assertions(4) - - console.warn = vi.fn() - process.env.VITEST_WEB_WORKER_CLONE = 'ponyfill' - - const worker = new MyWorker() - const buffer = new ArrayBuffer(1) - const obj = { hello: 'world' } - worker.postMessage(obj, [buffer]) - - return new Promise((resolve, reject) => { - worker.onmessageerror = (e) => { - reject(e.data) - } - worker.onmessage = (e) => { - try { - expect(e).toBeInstanceOf(MessageEvent) - expect(e.data, 'doesn\'t keep reference').not.toBe(obj) - expect(e.data, 'shape is not equal, don\'t transfer buffer').toEqual({ hello: 'world' }) - expect(console.warn).toBeCalledWith(expect.stringContaining('[@vitest/web-worker] `structuredClone` is not supported in this')) - resolve() - } - catch (err) { - reject(err) - } - finally { - worker.terminate() - } - } - }) - }) - - it('doesn\'t clone, if asked to', () => { - expect.assertions(3) - - console.warn = vi.fn() - process.env.VITEST_WEB_WORKER_CLONE = 'none' - - const worker = new MyWorker() - const buffer = new ArrayBuffer(1) - const obj = { hello: 'world', buffer } - worker.postMessage(obj, [buffer]) - - return new Promise((resolve, reject) => { - worker.onmessageerror = (e) => { - reject(e.data) - } - worker.onmessage = (e) => { - try { - expect(e).toBeInstanceOf(MessageEvent) - expect(e.data, 'keeps reference').toBe(obj) - expect(console.warn).not.toHaveBeenCalled() - resolve() - } - catch (err) { - reject(err) - } - finally { - worker.terminate() - } - } - }) - }) -}) diff --git a/test/web-worker/test/init.test.ts b/test/web-worker/test/init.test.ts deleted file mode 100644 index 166cb2353ff2..000000000000 --- a/test/web-worker/test/init.test.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { expect, it } from 'vitest' - -import MyWorker from '../src/worker?worker' -import MyEventListenerWorker from '../src/eventListenerWorker?worker' -import MySelfWorker from '../src/selfWorker?worker' - -function sleep(time: number) { - return new Promise(resolve => setTimeout(resolve, time)) -} - -function testWorker(worker: Worker) { - return new Promise((resolve) => { - worker.postMessage('hello') - worker.onmessage = (e) => { - expect(e.data).toBe('hello world') - - resolve() - } - }) -} - -function testSelfWorker(worker: Worker) { - return new Promise((resolve) => { - worker.onmessage = (e) => { - resolve(e.data) - } - }) -} - -it('worker exists', async () => { - expect(Worker).toBeDefined() -}) - -it('simple worker', async () => { - expect.assertions(1) - - await testWorker(new MyWorker()) -}) - -it('event listener worker', async () => { - expect.assertions(1) - - await testWorker(new MyEventListenerWorker()) -}) - -it('can test workers several times', async () => { - expect.assertions(1) - - await testWorker(new MyWorker()) -}) - -it('worker with url', async () => { - expect.assertions(1) - const url = import.meta.url - - await testWorker(new Worker(new URL('../src/worker.ts', url))) -}) - -it('self injected into worker and its deps should be equal', async () => { - expect.assertions(4) - expect(await testSelfWorker(new MySelfWorker())).toBeTruthy() - // wait for clear worker mod cache - await sleep(0) - expect(await testSelfWorker(new MySelfWorker())).toBeTruthy() - - await sleep(0) - - expect(await testSelfWorker(new Worker(new URL('../src/selfWorker.ts', import.meta.url)))).toBeTruthy() - // wait for clear worker mod cache - await sleep(0) - expect(await testSelfWorker(new Worker(new URL('../src/selfWorker.ts', import.meta.url)))).toBeTruthy() -}) diff --git a/test/web-worker/test/postMessage.test.ts b/test/web-worker/test/postMessage.test.ts deleted file mode 100644 index 4f35ee6a3076..000000000000 --- a/test/web-worker/test/postMessage.test.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { expect, it } from 'vitest' -import MyWorker from '../src/worker?worker' - -it('throws syntax error if no arguments are provided', () => { - const worker = new MyWorker() - - // @ts-expect-error requires at least one argument - expect(() => worker.postMessage()).toThrowError(SyntaxError) - expect(() => worker.postMessage(undefined)).not.toThrowError() - expect(() => worker.postMessage(null)).not.toThrowError() -}) diff --git a/test/web-worker/test/sharedWorker.spec.ts b/test/web-worker/test/sharedWorker.spec.ts deleted file mode 100644 index 8c82a1b06b2b..000000000000 --- a/test/web-worker/test/sharedWorker.spec.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { expect, it } from 'vitest' -import MySharedWorker from '../src/sharedWorker?sharedworker' - -function sendEventMessage(worker: SharedWorker, msg: any) { - worker.port.postMessage(msg) - return new Promise((resolve) => { - worker.port.addEventListener('message', function onmessage(e) { - worker.port.removeEventListener('message', onmessage) - resolve(e.data as string) - }) - }) -} - -function sendOnMessage(worker: SharedWorker, msg: any) { - worker.port.postMessage(msg) - return new Promise((resolve) => { - worker.port.onmessage = function onmessage(e) { - worker.port.onmessage = null - resolve(e.data as string) - } - }) -} - -it('vite shared worker works', async () => { - expect(MySharedWorker).toBeDefined() - expect(SharedWorker).toBeDefined() - const worker = new MySharedWorker() - expect(worker).toBeInstanceOf(SharedWorker) - - await expect(sendEventMessage(worker, 'event')).resolves.toBe('event') - await expect(sendOnMessage(worker, 'event')).resolves.toBe('event') -}) - -it('shared worker with path works', async () => { - expect(SharedWorker).toBeDefined() - const worker = new SharedWorker(new URL('../src/sharedWorker.ts', import.meta.url)) - expect(worker).toBeTruthy() - - await expect(sendEventMessage(worker, 'event')).resolves.toBe('event') - await expect(sendOnMessage(worker, 'event')).resolves.toBe('event') -}) - -it('doesn\'t trigger events, if closed', async () => { - const worker = new MySharedWorker() - worker.port.close() - await new Promise((resolve) => { - worker.port.addEventListener('message', () => { - expect.fail('should not trigger message') - }) - worker.port.postMessage('event') - setTimeout(resolve, 100) - }) -}) diff --git a/test/web-worker/vitest.config.ts b/test/web-worker/vitest.config.ts deleted file mode 100644 index e2505eb392e5..000000000000 --- a/test/web-worker/vitest.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { defineConfig } from 'vite' - -export default defineConfig({ - test: { - setupFiles: [ - './setup.ts', - ], - server: { - deps: { - external: [ - /packages\/web-worker/, - ], - }, - }, - onConsoleLog(log) { - return !log.includes('Failed to load') - }, - }, -}) diff --git a/test/workspaces-browser/globalTest.ts b/test/workspaces-browser/globalTest.ts index babae74c9f4e..1adca7ac3620 100644 --- a/test/workspaces-browser/globalTest.ts +++ b/test/workspaces-browser/globalTest.ts @@ -1,7 +1,10 @@ import { readFile } from 'node:fs/promises' import assert from 'node:assert/strict' +let teardownCalled = false + export async function teardown() { + teardownCalled = true const results = JSON.parse(await readFile('./results.json', 'utf-8')) try { @@ -12,6 +15,15 @@ export async function teardown() { } catch (err) { console.error(err) + // eslint-disable-next-line no-console + console.dir(results, { depth: null }) process.exit(1) } } + +process.on('beforeExit', () => { + if (!teardownCalled) { + console.error('teardown was not called') + process.exitCode = 1 + } +}) diff --git a/test/workspaces/globalTest.ts b/test/workspaces/globalTest.ts index 3ad6b6a5421e..771dca6aed17 100644 --- a/test/workspaces/globalTest.ts +++ b/test/workspaces/globalTest.ts @@ -42,6 +42,8 @@ export async function teardown() { } catch (err) { console.error(err) + // eslint-disable-next-line no-console + console.dir(results, { depth: null }) process.exit(1) } } diff --git a/test/workspaces/vitest.config.ts b/test/workspaces/vitest.config.ts index 52540c401d50..ae8998934730 100644 --- a/test/workspaces/vitest.config.ts +++ b/test/workspaces/vitest.config.ts @@ -1,12 +1,6 @@ import { defineConfig } from 'vitest/config' import { cwdPlugin } from './cwdPlugin.js' -if (process.env.TEST_WATCH) { - // Patch stdin on the process so that we can fake it to seem like a real interactive terminal and pass the TTY checks - process.stdin.isTTY = true - process.stdin.setRawMode = () => process.stdin -} - export default defineConfig({ envPrefix: ['VITE_', 'CUSTOM_', 'ROOT_'], plugins: [cwdPlugin('ROOT')], diff --git a/test/workspaces/vitest.config.watch.ts b/test/workspaces/vitest.config.watch.ts new file mode 100644 index 000000000000..42f4e302e396 --- /dev/null +++ b/test/workspaces/vitest.config.watch.ts @@ -0,0 +1,16 @@ +import { defineConfig, mergeConfig } from 'vitest/config' +import vitestConfig from './vitest.config' + +// Patch stdin on the process so that we can fake it to seem like a real interactive terminal and pass the TTY checks +process.stdin.isTTY = true +process.stdin.setRawMode = () => process.stdin + +export default mergeConfig(vitestConfig, defineConfig({ + test: { + coverage: { + enabled: false, + }, + reporters: ['default'], + globalSetup: undefined, + }, +})) diff --git a/test/ws-api/package.json b/test/ws-api/package.json deleted file mode 100644 index 83754d0a26e8..000000000000 --- a/test/ws-api/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "@vitest/test-ws-api", - "type": "module", - "private": true, - "scripts": { - "test": "vitest" - }, - "devDependencies": { - "@vitejs/plugin-basic-ssl": "^1.0.2", - "vitest": "workspace:*" - } -} diff --git a/test/ws-api/vitest.config.ts b/test/ws-api/vitest.config.ts deleted file mode 100644 index f964be2a40cc..000000000000 --- a/test/ws-api/vitest.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - test: { - include: ['tests/**/*.test.ts'], - }, -}) From 48fba19022ebb1f8f9c6f04c90cf5f362513a6a3 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Fri, 26 Apr 2024 15:45:12 +0200 Subject: [PATCH 2/2] fix: use package.json name for a workspace project if not provided (#5608) --- packages/vitest/src/node/plugins/workspace.ts | 19 +++++++++++++++---- test/watch/test/workspaces.test.ts | 6 +++--- test/workspaces/space_3/package.json | 4 ++++ test/workspaces/space_3/vitest.config.ts | 1 - 4 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 test/workspaces/space_3/package.json diff --git a/packages/vitest/src/node/plugins/workspace.ts b/packages/vitest/src/node/plugins/workspace.ts index f6df0efd2c81..d04d29d30639 100644 --- a/packages/vitest/src/node/plugins/workspace.ts +++ b/packages/vitest/src/node/plugins/workspace.ts @@ -1,4 +1,5 @@ -import { basename, dirname, relative } from 'pathe' +import { existsSync, readFileSync } from 'node:fs' +import { basename, dirname, relative, resolve } from 'pathe' import type { UserConfig as ViteConfig, Plugin as VitePlugin } from 'vite' import { configDefaults } from '../../defaults' import { generateScopedClassName } from '../../integrations/css/css-modules' @@ -35,10 +36,20 @@ export function WorkspaceVitestPlugin(project: WorkspaceProject, options: Worksp const root = testConfig.root || viteConfig.root || options.root let name = testConfig.name if (!name) { - if (typeof options.workspacePath === 'string') - name = basename(options.workspacePath.endsWith('/') ? options.workspacePath.slice(0, -1) : dirname(options.workspacePath)) - else + if (typeof options.workspacePath === 'string') { + // if there is a package.json, read the name from it + const dir = options.workspacePath.endsWith('/') + ? options.workspacePath.slice(0, -1) + : dirname(options.workspacePath) + const pkgJsonPath = resolve(dir, 'package.json') + if (existsSync(pkgJsonPath)) + name = JSON.parse(readFileSync(pkgJsonPath, 'utf-8')).name + if (typeof name !== 'string' || !name) + name = basename(dir) + } + else { name = options.workspacePath.toString() + } } const config: ViteConfig = { diff --git a/test/watch/test/workspaces.test.ts b/test/watch/test/workspaces.test.ts index 30fcdbeb0c69..87cff84823d4 100644 --- a/test/watch/test/workspaces.test.ts +++ b/test/watch/test/workspaces.test.ts @@ -65,7 +65,7 @@ it('editing a file that is imported in different workspaces reruns both files', writeFileSync(srcMathFile, `${srcMathContent}\n`, 'utf8') await vitest.waitForStdout('RERUN src/math.ts') - await vitest.waitForStdout('|space_3| math.space-3-test.ts') + await vitest.waitForStdout('|@vitest/space_3| math.space-3-test.ts') await vitest.waitForStdout('|space_1| test/math.spec.ts') await vitest.waitForStdout('Test Files 2 passed') }) @@ -100,7 +100,7 @@ it('adding a new test file matching core project config triggers re-run', async // Test case should not be run by other projects expect(vitest.stdout).not.include('|space_1|') - expect(vitest.stdout).not.include('|space_3|') + expect(vitest.stdout).not.include('|@vitest/space_3|') expect(vitest.stdout).not.include('|node|') expect(vitest.stdout).not.include('|happy-dom|') }) @@ -114,7 +114,7 @@ it('adding a new test file matching project specific config triggers re-run', as await vitest.waitForStdout('Running added dynamic test') await vitest.waitForStdout('RERUN space_3/new-dynamic.space-3-test.ts') - await vitest.waitForStdout('|space_3| new-dynamic.space-3-test.ts') + await vitest.waitForStdout('|@vitest/space_3| new-dynamic.space-3-test.ts') // Wait for tests to end await vitest.waitForStdout('Waiting for file changes') diff --git a/test/workspaces/space_3/package.json b/test/workspaces/space_3/package.json new file mode 100644 index 000000000000..db61b2ef3abf --- /dev/null +++ b/test/workspaces/space_3/package.json @@ -0,0 +1,4 @@ +{ + "name": "@vitest/space_3", + "private": true +} diff --git a/test/workspaces/space_3/vitest.config.ts b/test/workspaces/space_3/vitest.config.ts index 55bdced7da5d..956f9e5c8c84 100644 --- a/test/workspaces/space_3/vitest.config.ts +++ b/test/workspaces/space_3/vitest.config.ts @@ -3,7 +3,6 @@ import { defineProject } from 'vitest/config' export default defineProject({ test: { include: ['**/*.space-3-test.ts'], - name: 'space_3', environment: 'node', globalSetup: './localSetup.ts', },