From aba422a482fa75c458e4554256d65a47ea0be7a3 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 9 Apr 2026 05:45:57 +0700 Subject: [PATCH 01/12] Remove CommonJS support Fixes #3349 --- docs/06-configuration.md | 81 +++-------- docs/08-common-pitfalls.md | 4 +- docs/recipes/babel.md | 18 +-- docs/recipes/debugging-with-vscode.md | 6 +- docs/recipes/puppeteer.md | 6 +- docs/recipes/typescript.md | 18 +-- docs/recipes/vue.md | 57 +------- docs/recipes/watch-mode.md | 2 +- entrypoints/{cli.mjs => cli.js} | 0 ...gin-helper.cjs => eslint-plugin-helper.js} | 23 ++-- entrypoints/{internal.d.mts => internal.d.ts} | 2 +- entrypoints/main.cjs | 2 - entrypoints/main.d.cts | 12 -- entrypoints/{main.d.mts => main.d.ts} | 10 +- entrypoints/{main.mjs => main.js} | 2 +- entrypoints/plugin.cjs | 2 - entrypoints/plugin.d.mts | 6 - entrypoints/{plugin.d.cts => plugin.d.ts} | 4 +- entrypoints/plugin.js | 8 ++ entrypoints/plugin.mjs | 4 - index.d.ts | 4 +- lib/api.js | 2 +- lib/cli.js | 17 +-- lib/create-chain.js | 25 ---- lib/extensions.js | 4 - lib/fork.js | 2 +- lib/{glob-helpers.cjs => glob-helpers.js} | 45 +++---- lib/globs.js | 5 +- ...c-flow-control.cjs => ipc-flow-control.js} | 5 +- lib/load-config.js | 5 +- lib/module-types.js | 45 +++---- lib/{now-and-timers.cjs => now-and-timers.js} | 19 +-- lib/pkg.cjs | 2 - lib/pkg.js | 1 + lib/plugin-support/shared-worker-loader.js | 2 +- lib/provider-manager.js | 2 +- lib/reporters/improper-usage-messages.js | 2 +- lib/runner.js | 2 +- lib/{slash.cjs => slash.js} | 11 +- lib/snapshot-manager.js | 2 +- lib/test.js | 2 +- lib/worker/base.js | 40 ++---- lib/worker/{channel.cjs => channel.js} | 34 +++-- lib/worker/completion-handlers.js | 6 +- ...d-environment.cjs => guard-environment.js} | 9 +- lib/worker/line-numbers.js | 10 +- lib/worker/main.cjs | 12 -- lib/worker/main.js | 11 ++ lib/worker/{options.cjs => options.js} | 9 +- lib/worker/{plugin.cjs => plugin.js} | 16 +-- lib/worker/state.cjs | 6 - lib/worker/state.js | 5 + lib/worker/utils.cjs | 6 - lib/worker/utils.js | 5 + package-lock.json | 4 +- package.json | 26 +--- plugin.d.ts | 2 +- test-tap/api.js | 84 ++++++------ test-tap/assert.js | 4 +- test-tap/eslint-plugin-helper.js | 6 +- .../fixture/{assert.cjs.md => assert.js.md} | 4 +- .../{assert.cjs.snap => assert.js.snap} | Bin .../fixture/ava-paths/target/test.js | 0 test-tap/fixture/caching/test.cjs | 5 - test-tap/fixture/caching/test.js | 5 + test-tap/fixture/cjs.cjs | 5 - ...ion.cjs => error-in-anonymous-function.js} | 2 +- test-tap/fixture/es2015.cjs | 5 - test-tap/fixture/es2015.js | 5 + .../{ava.config.mjs => ava.config.js} | 0 .../{ava.config.mjs => ava.config.js} | 0 test-tap/fixture/extensions/test.foo.bar | 2 +- test-tap/fixture/fail-fast/crash/crashes.cjs | 3 - test-tap/fixture/fail-fast/crash/crashes.js | 3 + test-tap/fixture/fail-fast/crash/passes.cjs | 5 - test-tap/fixture/fail-fast/crash/passes.js | 5 + .../multiple-files/{fails.cjs => fails.js} | 2 +- .../{passes-slow.cjs => passes-slow.js} | 6 +- .../fail-fast/multiple-files/passes.cjs | 5 - .../fail-fast/multiple-files/passes.js | 5 + .../single-file/{test.cjs => test.js} | 2 +- test-tap/fixture/fail-fast/timeout/fails.cjs | 8 -- test-tap/fixture/fail-fast/timeout/fails.js | 8 ++ .../fixture/fail-fast/timeout/passes-slow.cjs | 9 -- .../fixture/fail-fast/timeout/passes-slow.js | 9 ++ test-tap/fixture/fail-fast/timeout/passes.cjs | 5 - test-tap/fixture/fail-fast/timeout/passes.js | 5 + .../fixture/fail-fast/without-error/a.cjs | 3 - test-tap/fixture/fail-fast/without-error/a.js | 3 + .../fail-fast/without-error/{b.cjs => b.js} | 2 +- ...rmatting-color.cjs => formatting-color.js} | 2 +- .../{do-not-compile.cjs => do-not-compile.js} | 0 .../test/helpers/{b.cjs => b.js} | 0 .../globs/cwd/dir-a/test/{bar.cjs => bar.js} | 0 .../globs/cwd/dir-a/test/{foo.cjs => foo.js} | 0 .../globs/cwd/dir-b/test/{baz.cjs => baz.js} | 0 .../directory/__tests__/{_foo.cjs => _foo.js} | 0 .../__tests__/fixtures/{foo.cjs => foo.js} | 0 .../directory/__tests__/{foo.cjs => foo.js} | 0 .../__tests__/helpers/{foo.cjs => foo.js} | 0 .../directory/{bar.spec.cjs => bar.spec.js} | 0 .../directory/{bar.test.cjs => bar.test.js} | 0 .../{test-foo.cjs => test-foo.js} | 0 .../default-patterns/{test.cjs => test.js} | 0 .../test/{_foo-help.cjs => _foo-help.js} | 0 .../default-patterns/test/{baz.cjs => baz.js} | 0 .../test/deep/{deep.cjs => deep.js} | 0 .../fixtures/{foo-fixt.cjs => foo-fixt.js} | 0 .../test/helpers/{test.cjs => test.js} | 0 .../tests/{_foo-help.cjs => _foo-help.js} | 0 .../tests/{baz.cjs => baz.js} | 0 .../tests/deep/{deep.cjs => deep.js} | 0 .../fixtures/{foo-fixt.cjs => foo-fixt.js} | 0 .../tests/helpers/{test.cjs => test.js} | 0 .../{hooks-skipped.cjs => hooks-skipped.js} | 2 +- .../fixture/ignored-dirs/helpers/test.cjs | 5 - test-tap/fixture/ignored-dirs/helpers/test.js | 5 + test-tap/fixture/ignored-dirs/test.cjs | 3 - test-tap/fixture/ignored-dirs/test.js | 3 + ...tack-trace.cjs => infinity-stack-trace.js} | 2 +- test-tap/fixture/js.js | 5 + .../fixture/load-config/cjs/ava.config.cjs | 5 - test-tap/fixture/load-config/cjs/package.json | 1 - .../file-yes-cjs-yes/ava.config.cjs | 3 - .../fixture/load-config/require/ava.config.js | 3 - test-tap/fixture/load-config/require/cjs.cjs | 3 - .../fixture/load-config/require/package.json | 3 - .../{long-running.cjs => long-running.js} | 4 +- ...tch-no-match-2.cjs => match-no-match-2.js} | 2 +- .../{match-no-match.cjs => match-no-match.js} | 2 +- .../{matcher-skip.cjs => matcher-skip.js} | 2 +- test-tap/fixture/mjs.mjs | 2 +- test-tap/fixture/no-tests.cjs | 1 - test-tap/fixture/no-tests.js | 1 + .../{node-env-foo.cjs => node-env-foo.js} | 2 +- .../{node-env-test.cjs => node-env-test.js} | 2 +- .../fail-without-assertions/test.cjs | 3 - .../fail-without-assertions/test.js | 3 + .../custom-comparator/{0-1.cjs => 0-1.js} | 2 +- .../custom-comparator/{0-2.cjs => 0-2.js} | 2 +- .../custom-comparator/{0-3.cjs => 0-3.js} | 2 +- .../custom-comparator/{1-2.cjs => 1-1.js} | 2 +- .../custom-comparator/{1-3.cjs => 1-2.js} | 2 +- .../9.cjs => custom-comparator/1-3.js} | 2 +- .../custom-comparator/{2-1.cjs => 2-1.js} | 2 +- .../custom-comparator/{2-2.cjs => 2-2.js} | 2 +- .../custom-comparator/{2-3.cjs => 2-3.js} | 2 +- .../custom-comparator/ava.config.js | 2 +- .../less-files-than-ci-total/{2.cjs => 2.js} | 2 +- .../1-1.cjs => less-files-than-ci-total/9.js} | 2 +- .../less-files-than-ci-total/package.json | 2 +- .../more-files-than-ci-total/10.cjs | 5 - .../more-files-than-ci-total/10.js | 5 + .../more-files-than-ci-total/2.cjs | 5 - .../more-files-than-ci-total/2.js | 5 + .../more-files-than-ci-total/2a.cjs | 5 - .../more-files-than-ci-total/2a.js | 5 + .../more-files-than-ci-total/9.cjs | 5 - .../more-files-than-ci-total/9.js | 5 + .../{Ab.cjs => Ab.js} | 2 +- .../more-files-than-ci-total/a.cjs | 5 - .../more-files-than-ci-total/a.js | 5 + .../more-files-than-ci-total/{b.cjs => b.js} | 2 +- .../more-files-than-ci-total/c.cjs | 5 - .../more-files-than-ci-total/c.js | 5 + .../more-files-than-ci-total/package.json | 2 +- .../parallel-runs/no-files/package.json | 2 +- test-tap/fixture/pkg-type-module/test.js | 2 +- ...cwd-default.cjs => process-cwd-default.js} | 4 +- test-tap/fixture/process-cwd-pkgdir.cjs | 5 - test-tap/fixture/process-cwd-pkgdir.js | 7 + test-tap/fixture/report/README.md | 2 +- .../report/edgecases/ast-syntax-error.cjs | 7 - .../report/edgecases/ast-syntax-error.js | 7 + .../ava-import-no-test-declaration.cjs | 1 - .../ava-import-no-test-declaration.js | 1 + .../edgecases/import-and-use-test-member.cjs | 3 - .../edgecases/import-and-use-test-member.js | 3 + .../{no-ava-import.cjs => no-ava-import.js} | 0 test-tap/fixture/report/edgecases/test.cjs | 3 - test-tap/fixture/report/edgecases/test.js | 3 + .../edgecases/{throws.cjs => throws.js} | 0 test-tap/fixture/report/failfast/a.cjs | 3 - test-tap/fixture/report/failfast/a.js | 3 + test-tap/fixture/report/failfast/b.cjs | 3 - test-tap/fixture/report/failfast/b.js | 3 + .../fixture/report/failfast2/{a.cjs => a.js} | 2 +- test-tap/fixture/report/failfast2/b.cjs | 3 - test-tap/fixture/report/failfast2/b.js | 3 + test-tap/fixture/report/only/{a.cjs => a.js} | 2 +- test-tap/fixture/report/only/b.cjs | 3 - test-tap/fixture/report/only/b.js | 3 + .../fixture/report/regular/bad-test-chain.cjs | 3 - .../fixture/report/regular/bad-test-chain.js | 3 + .../{nested-objects.cjs => nested-objects.js} | 4 +- .../{output-in-hook.cjs => output-in-hook.js} | 2 +- .../report/regular/{test.cjs => test.js} | 2 +- ...-in-t-throws.cjs => traces-in-t-throws.js} | 2 +- ...ht-exception.cjs => uncaught-exception.js} | 2 +- ...d-rejection.cjs => unhandled-rejection.js} | 2 +- .../report/timeoutcontextlogs/{a.cjs => a.js} | 4 +- .../report/timeoutcontextlogs/{b.cjs => b.js} | 4 +- .../timeoutinmultiplefiles/{a.cjs => a.js} | 4 +- .../timeoutinmultiplefiles/{b.cjs => b.js} | 4 +- .../timeoutinsinglefile/{a.cjs => a.js} | 4 +- .../report/timeoutwithmatch/{a.cjs => a.js} | 4 +- test-tap/fixture/report/watch/test.cjs | 3 - test-tap/fixture/report/watch/test.js | 3 + test-tap/fixture/reset-cache/test.cjs | 3 - test-tap/fixture/reset-cache/test.js | 3 + test-tap/fixture/{serial.cjs => serial.js} | 4 +- test-tap/fixture/skip-only.cjs | 5 - test-tap/fixture/skip-only.js | 5 + .../__tests__/test.js} | 2 +- .../snapshots/test-content/package.json | 2 +- ...st.cjs.md.expected => test.js.md.expected} | 4 +- ...js.snap.expected => test.js.snap.expected} | Bin .../snapshots/test-content/tests/test.cjs | 5 - .../snapshots/test-content/tests/test.js | 5 + .../fixture/snapshots/test-dir/test/test.cjs | 11 -- .../test.cjs => test-dir/test/test.js} | 2 +- .../test-snapshot-location/package.json | 2 +- .../nested-feature/{test.cjs => test.js} | 2 +- .../src/feature/{test.cjs => test.js} | 2 +- .../src/{test.cjs => test.js} | 2 +- .../feature/__tests__/{test.cjs => test.js} | 4 +- .../__tests__/{test.cjs.map => test.js.map} | 2 +- .../test-sourcemaps/build/test.cjs.map | 1 - .../build/{test.cjs => test.js} | 4 +- .../test-sourcemaps/build/test.js.map | 1 + .../build/test/{test.cjs => test.js} | 4 +- .../build/test/{test.cjs.map => test.js.map} | 2 +- .../snapshots/test-sourcemaps/package.json | 2 +- .../src/feature/__tests__/test.ts | 2 +- .../snapshots/test-sourcemaps/src/test.ts | 2 +- .../test-sourcemaps/src/test/test.ts | 2 +- .../snapshots/test-sourcemaps/tsconfig.json | 2 +- .../__tests__/test.cjs => test.js} | 2 +- .../fixture/snapshots/tests-dir/package.json | 2 +- .../snapshots/tests-dir/tests/test.cjs | 11 -- .../fixture/snapshots/tests-dir/tests/test.js | 11 ++ .../{test.cjs => test.js} | 2 +- .../fixture/snapshots/watcher-rerun/test.js | 11 ++ test-tap/fixture/sort-tests/0.cjs | 5 - test-tap/fixture/sort-tests/0.js | 5 + test-tap/fixture/sort-tests/1.cjs | 5 - test-tap/fixture/sort-tests/1.js | 5 + test-tap/fixture/sort-tests/2.cjs | 5 - test-tap/fixture/sort-tests/2.js | 5 + test-tap/fixture/sort-tests/ava.config.js | 2 +- test-tap/fixture/stalled-tests/observable.cjs | 7 - test-tap/fixture/stalled-tests/observable.js | 7 + .../stalled-tests/{promise.cjs => promise.js} | 2 +- test-tap/fixture/symlinkdir/symlink.cjs | 5 - test-tap/fixture/symlinkdir/symlink.js | 5 + test-tap/fixture/symlinkfile.cjs | 1 - test-tap/fixture/symlinkfile.js | 1 + test-tap/fixture/tap/test.cjs | 5 - test-tap/fixture/tap/test.js | 5 + test-tap/fixture/target-symlink.cjs | 5 - test-tap/fixture/target-symlink.js | 5 + .../{test-count-2.cjs => test-count-2.js} | 2 +- .../{test-count-3.cjs => test-count-3.js} | 2 +- .../fixture/{test-count.cjs => test-count.js} | 2 +- ...try-snapshot.cjs.md => try-snapshot.js.md} | 4 +- ...snapshot.cjs.snap => try-snapshot.js.snap} | Bin .../fixture/with-dependencies/no-tests.cjs | 3 - .../fixture/with-dependencies/no-tests.js | 3 + .../with-dependencies/require-custom.cjs | 2 - .../with-dependencies/test-failure.cjs | 9 -- .../fixture/with-dependencies/test-failure.js | 9 ++ .../test-uncaught-exception.cjs | 13 -- .../test-uncaught-exception.js | 13 ++ test-tap/fixture/with-dependencies/test.cjs | 9 -- test-tap/fixture/with-dependencies/test.js | 9 ++ test-tap/fixture/worker-argv.cjs | 5 - test-tap/fixture/worker-argv.js | 7 + test-tap/globs.js | 34 ++--- test-tap/helper/cli.js | 2 +- test-tap/helper/report.js | 17 ++- test-tap/hooks.js | 2 +- test-tap/integration/assorted.js | 30 ++--- test-tap/integration/debug.js | 6 +- test-tap/integration/repl.js | 2 +- test-tap/integration/snapshots.js | 50 +++---- test-tap/integration/stack-traces.js | 10 +- test-tap/integration/stalled.js | 4 +- test-tap/node-arguments.js | 4 +- test-tap/promise.js | 2 +- test-tap/reporters/default.edgecases.v22.log | 30 ++--- test-tap/reporters/default.edgecases.v24.log | 30 ++--- test-tap/reporters/default.edgecases.v25.log | 32 ++--- test-tap/reporters/default.failfast.v22.log | 4 +- test-tap/reporters/default.failfast.v24.log | 4 +- test-tap/reporters/default.failfast.v25.log | 4 +- test-tap/reporters/default.failfast2.v22.log | 4 +- test-tap/reporters/default.failfast2.v24.log | 4 +- test-tap/reporters/default.failfast2.v25.log | 4 +- test-tap/reporters/default.js | 2 +- test-tap/reporters/default.regular.v22.log | 88 ++++++------ test-tap/reporters/default.regular.v24.log | 88 ++++++------ test-tap/reporters/default.regular.v25.log | 88 ++++++------ .../default.timeoutcontextlogs.v22.log | 4 +- .../default.timeoutcontextlogs.v24.log | 4 +- .../default.timeoutcontextlogs.v25.log | 4 +- .../default.timeoutinmultiplefiles.v22.log | 4 +- .../default.timeoutinmultiplefiles.v24.log | 4 +- .../default.timeoutinmultiplefiles.v25.log | 4 +- .../default.timeoutinsinglefile.v22.log | 2 +- .../default.timeoutinsinglefile.v24.log | 2 +- .../default.timeoutinsinglefile.v25.log | 2 +- .../default.timeoutwithmatch.v22.log | 2 +- .../default.timeoutwithmatch.v24.log | 2 +- .../default.timeoutwithmatch.v25.log | 2 +- test-tap/reporters/prefix-title.js | 25 ++-- test-tap/reporters/tap.edgecases.v22.log | 16 +-- test-tap/reporters/tap.edgecases.v24.log | 16 +-- test-tap/reporters/tap.edgecases.v25.log | 20 ++- test-tap/reporters/tap.failfast2.v22.log | 2 +- test-tap/reporters/tap.failfast2.v24.log | 2 +- test-tap/reporters/tap.failfast2.v25.log | 2 +- test-tap/reporters/tap.js | 2 +- test-tap/reporters/tap.regular.v22.log | 22 +-- test-tap/reporters/tap.regular.v24.log | 22 +-- test-tap/reporters/tap.regular.v25.log | 22 +-- test-tap/runner.js | 2 +- test-tap/test-try-commit.js | 2 +- test-tap/test.js | 6 +- test-tap/try-snapshot.js | 4 +- .../assertions-as-type-guards.cts | 62 --------- .../import-in-cts/conditional-chains.cts | 14 -- test-types/import-in-cts/context.cts | 33 ----- test-types/import-in-cts/deep-equal.cts | 29 ---- .../import-in-cts/implementation-result.cts | 20 --- test-types/import-in-cts/like.cts | 25 ---- test-types/import-in-cts/macros.cts | 126 ------------------ test-types/import-in-cts/plugin.cts | 18 --- test-types/import-in-cts/snapshot.cts | 16 --- test-types/import-in-cts/teardown.cts | 6 - test-types/import-in-cts/throws.cts | 49 ------- test-types/import-in-cts/timeout.cts | 6 - test-types/import-in-cts/try-commit.cts | 67 ---------- .../module/assertions-as-type-guards.ts | 2 +- test-types/module/conditional-chains.ts | 2 +- test-types/module/context.ts | 4 +- test-types/module/deep-equal.ts | 2 +- test-types/module/implementation-result.ts | 2 +- test-types/module/like.ts | 2 +- test-types/module/macros.ts | 4 +- test-types/module/snapshot.ts | 2 +- test-types/module/teardown.ts | 2 +- test-types/module/throws.ts | 2 +- test-types/module/timeout.ts | 2 +- test-types/module/try-commit.ts | 4 +- test/cjs-default/fixtures/package.json | 7 - test/cjs-default/fixtures/test.cjs | 20 --- test/cjs-default/test.js | 7 - .../fixtures/exports-default/package.json | 2 +- .../fixtures/exports-default/required.cjs | 5 - .../fixtures/exports-default/required.js | 7 + .../fixtures/exports-default/test.js | 4 +- .../fixtures/non-json/ava.config.js | 2 +- .../non-json/{required.mjs => required.js} | 0 test/config-require/fixtures/non-json/test.js | 2 +- .../fixtures/with-arguments/ava.config.js | 4 +- .../{required.mjs => required-esm.js} | 0 .../{required.cjs => required.js} | 2 +- .../fixtures/with-arguments/test.js | 6 +- test/config-require/test.js | 2 +- .../file-yes-cjs-yes-mjs-yes/ava.config.cjs | 3 - .../file-yes-cjs-yes-mjs-yes/ava.config.js | 3 - .../file-yes-cjs-yes-mjs-yes/package.json | 3 - .../file-yes-js-yes-mjs-yes}/ava.config.js | 0 .../ava.config.mjs | 0 .../file-yes-js-yes-mjs-yes}/package.json | 0 test/config/fixtures/js-as-cjs/ava.config.js | 3 - test/config/fixtures/js-as-cjs/package.json | 1 - .../ava.config.js} | 0 .../dir-a-wrapper/dir-a/dir-a-wrapper-3.js} | 0 .../dir-a-wrapper/dir-a/dir-a-wrapper-4.js} | 0 .../dir-a/dir-a-base-1.js} | 0 .../js-with-tests/dir-a/dir-a-base-2.js | 2 +- .../package.json | 0 test/config/integration.js | 6 +- test/config/loader.js | 10 -- test/config/next-gen.js | 7 +- test/config/snapshots/integration.js.md | 2 +- test/config/snapshots/integration.js.snap | Bin 564 -> 563 bytes test/config/snapshots/loader.js.md | 8 +- test/config/snapshots/loader.js.snap | Bin 638 -> 608 bytes test/config/snapshots/next-gen.js.md | 4 +- test/config/snapshots/next-gen.js.snap | Bin 367 -> 359 bytes test/configurable-module-format/commonjs.js | 27 ---- test/configurable-module-format/custom.js | 17 --- .../fixtures/array-custom.config.js | 3 - .../fixtures/array-extensions.config.js | 2 +- .../fixtures/bad-custom-type.config.js | 2 +- .../fixtures/change-cjs-loading.config.js | 5 - .../fixtures/change-mjs-loading.config.js | 2 +- .../fixtures/object-custom.config.js | 6 - .../fixtures/object-extensions.config.js | 1 - .../fixtures/test.cjs | 5 - .../fixtures/test.cts | 8 -- .../invalid-configurations.js | 7 +- .../snapshots/invalid-configurations.js.md | 14 +- .../snapshots/invalid-configurations.js.snap | Bin 293 -> 273 bytes test/create-chain/test.js | 9 -- test/helpers/exec.js | 10 +- .../{simulate-tty.cjs => simulate-tty.js} | 3 +- test/idle-timeouts/test.js | 7 +- test/meta/fixtures/{meta.cjs => meta.js} | 7 +- test/meta/test.js | 4 +- .../node-arguments-from-config.js | 2 +- .../node-arguments-from-config/package.json | 4 +- .../{setup.cjs => setup.js} | 0 ....mjs => thread-arguments-filter.config.js} | 0 test/node-arguments/snapshots/test.js.snap | Bin 556 -> 560 bytes test/node-arguments/test.js | 4 +- .../{disabled-cache.cjs => disabled-cache.js} | 2 +- test/scheduler/test.js | 4 +- test/snapshot-regenerate-report/test.js | 2 +- .../fixtures/fixed-snapshot-dir/test.js | 2 +- .../fixtures/no-snapshots/test.js | 2 +- .../fixtures/only-test/test.js | 2 +- .../snapshot-removal/fixtures/removal/test.js | 2 +- .../fixtures/skipped-snapshots-in-try/test.js | 2 +- .../fixtures/skipped-snapshots/test.js | 2 +- .../fixtures/skipped-tests/test.js | 2 +- .../fixtures/snapshot-dir/test/test.js | 2 +- test/snapshot-removal/fixtures/try/test.js | 2 +- test/snapshot-tests/fixtures/corrupt/test.js | 2 +- test/snapshot-tests/fixtures/large/test.js | 4 +- .../fixtures/multiline-snapshot-label/test.js | 2 +- .../normalized-title-in-snapshots/test.js | 3 +- .../normalized-title-in-stdout/test.js | 2 +- .../fixtures/adding-skipped-snapshots/test.js | 2 +- .../fixtures/adding-snapshots/test.js | 2 +- .../fixtures/adding-test/test.js | 2 +- .../fixtures/changing-label/test.js | 2 +- .../fixtures/changing-title/test.js | 2 +- .../fixtures/commit-skip/test.js | 2 +- .../fixtures/discard-skip/test.js | 2 +- .../fixtures/filling-in-blanks/test.js | 2 +- .../fixtures/first-run/test.js | 2 +- .../fixtures/invalid-snapfile/test.js | 2 +- .../fixtures/removing-all-snapshots/test.js | 2 +- .../fixtures/removing-snapshots/test.js | 2 +- .../fixtures/removing-test/test.js | 2 +- .../fixtures/reorder/test.js | 2 +- .../fixtures/select-test-update/test.js | 2 +- .../fixtures/skipping-snapshot-update/test.js | 2 +- .../fixtures/skipping-snapshot/test.js | 2 +- .../fixtures/skipping-test-update/test.js | 2 +- .../fixtures/skipping-test/test.js | 2 +- ...ess.config.mjs => child-process.config.js} | 0 test/worker-threads/test.js | 2 +- types/{assertions.d.cts => assertions.d.ts} | 0 ...shared-worker.d.cts => shared-worker.d.ts} | 0 ...-events.d.cts => state-change-events.d.ts} | 0 .../{subscribable.d.cts => subscribable.d.ts} | 0 types/{test-fn.d.cts => test-fn.d.ts} | 6 +- types/{try-fn.d.cts => try-fn.d.ts} | 3 +- xo.config.mjs => xo.config.js | 2 +- 463 files changed, 1087 insertions(+), 1995 deletions(-) rename entrypoints/{cli.mjs => cli.js} (100%) rename entrypoints/{eslint-plugin-helper.cjs => eslint-plugin-helper.js} (84%) rename entrypoints/{internal.d.mts => internal.d.ts} (94%) delete mode 100644 entrypoints/main.cjs delete mode 100644 entrypoints/main.d.cts rename entrypoints/{main.d.mts => main.d.ts} (69%) rename entrypoints/{main.mjs => main.js} (62%) delete mode 100644 entrypoints/plugin.cjs delete mode 100644 entrypoints/plugin.d.mts rename entrypoints/{plugin.d.cts => plugin.d.ts} (61%) create mode 100644 entrypoints/plugin.js delete mode 100644 entrypoints/plugin.mjs rename lib/{glob-helpers.cjs => glob-helpers.js} (72%) rename lib/{ipc-flow-control.cjs => ipc-flow-control.js} (90%) rename lib/{now-and-timers.cjs => now-and-timers.js} (50%) delete mode 100644 lib/pkg.cjs create mode 100644 lib/pkg.js rename lib/{slash.cjs => slash.js} (80%) rename lib/worker/{channel.cjs => channel.js} (84%) rename lib/worker/{guard-environment.cjs => guard-environment.js} (59%) delete mode 100644 lib/worker/main.cjs create mode 100644 lib/worker/main.js rename lib/worker/{options.cjs => options.js} (74%) rename lib/worker/{plugin.cjs => plugin.js} (85%) delete mode 100644 lib/worker/state.cjs create mode 100644 lib/worker/state.js delete mode 100644 lib/worker/utils.cjs create mode 100644 lib/worker/utils.js rename test-tap/fixture/{assert.cjs.md => assert.js.md} (69%) rename test-tap/fixture/{assert.cjs.snap => assert.js.snap} (100%) rename test/config/fixtures/mjs-with-tests/dir-a-wrapper/dir-a/dir-a-wrapper-3.js => test-tap/fixture/ava-paths/target/test.js (100%) delete mode 100644 test-tap/fixture/caching/test.cjs create mode 100644 test-tap/fixture/caching/test.js delete mode 100644 test-tap/fixture/cjs.cjs rename test-tap/fixture/{error-in-anonymous-function.cjs => error-in-anonymous-function.js} (69%) delete mode 100644 test-tap/fixture/es2015.cjs create mode 100644 test-tap/fixture/es2015.js rename test-tap/fixture/eslint-plugin-helper/{ava.config.mjs => ava.config.js} (100%) rename test-tap/fixture/eslint-plugin-helper/for-overriding/{ava.config.mjs => ava.config.js} (100%) delete mode 100644 test-tap/fixture/fail-fast/crash/crashes.cjs create mode 100644 test-tap/fixture/fail-fast/crash/crashes.js delete mode 100644 test-tap/fixture/fail-fast/crash/passes.cjs create mode 100644 test-tap/fixture/fail-fast/crash/passes.js rename test-tap/fixture/fail-fast/multiple-files/{fails.cjs => fails.js} (83%) rename test-tap/fixture/fail-fast/multiple-files/{passes-slow.cjs => passes-slow.js} (73%) delete mode 100644 test-tap/fixture/fail-fast/multiple-files/passes.cjs create mode 100644 test-tap/fixture/fail-fast/multiple-files/passes.js rename test-tap/fixture/fail-fast/single-file/{test.cjs => test.js} (68%) delete mode 100644 test-tap/fixture/fail-fast/timeout/fails.cjs create mode 100644 test-tap/fixture/fail-fast/timeout/fails.js delete mode 100644 test-tap/fixture/fail-fast/timeout/passes-slow.cjs create mode 100644 test-tap/fixture/fail-fast/timeout/passes-slow.js delete mode 100644 test-tap/fixture/fail-fast/timeout/passes.cjs create mode 100644 test-tap/fixture/fail-fast/timeout/passes.js delete mode 100644 test-tap/fixture/fail-fast/without-error/a.cjs create mode 100644 test-tap/fixture/fail-fast/without-error/a.js rename test-tap/fixture/fail-fast/without-error/{b.cjs => b.js} (53%) rename test-tap/fixture/{formatting-color.cjs => formatting-color.js} (53%) rename test-tap/fixture/globs/custom-extension/test/{do-not-compile.cjs => do-not-compile.js} (100%) rename test-tap/fixture/globs/custom-extension/test/helpers/{b.cjs => b.js} (100%) rename test-tap/fixture/globs/cwd/dir-a/test/{bar.cjs => bar.js} (100%) rename test-tap/fixture/globs/cwd/dir-a/test/{foo.cjs => foo.js} (100%) rename test-tap/fixture/globs/cwd/dir-b/test/{baz.cjs => baz.js} (100%) rename test-tap/fixture/globs/default-patterns/sub/directory/__tests__/{_foo.cjs => _foo.js} (100%) rename test-tap/fixture/globs/default-patterns/sub/directory/__tests__/fixtures/{foo.cjs => foo.js} (100%) rename test-tap/fixture/globs/default-patterns/sub/directory/__tests__/{foo.cjs => foo.js} (100%) rename test-tap/fixture/globs/default-patterns/sub/directory/__tests__/helpers/{foo.cjs => foo.js} (100%) rename test-tap/fixture/globs/default-patterns/sub/directory/{bar.spec.cjs => bar.spec.js} (100%) rename test-tap/fixture/globs/default-patterns/sub/directory/{bar.test.cjs => bar.test.js} (100%) rename test-tap/fixture/globs/default-patterns/{test-foo.cjs => test-foo.js} (100%) rename test-tap/fixture/globs/default-patterns/{test.cjs => test.js} (100%) rename test-tap/fixture/globs/default-patterns/test/{_foo-help.cjs => _foo-help.js} (100%) rename test-tap/fixture/globs/default-patterns/test/{baz.cjs => baz.js} (100%) rename test-tap/fixture/globs/default-patterns/test/deep/{deep.cjs => deep.js} (100%) rename test-tap/fixture/globs/default-patterns/test/fixtures/{foo-fixt.cjs => foo-fixt.js} (100%) rename test-tap/fixture/globs/default-patterns/test/helpers/{test.cjs => test.js} (100%) rename test-tap/fixture/globs/default-patterns/tests/{_foo-help.cjs => _foo-help.js} (100%) rename test-tap/fixture/globs/default-patterns/tests/{baz.cjs => baz.js} (100%) rename test-tap/fixture/globs/default-patterns/tests/deep/{deep.cjs => deep.js} (100%) rename test-tap/fixture/globs/default-patterns/tests/fixtures/{foo-fixt.cjs => foo-fixt.js} (100%) rename test-tap/fixture/globs/default-patterns/tests/helpers/{test.cjs => test.js} (100%) rename test-tap/fixture/{hooks-skipped.cjs => hooks-skipped.js} (85%) delete mode 100644 test-tap/fixture/ignored-dirs/helpers/test.cjs create mode 100644 test-tap/fixture/ignored-dirs/helpers/test.js delete mode 100644 test-tap/fixture/ignored-dirs/test.cjs create mode 100644 test-tap/fixture/ignored-dirs/test.js rename test-tap/fixture/{infinity-stack-trace.cjs => infinity-stack-trace.js} (71%) create mode 100644 test-tap/fixture/js.js delete mode 100644 test-tap/fixture/load-config/cjs/ava.config.cjs delete mode 100644 test-tap/fixture/load-config/cjs/package.json delete mode 100644 test-tap/fixture/load-config/file-yes-cjs-yes/ava.config.cjs delete mode 100644 test-tap/fixture/load-config/require/ava.config.js delete mode 100644 test-tap/fixture/load-config/require/cjs.cjs delete mode 100644 test-tap/fixture/load-config/require/package.json rename test-tap/fixture/{long-running.cjs => long-running.js} (54%) rename test-tap/fixture/{match-no-match-2.cjs => match-no-match-2.js} (76%) rename test-tap/fixture/{match-no-match.cjs => match-no-match.js} (68%) rename test-tap/fixture/{matcher-skip.cjs => matcher-skip.js} (79%) delete mode 100644 test-tap/fixture/no-tests.cjs create mode 100644 test-tap/fixture/no-tests.js rename test-tap/fixture/{node-env-foo.cjs => node-env-foo.js} (61%) rename test-tap/fixture/{node-env-test.cjs => node-env-test.js} (62%) delete mode 100644 test-tap/fixture/package-config/fail-without-assertions/test.cjs create mode 100644 test-tap/fixture/package-config/fail-without-assertions/test.js rename test-tap/fixture/parallel-runs/custom-comparator/{0-1.cjs => 0-1.js} (57%) rename test-tap/fixture/parallel-runs/custom-comparator/{0-2.cjs => 0-2.js} (57%) rename test-tap/fixture/parallel-runs/custom-comparator/{0-3.cjs => 0-3.js} (57%) rename test-tap/fixture/parallel-runs/custom-comparator/{1-2.cjs => 1-1.js} (57%) rename test-tap/fixture/parallel-runs/custom-comparator/{1-3.cjs => 1-2.js} (57%) rename test-tap/fixture/parallel-runs/{less-files-than-ci-total/9.cjs => custom-comparator/1-3.js} (57%) rename test-tap/fixture/parallel-runs/custom-comparator/{2-1.cjs => 2-1.js} (57%) rename test-tap/fixture/parallel-runs/custom-comparator/{2-2.cjs => 2-2.js} (57%) rename test-tap/fixture/parallel-runs/custom-comparator/{2-3.cjs => 2-3.js} (57%) rename test-tap/fixture/parallel-runs/less-files-than-ci-total/{2.cjs => 2.js} (57%) rename test-tap/fixture/parallel-runs/{custom-comparator/1-1.cjs => less-files-than-ci-total/9.js} (57%) delete mode 100644 test-tap/fixture/parallel-runs/more-files-than-ci-total/10.cjs create mode 100644 test-tap/fixture/parallel-runs/more-files-than-ci-total/10.js delete mode 100644 test-tap/fixture/parallel-runs/more-files-than-ci-total/2.cjs create mode 100644 test-tap/fixture/parallel-runs/more-files-than-ci-total/2.js delete mode 100644 test-tap/fixture/parallel-runs/more-files-than-ci-total/2a.cjs create mode 100644 test-tap/fixture/parallel-runs/more-files-than-ci-total/2a.js delete mode 100644 test-tap/fixture/parallel-runs/more-files-than-ci-total/9.cjs create mode 100644 test-tap/fixture/parallel-runs/more-files-than-ci-total/9.js rename test-tap/fixture/parallel-runs/more-files-than-ci-total/{Ab.cjs => Ab.js} (67%) delete mode 100644 test-tap/fixture/parallel-runs/more-files-than-ci-total/a.cjs create mode 100644 test-tap/fixture/parallel-runs/more-files-than-ci-total/a.js rename test-tap/fixture/parallel-runs/more-files-than-ci-total/{b.cjs => b.js} (57%) delete mode 100644 test-tap/fixture/parallel-runs/more-files-than-ci-total/c.cjs create mode 100644 test-tap/fixture/parallel-runs/more-files-than-ci-total/c.js rename test-tap/fixture/{process-cwd-default.cjs => process-cwd-default.js} (74%) delete mode 100644 test-tap/fixture/process-cwd-pkgdir.cjs create mode 100644 test-tap/fixture/process-cwd-pkgdir.js delete mode 100644 test-tap/fixture/report/edgecases/ast-syntax-error.cjs create mode 100644 test-tap/fixture/report/edgecases/ast-syntax-error.js delete mode 100644 test-tap/fixture/report/edgecases/ava-import-no-test-declaration.cjs create mode 100644 test-tap/fixture/report/edgecases/ava-import-no-test-declaration.js delete mode 100644 test-tap/fixture/report/edgecases/import-and-use-test-member.cjs create mode 100644 test-tap/fixture/report/edgecases/import-and-use-test-member.js rename test-tap/fixture/report/edgecases/{no-ava-import.cjs => no-ava-import.js} (100%) delete mode 100644 test-tap/fixture/report/edgecases/test.cjs create mode 100644 test-tap/fixture/report/edgecases/test.js rename test-tap/fixture/report/edgecases/{throws.cjs => throws.js} (100%) delete mode 100644 test-tap/fixture/report/failfast/a.cjs create mode 100644 test-tap/fixture/report/failfast/a.js delete mode 100644 test-tap/fixture/report/failfast/b.cjs create mode 100644 test-tap/fixture/report/failfast/b.js rename test-tap/fixture/report/failfast2/{a.cjs => a.js} (51%) delete mode 100644 test-tap/fixture/report/failfast2/b.cjs create mode 100644 test-tap/fixture/report/failfast2/b.js rename test-tap/fixture/report/only/{a.cjs => a.js} (53%) delete mode 100644 test-tap/fixture/report/only/b.cjs create mode 100644 test-tap/fixture/report/only/b.js delete mode 100644 test-tap/fixture/report/regular/bad-test-chain.cjs create mode 100644 test-tap/fixture/report/regular/bad-test-chain.js rename test-tap/fixture/report/regular/{nested-objects.cjs => nested-objects.js} (85%) rename test-tap/fixture/report/regular/{output-in-hook.cjs => output-in-hook.js} (88%) rename test-tap/fixture/report/regular/{test.cjs => test.js} (88%) rename test-tap/fixture/report/regular/{traces-in-t-throws.cjs => traces-in-t-throws.js} (91%) rename test-tap/fixture/report/regular/{uncaught-exception.cjs => uncaught-exception.js} (64%) rename test-tap/fixture/report/regular/{unhandled-rejection.cjs => unhandled-rejection.js} (78%) rename test-tap/fixture/report/timeoutcontextlogs/{a.cjs => a.js} (77%) rename test-tap/fixture/report/timeoutcontextlogs/{b.cjs => b.js} (73%) rename test-tap/fixture/report/timeoutinmultiplefiles/{a.cjs => a.js} (63%) rename test-tap/fixture/report/timeoutinmultiplefiles/{b.cjs => b.js} (69%) rename test-tap/fixture/report/timeoutinsinglefile/{a.cjs => a.js} (62%) rename test-tap/fixture/report/timeoutwithmatch/{a.cjs => a.js} (70%) delete mode 100644 test-tap/fixture/report/watch/test.cjs create mode 100644 test-tap/fixture/report/watch/test.js delete mode 100644 test-tap/fixture/reset-cache/test.cjs create mode 100644 test-tap/fixture/reset-cache/test.js rename test-tap/fixture/{serial.cjs => serial.js} (69%) delete mode 100644 test-tap/fixture/skip-only.cjs create mode 100644 test-tap/fixture/skip-only.js rename test-tap/fixture/snapshots/{test.cjs => __tests__-dir/__tests__/test.js} (72%) rename test-tap/fixture/snapshots/test-content/{test.cjs.md.expected => test.js.md.expected} (53%) rename test-tap/fixture/snapshots/test-content/{test.cjs.snap.expected => test.js.snap.expected} (100%) delete mode 100644 test-tap/fixture/snapshots/test-content/tests/test.cjs create mode 100644 test-tap/fixture/snapshots/test-content/tests/test.js delete mode 100644 test-tap/fixture/snapshots/test-dir/test/test.cjs rename test-tap/fixture/snapshots/{watcher-rerun/test.cjs => test-dir/test/test.js} (71%) rename test-tap/fixture/snapshots/test-snapshot-location/src/feature/nested-feature/{test.cjs => test.js} (72%) rename test-tap/fixture/snapshots/test-snapshot-location/src/feature/{test.cjs => test.js} (71%) rename test-tap/fixture/snapshots/test-snapshot-location/src/{test.cjs => test.js} (70%) rename test-tap/fixture/snapshots/test-sourcemaps/build/feature/__tests__/{test.cjs => test.js} (62%) rename test-tap/fixture/snapshots/test-sourcemaps/build/feature/__tests__/{test.cjs.map => test.js.map} (95%) delete mode 100644 test-tap/fixture/snapshots/test-sourcemaps/build/test.cjs.map rename test-tap/fixture/snapshots/test-sourcemaps/build/{test.cjs => test.js} (64%) create mode 100644 test-tap/fixture/snapshots/test-sourcemaps/build/test.js.map rename test-tap/fixture/snapshots/test-sourcemaps/build/test/{test.cjs => test.js} (60%) rename test-tap/fixture/snapshots/test-sourcemaps/build/test/{test.cjs.map => test.js.map} (95%) rename test-tap/fixture/snapshots/{__tests__-dir/__tests__/test.cjs => test.js} (70%) delete mode 100644 test-tap/fixture/snapshots/tests-dir/tests/test.cjs create mode 100644 test-tap/fixture/snapshots/tests-dir/tests/test.js rename test-tap/fixture/snapshots/watcher-rerun-unlink/{test.cjs => test.js} (83%) create mode 100644 test-tap/fixture/snapshots/watcher-rerun/test.js delete mode 100644 test-tap/fixture/sort-tests/0.cjs create mode 100644 test-tap/fixture/sort-tests/0.js delete mode 100644 test-tap/fixture/sort-tests/1.cjs create mode 100644 test-tap/fixture/sort-tests/1.js delete mode 100644 test-tap/fixture/sort-tests/2.cjs create mode 100644 test-tap/fixture/sort-tests/2.js delete mode 100644 test-tap/fixture/stalled-tests/observable.cjs create mode 100644 test-tap/fixture/stalled-tests/observable.js rename test-tap/fixture/stalled-tests/{promise.cjs => promise.js} (50%) delete mode 100644 test-tap/fixture/symlinkdir/symlink.cjs create mode 100644 test-tap/fixture/symlinkdir/symlink.js delete mode 120000 test-tap/fixture/symlinkfile.cjs create mode 120000 test-tap/fixture/symlinkfile.js delete mode 100644 test-tap/fixture/tap/test.cjs create mode 100644 test-tap/fixture/tap/test.js delete mode 100644 test-tap/fixture/target-symlink.cjs create mode 100644 test-tap/fixture/target-symlink.js rename test-tap/fixture/{test-count-2.cjs => test-count-2.js} (74%) rename test-tap/fixture/{test-count-3.cjs => test-count-3.js} (78%) rename test-tap/fixture/{test-count.cjs => test-count.js} (74%) rename test-tap/fixture/{try-snapshot.cjs.md => try-snapshot.js.md} (75%) rename test-tap/fixture/{try-snapshot.cjs.snap => try-snapshot.js.snap} (100%) delete mode 100644 test-tap/fixture/with-dependencies/no-tests.cjs create mode 100644 test-tap/fixture/with-dependencies/no-tests.js delete mode 100644 test-tap/fixture/with-dependencies/require-custom.cjs delete mode 100644 test-tap/fixture/with-dependencies/test-failure.cjs create mode 100644 test-tap/fixture/with-dependencies/test-failure.js delete mode 100644 test-tap/fixture/with-dependencies/test-uncaught-exception.cjs create mode 100644 test-tap/fixture/with-dependencies/test-uncaught-exception.js delete mode 100644 test-tap/fixture/with-dependencies/test.cjs create mode 100644 test-tap/fixture/with-dependencies/test.js delete mode 100644 test-tap/fixture/worker-argv.cjs create mode 100644 test-tap/fixture/worker-argv.js delete mode 100644 test-types/import-in-cts/assertions-as-type-guards.cts delete mode 100644 test-types/import-in-cts/conditional-chains.cts delete mode 100644 test-types/import-in-cts/context.cts delete mode 100644 test-types/import-in-cts/deep-equal.cts delete mode 100644 test-types/import-in-cts/implementation-result.cts delete mode 100644 test-types/import-in-cts/like.cts delete mode 100644 test-types/import-in-cts/macros.cts delete mode 100644 test-types/import-in-cts/plugin.cts delete mode 100644 test-types/import-in-cts/snapshot.cts delete mode 100644 test-types/import-in-cts/teardown.cts delete mode 100644 test-types/import-in-cts/throws.cts delete mode 100644 test-types/import-in-cts/timeout.cts delete mode 100644 test-types/import-in-cts/try-commit.cts delete mode 100644 test/cjs-default/fixtures/package.json delete mode 100644 test/cjs-default/fixtures/test.cjs delete mode 100644 test/cjs-default/test.js delete mode 100644 test/config-require/fixtures/exports-default/required.cjs create mode 100644 test/config-require/fixtures/exports-default/required.js rename test/config-require/fixtures/non-json/{required.mjs => required.js} (100%) rename test/config-require/fixtures/with-arguments/{required.mjs => required-esm.js} (100%) rename test/config-require/fixtures/with-arguments/{required.cjs => required.js} (78%) delete mode 100644 test/config/fixtures/file-yes-cjs-yes-mjs-yes/ava.config.cjs delete mode 100644 test/config/fixtures/file-yes-cjs-yes-mjs-yes/ava.config.js delete mode 100644 test/config/fixtures/file-yes-cjs-yes-mjs-yes/package.json rename {test-tap/fixture/load-config/file-yes-cjs-yes => test/config/fixtures/file-yes-js-yes-mjs-yes}/ava.config.js (100%) rename test/config/fixtures/{file-yes-cjs-yes-mjs-yes => file-yes-js-yes-mjs-yes}/ava.config.mjs (100%) rename {test-tap/fixture/load-config/file-yes-cjs-yes => test/config/fixtures/file-yes-js-yes-mjs-yes}/package.json (100%) delete mode 100644 test/config/fixtures/js-as-cjs/ava.config.js delete mode 100644 test/config/fixtures/js-as-cjs/package.json rename test/config/fixtures/{mjs-with-tests/ava.config.mjs => js-with-tests/ava.config.js} (100%) rename test/config/fixtures/{mjs-with-tests/dir-a-wrapper/dir-a/dir-a-wrapper-4.js => js-with-tests/dir-a-wrapper/dir-a/dir-a-wrapper-3.js} (100%) rename test/config/fixtures/{mjs-with-tests/dir-a/dir-a-base-1.js => js-with-tests/dir-a-wrapper/dir-a/dir-a-wrapper-4.js} (100%) rename test/config/fixtures/{mjs-with-tests/dir-a/dir-a-base-2.js => js-with-tests/dir-a/dir-a-base-1.js} (100%) rename test-tap/fixture/ava-paths/target/test.cjs => test/config/fixtures/js-with-tests/dir-a/dir-a-base-2.js (55%) rename test/config/fixtures/{mjs-with-tests => js-with-tests}/package.json (100%) delete mode 100644 test/configurable-module-format/commonjs.js delete mode 100644 test/configurable-module-format/custom.js delete mode 100644 test/configurable-module-format/fixtures/array-custom.config.js delete mode 100644 test/configurable-module-format/fixtures/change-cjs-loading.config.js delete mode 100644 test/configurable-module-format/fixtures/object-custom.config.js delete mode 100644 test/configurable-module-format/fixtures/test.cjs delete mode 100644 test/configurable-module-format/fixtures/test.cts rename test/helpers/{simulate-tty.cjs => simulate-tty.js} (96%) rename test/meta/fixtures/{meta.cjs => meta.js} (61%) rename test/node-arguments/fixtures/node-arguments-from-config/{setup.cjs => setup.js} (100%) rename test/node-arguments/fixtures/thread-arguments-filter/{thread-arguments-filter.config.mjs => thread-arguments-filter.config.js} (100%) rename test/scheduler/fixtures/{disabled-cache.cjs => disabled-cache.js} (68%) rename test/worker-threads/fixtures/{child-process.config.mjs => child-process.config.js} (100%) rename types/{assertions.d.cts => assertions.d.ts} (100%) rename types/{shared-worker.d.cts => shared-worker.d.ts} (100%) rename types/{state-change-events.d.cts => state-change-events.d.ts} (100%) rename types/{subscribable.d.cts => subscribable.d.ts} (100%) rename types/{test-fn.d.cts => test-fn.d.ts} (98%) rename types/{try-fn.d.cts => try-fn.d.ts} (96%) rename xo.config.mjs => xo.config.js (97%) diff --git a/docs/06-configuration.md b/docs/06-configuration.md index c3941f41a..cdced2713 100644 --- a/docs/06-configuration.md +++ b/docs/06-configuration.md @@ -42,7 +42,7 @@ Arguments passed to the CLI will always take precedence over the CLI options con ## Options -- `files`: an array of glob patterns to select test files. Files with an underscore prefix are ignored. By default only selects files with `cjs`, `mjs` & `js` extensions, even if the pattern matches other files. Specify `extensions` to allow other file extensions +- `files`: an array of glob patterns to select test files. Files with an underscore prefix are ignored. By default only selects files with `mjs` & `js` extensions, even if the pattern matches other files. Specify `extensions` to allow other file extensions - `watchMode`: See the [watch mode recipe for details](https://github.com/avajs/ava/blob/main/docs/recipes/watch-mode.md) - `match`: not typically useful in the `package.json` configuration, but equivalent to [specifying `--match` on the CLI](./05-command-line.md#running-tests-with-matching-titles) - `cache`: defaults to `true` to cache compiled files under `node_modules/.cache/ava`. If `false`, files are cached in a temporary directory instead @@ -55,7 +55,7 @@ Arguments passed to the CLI will always take precedence over the CLI options con - `tap`: if `true`, enables the [TAP reporter](./05-command-line.md#tap-reporter) - `verbose`: if `true`, enables verbose output (though there currently non-verbose output is not supported) - `snapshotDir`: specifies a fixed location for storing snapshot files. Use this if your snapshots are ending up in the wrong location -- `extensions`: extensions of test files. Setting this overrides the default `["cjs", "mjs", "js"]` value, so make sure to include those extensions in the list. [Experimentally you can configure how files are loaded](#configuring-module-formats) +- `extensions`: extensions of test files. Setting this overrides the default `["mjs", "js"]` value, so make sure to include those extensions in the list. [Experimentally you can configure how files are loaded](#configuring-module-formats) - `require`: [extra modules to load before test files](#requiring-extra-modules) - `timeout`: Timeouts in AVA behave differently than in other test frameworks. AVA resets a timer after each test, forcing tests to quit if no new test results were received within the specified timeout. This can be used to handle stalled tests. See our [timeout documentation](./07-test-timeouts.md) for more options. - `nodeArguments`: Configure Node.js arguments used to launch worker processes. @@ -68,18 +68,18 @@ Provide the `typescript` option (and install [`@ava/typescript`](https://github. ## Using `ava.config.*` files -Rather than specifying the configuration in the `package.json` file you can use `ava.config.js`, `ava.config.cjs` or `ava.config.mjs` files. +Rather than specifying the configuration in the `package.json` file you can use an `ava.config.js` file. If your project does not already treat `.js` files as ES modules, use `ava.config.mjs` instead. To use these files: 1. Your `package.json` must not contain an `ava` property (or, if it does, it must be an empty object) -2. You must only have one `ava.config.*` file in any directory, so don't mix `ava.config.js` *and* `ava.config.cjs` files +2. You must only have one `ava.config.*` file in any directory, so don't mix `ava.config.js` *and* `ava.config.mjs` files AVA searches your file system for `ava.config.*` files. First, when you run AVA, it finds the closest `package.json`. Starting in that directory it recursively checks the parent directories until it either reaches the file system root or encounters a `.git` file or directory. The first `ava.config.*` file found is selected. This allows you to use a single configuration file in a monorepo setup. ### `ava.config.js` -AVA follows Node.js' behavior, so if you've set `"type": "module"` you must use ESM, and otherwise you must use CommonJS. +Prefer `ava.config.js` when your project already treats `.js` files as ES modules, for example through `"type": "module"` in `package.json`. The default export can either be a plain object or a factory function which returns a plain object. You can export or return a promise for a plain object: @@ -113,44 +113,10 @@ export default ({projectDir}) => { }; ``` -### `ava.config.cjs` - -For `ava.config.cjs` files you must assign `module.exports`. ["Module scope"](https://nodejs.org/docs/latest-v12.x/api/modules.html#modules_the_module_scope) is available. You can `require()` dependencies. - -The module export can either be a plain object or a factory function which returns a plain object. You can export or return a promise for a plain object: - -```js -module.exports = { - require: ['./_my-test-helper.js'] -}; -``` - -```js -module.exports = () => { - return { - require: ['./_my-test-helper.js'] - }; -}; -``` - -The factory function is called with an object containing a `projectDir` property, which you could use to change the returned configuration: - -```js -module.exports = ({projectDir}) => { - if (projectDir === '/Users/username/projects/my-project') { - return { - // Config A - }; - } - - return { - // Config B - }; -}; -``` - ### `ava.config.mjs` +Use `ava.config.mjs` when you need the filename itself to opt into ESM. + The default export can either be a plain object or a factory function which returns a plain object. You can export or return a promise for a plain object: ```js @@ -185,32 +151,32 @@ export default ({projectDir}) => { ## Alternative configuration files -The [CLI] lets you specify a specific configuration file, using the `--config` flag. This file must have either a `.js`, `.cjs` or `.mjs` extension and is processed like an `ava.config.js`, `ava.config.cjs` or `ava.config.mjs` file would be. +The [CLI] lets you specify a specific configuration file, using the `--config` flag. Prefer a `.js` file. Use `.mjs` only when your project does not already treat `.js` files as ESM. -When the `--config` flag is set, the provided file will override all configuration from the `package.json` and `ava.config.js`, `ava.config.cjs` or `ava.config.mjs` files. The configuration is not merged. +When the `--config` flag is set, the provided file will override all configuration from the `package.json` and `ava.config.js` or `ava.config.mjs` files. The configuration is not merged. You can use this to customize configuration for a specific test run. For instance, you may want to run unit tests separately from integration tests: -`ava.config.cjs`: +`ava.config.js`: ```js -module.exports = { +export default { files: ['unit-tests/**/*'] }; ``` -`integration-tests.config.cjs`: +`integration-tests.config.js`: ```js -const baseConfig = require('./ava.config.cjs'); +import baseConfig from './ava.config.js'; -module.exports = { +export default { ...baseConfig, files: ['integration-tests/**/*'] }; ``` -You can now run your unit tests through `npx ava` and the integration tests through `npx ava --config integration-tests.config.cjs`. +You can now run your unit tests through `npx ava` and the integration tests through `npx ava --config integration-tests.config.js`. ## Object printing depth @@ -247,7 +213,7 @@ export default { Node.js can only load non-standard extension as ES Modules when using [experimental loaders](https://nodejs.org/docs/latest/api/esm.html#esm_experimental_loaders). To use this you'll also have to configure AVA to `import()` your test file. -As with the array form, you need to explicitly list `js`, `cjs`, and `mjs` extensions. These **must** be set using the `true` value; other extensions are configurable using either `'commonjs'` or `'module'`: +As with the array form, you need to explicitly list `js` and `mjs` extensions. These **must** be set using the `true` value; other extensions are configurable using `'module'`: `ava.config.js`: ```js @@ -286,21 +252,6 @@ export default function () { } ``` -`_my-test-helper.cjs`: -```js -module.exports = function () { - // Additional setup -} -``` - -In CJS files, a `default` export is also supported: - -```js -exports.default = function () { - // Never called -} -``` - You can provide arguments: `ava.config.js`: diff --git a/docs/08-common-pitfalls.md b/docs/08-common-pitfalls.md index 9a2533fa0..1680d9f83 100644 --- a/docs/08-common-pitfalls.md +++ b/docs/08-common-pitfalls.md @@ -91,7 +91,7 @@ It is best practice to make sure your code exits cleanly. We've also seen occurr For these reasons we're not providing an option to disable this timeout behavior. However, it is possible to register a callback for when AVA has completed the test run without uncaught exceptions or unhandled rejections. From inside this callback you can do whatever you need to do, including calling `process.exit()`. -Create a `_force-exit.mjs` file: +Create a `_force-exit.js` file: ```js import process from 'node:process'; @@ -108,7 +108,7 @@ Load it for all test files through AVA's `require` option: ```js export default { - require: ['./_force-exit.mjs'], + require: ['./_force-exit.js'], }; ``` diff --git a/docs/recipes/babel.md b/docs/recipes/babel.md index 5e41bb7d0..5f8dcad8b 100644 --- a/docs/recipes/babel.md +++ b/docs/recipes/babel.md @@ -2,20 +2,6 @@ Translations: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/recipes/babel.md) -You can enable Babel support by installing [`@babel/register`](https://babeljs.io/docs/en/babel-register) and `@babel/core`, and then in AVA's configuration requiring `@babel/register`: +AVA is ESM-only. [`@babel/register`](https://babeljs.io/docs/en/babel-register) only hooks legacy `require()` loading, so this setup is no longer supported. -**`package.json`:** - -```json -{ - "ava": { - "require": [ - "@babel/register" - ] - } -} -``` - -`@babel/register` is compatible with CommonJS only. It intercepts `require()` calls and compiles files on the fly. This will compile source, helper and test files. - -For more information visit the [Babel documentation](https://babeljs.io/docs/en/babel-register). +If you need Babel, precompile your files before running AVA or use an ESM-capable loader configured through [`nodeArguments`](../06-configuration.md#node-arguments). diff --git a/docs/recipes/debugging-with-vscode.md b/docs/recipes/debugging-with-vscode.md index 854b0b1bd..6a74cb6e2 100644 --- a/docs/recipes/debugging-with-vscode.md +++ b/docs/recipes/debugging-with-vscode.md @@ -26,7 +26,7 @@ Alternatively you can create a launch configuration, which makes it easier to de "type": "node", "request": "launch", "name": "Debug AVA test file", - "program": "${workspaceFolder}/node_modules/ava/entrypoints/cli.mjs", + "program": "${workspaceFolder}/node_modules/ava/entrypoints/cli.js", "args": [ "${file}" ], @@ -56,7 +56,7 @@ Assuming the names of your test files are unique you could try the following con "type": "node", "request": "launch", "name": "Debug AVA test file", - "program": "${workspaceFolder}/node_modules/ava/entrypoints/cli.mjs", + "program": "${workspaceFolder}/node_modules/ava/entrypoints/cli.js", "args": [ "build/**/${fileBasenameNoExtension}.*" ], @@ -103,7 +103,7 @@ Or, if you're using a launch configuration, add the `--serial` argument: "type": "node", "request": "launch", "name": "Debug AVA test file", - "program": "${workspaceFolder}/node_modules/ava/entrypoints/cli.mjs", + "program": "${workspaceFolder}/node_modules/ava/entrypoints/cli.js", "args": [ "--serial", "${file}" diff --git a/docs/recipes/puppeteer.md b/docs/recipes/puppeteer.md index 9565f3ce1..6a4f3420b 100644 --- a/docs/recipes/puppeteer.md +++ b/docs/recipes/puppeteer.md @@ -15,7 +15,7 @@ The first step is setting up a helper to configure the environment: ```js import puppeteer from 'puppeteer'; -module.exports = async (t, run) => { +export default async (t, run) => { const browser = await puppeteer.launch(); const page = await browser.newPage(); try { @@ -24,7 +24,7 @@ module.exports = async (t, run) => { await page.close(); await browser.close(); } -} +}; ``` ## Usage example @@ -33,7 +33,7 @@ module.exports = async (t, run) => { ```js import test from 'ava'; -import withPage from './_withPage'; +import withPage from './_withPage.js'; const url = 'https://google.com'; diff --git a/docs/recipes/typescript.md b/docs/recipes/typescript.md index d7f55f2b5..7d7dd69d5 100644 --- a/docs/recipes/typescript.md +++ b/docs/recipes/typescript.md @@ -50,7 +50,7 @@ There are two components to a setup like this: [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/avajs/ava/tree/main/examples/typescript-basic?file=source%2Ftest.ts&terminal=test&view=editor) -Create a `test.ts` file. ESM syntax works best, even if you're targeting CommonJS. +Create a `test.ts` file using ESM syntax. ```ts import test from 'ava'; @@ -62,22 +62,6 @@ test('fn() returns foo', t => { }); ``` -You can use CommonJS syntax as well: - -```ts -const test = require('ava'); -``` - -This works whether `esModuleInterop` is enabled or not. - -`import … = require()` syntax is less elegant. It's best like this: - -```ts -import ava = require('ava') - -const test = ava.default; -``` - ## Using [macros](../01-writing-tests.md#reusing-test-logic-through-macros) Macros can receive additional arguments. AVA can infer these to ensure you're using the macro correctly: diff --git a/docs/recipes/vue.md b/docs/recipes/vue.md index 922bf06a5..83a5b0ae0 100644 --- a/docs/recipes/vue.md +++ b/docs/recipes/vue.md @@ -13,62 +13,11 @@ Translations: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs - Optional: [babel-plugin-webpack-alias-7](https://github.com/shortminds/babel-plugin-webpack-alias-7) if you want to use [webpack aliases](https://webpack.js.org/configuration/resolve/#resolve-alias) or use them in your source files - `npm i --save-dev babel-plugin-webpack-alias-7` -## Setup +## Status -The first step is setting up a helper to configure the environment to transpile `.vue` files and run in a browser like environment. +This recipe relied on legacy `require()` hooks. AVA is ESM-only, so this setup is no longer supported. -**`package.json`:** - -```json -{ - "ava": { - "require": [ - "./test/_setup.js" - ] - } -} -``` - -```js -// ./test/_setup.cjs - -// Set up JSDom. -const jsdomGlobal = require('jsdom-global'); -jsdomGlobal(); - -// Fix the Date object, see . -window.Date = Date - -// Setup browser environment -const hooks = require('require-extension-hooks'); -const Vue = require('vue'); - -// Setup Vue.js to remove production tip -Vue.config.productionTip = false; - -// Setup vue files to be processed by `require-extension-hooks-vue` -hooks('vue').plugin('vue').push(); -// Setup vue and js files to be processed by `require-extension-hooks-babel` -hooks(['vue', 'js']).exclude(({filename}) => filename.match(/\/node_modules\//)).plugin('babel').push(); -``` - -**Note:** If you are using _babel-plugin-webpack-alias-7_, you must also exclude your webpack file - e.g. `filename.includes(/\/node_modules\//) || filename.includes('webpack.config.test.js')` - -## Sample snapshot test - -```js -const test = require('ava'); -const Vue = require('vue'); -const Component = require('component.vue'); - -test('renders', t => { - const vm = new Vue(Component).$mount(); - const tree = { - $el: vm.$el.outerHTML - }; - t.snapshot(tree); -}); -``` +Precompile your Vue components before running AVA, or use tooling that provides an ESM loader for `.vue` files. ## Coverage reporting diff --git a/docs/recipes/watch-mode.md b/docs/recipes/watch-mode.md index 0cee6b54f..097ba59e1 100644 --- a/docs/recipes/watch-mode.md +++ b/docs/recipes/watch-mode.md @@ -66,7 +66,7 @@ Afterwards you can use the `r` command to run the matched tests again, or `a` co AVA tracks which source files your test files depend on. If you change such a dependency only the test file that depends on it will be rerun. AVA will rerun all tests if it cannot determine which test file depends on the changed source file. -Dependency tracking works for `require()` and `import` syntax, as supported by [@vercel/nft](https://github.com/vercel/nft). `import()` is supported but dynamic paths such as `import(myVariable)` are not. +Dependency tracking works for static `import` syntax, as supported by [@vercel/nft](https://github.com/vercel/nft). `import()` is supported but dynamic paths such as `import(myVariable)` are not. Files accessed using the `fs` module are not tracked. diff --git a/entrypoints/cli.mjs b/entrypoints/cli.js similarity index 100% rename from entrypoints/cli.mjs rename to entrypoints/cli.js diff --git a/entrypoints/eslint-plugin-helper.cjs b/entrypoints/eslint-plugin-helper.js similarity index 84% rename from entrypoints/eslint-plugin-helper.cjs rename to entrypoints/eslint-plugin-helper.js index 61a223371..acbd0c935 100644 --- a/entrypoints/eslint-plugin-helper.cjs +++ b/entrypoints/eslint-plugin-helper.js @@ -1,17 +1,16 @@ -'use strict'; -const path = require('node:path'); -const url = require('node:url'); -const v8 = require('node:v8'); -const {Worker} = require('node:worker_threads'); +import path from 'node:path'; +import {pathToFileURL} from 'node:url'; +import v8 from 'node:v8'; +import {Worker} from 'node:worker_threads'; -const { +import { classify, hasExtension, isHelperish, matches, normalizeFileForMatching, normalizePatterns, -} = require('../lib/glob-helpers.cjs'); +} from '../lib/glob-helpers.js'; const MAX_DATA_LENGTH_EXCLUSIVE = 100 * 1024; // Allocate 100 KiB to exchange globs. @@ -27,8 +26,8 @@ const resolveGlobsSync = (projectDir, overrideExtensions, overrideFiles) => { const syncBuffer = new SharedArrayBuffer(4); sync = new Int32Array(syncBuffer); - const filename = path.join(__dirname, '../lib/eslint-plugin-helper-worker.js'); - worker = new Worker(url.pathToFileURL(filename), { + const filename = path.join(import.meta.dirname, '../lib/eslint-plugin-helper-worker.js'); + worker = new Worker(pathToFileURL(filename), { workerData: { dataBuffer, syncBuffer, @@ -60,7 +59,7 @@ const resolveGlobsSync = (projectDir, overrideExtensions, overrideFiles) => { const helperCache = new Map(); -function load(projectDir, overrides) { +export function load(projectDir, overrides) { const cacheKey = `${JSON.stringify(overrides)}\n${projectDir}`; if (helperCache.has(cacheKey)) { return helperCache.get(cacheKey); @@ -69,7 +68,7 @@ function load(projectDir, overrides) { let helperPatterns = []; if (overrides && overrides.helpers !== undefined) { if (!Array.isArray(overrides.helpers) || overrides.helpers.length === 0) { - throw new Error('The ’helpers’ override must be an array containing glob patterns.'); + throw new Error('The \u2018helpers\u2019 override must be an array containing glob patterns.'); } helperPatterns = normalizePatterns(overrides.helpers); @@ -105,5 +104,3 @@ function load(projectDir, overrides) { helperCache.set(cacheKey, helper); return helper; } - -exports.load = load; diff --git a/entrypoints/internal.d.mts b/entrypoints/internal.d.ts similarity index 94% rename from entrypoints/internal.d.mts rename to entrypoints/internal.d.ts index 8afc573ea..89ee48d08 100644 --- a/entrypoints/internal.d.mts +++ b/entrypoints/internal.d.ts @@ -1,4 +1,4 @@ -import type {StateChangeEvent} from '../types/state-change-events.d.cts'; +import type {StateChangeEvent} from '../types/state-change-events.js'; export type Event = StateChangeEvent; diff --git a/entrypoints/main.cjs b/entrypoints/main.cjs deleted file mode 100644 index c0a5562b4..000000000 --- a/entrypoints/main.cjs +++ /dev/null @@ -1,2 +0,0 @@ -'use strict'; -module.exports = require('../lib/worker/main.cjs'); diff --git a/entrypoints/main.d.cts b/entrypoints/main.d.cts deleted file mode 100644 index a59c71ea2..000000000 --- a/entrypoints/main.d.cts +++ /dev/null @@ -1,12 +0,0 @@ -import type {TestFn} from '../types/test-fn.cjs'; - -export type * from '../types/assertions.cjs'; -export type * from '../types/try-fn.cjs'; -export type * from '../types/test-fn.cjs'; -export type * from '../types/subscribable.cjs'; - -/** Call to declare a test, or chain to declare hooks or test modifiers */ -declare const test: TestFn; - -/** Call to declare a test, or chain to declare hooks or test modifiers */ -export default test; diff --git a/entrypoints/main.d.mts b/entrypoints/main.d.ts similarity index 69% rename from entrypoints/main.d.mts rename to entrypoints/main.d.ts index bfdbbbda1..3f32521a2 100644 --- a/entrypoints/main.d.mts +++ b/entrypoints/main.d.ts @@ -1,9 +1,9 @@ -import type {TestFn} from '../types/test-fn.cjs'; +import type {TestFn} from '../types/test-fn.js'; -export type * from '../types/assertions.cjs'; -export type * from '../types/try-fn.cjs'; -export type * from '../types/test-fn.cjs'; -export type * from '../types/subscribable.cjs'; +export type * from '../types/assertions.js'; +export type * from '../types/try-fn.js'; +export type * from '../types/test-fn.js'; +export type * from '../types/subscribable.js'; /** Call to declare a test, or chain to declare hooks or test modifiers */ declare const test: TestFn; diff --git a/entrypoints/main.mjs b/entrypoints/main.js similarity index 62% rename from entrypoints/main.mjs rename to entrypoints/main.js index fec379316..98bccbd1f 100644 --- a/entrypoints/main.mjs +++ b/entrypoints/main.js @@ -1,2 +1,2 @@ -export {default} from '../lib/worker/main.cjs'; +export {default} from '../lib/worker/main.js'; export {registerCompletionHandler} from '../lib/worker/completion-handlers.js'; diff --git a/entrypoints/plugin.cjs b/entrypoints/plugin.cjs deleted file mode 100644 index 9c594ad0a..000000000 --- a/entrypoints/plugin.cjs +++ /dev/null @@ -1,2 +0,0 @@ -'use strict'; -module.exports = require('../lib/worker/plugin.cjs'); diff --git a/entrypoints/plugin.d.mts b/entrypoints/plugin.d.mts deleted file mode 100644 index 9e5871101..000000000 --- a/entrypoints/plugin.d.mts +++ /dev/null @@ -1,6 +0,0 @@ -import type {SharedWorker} from '../types/shared-worker.cjs'; - -export function registerSharedWorker(options: SharedWorker.Plugin.RegistrationOptions<'ava-4', Data>): SharedWorker.Plugin.Protocol; -// Add overloads for additional protocols. - -export type {SharedWorker} from '../types/shared-worker.cjs'; diff --git a/entrypoints/plugin.d.cts b/entrypoints/plugin.d.ts similarity index 61% rename from entrypoints/plugin.d.cts rename to entrypoints/plugin.d.ts index 9e5871101..06d750e62 100644 --- a/entrypoints/plugin.d.cts +++ b/entrypoints/plugin.d.ts @@ -1,6 +1,6 @@ -import type {SharedWorker} from '../types/shared-worker.cjs'; +import type {SharedWorker} from '../types/shared-worker.js'; export function registerSharedWorker(options: SharedWorker.Plugin.RegistrationOptions<'ava-4', Data>): SharedWorker.Plugin.Protocol; // Add overloads for additional protocols. -export type {SharedWorker} from '../types/shared-worker.cjs'; +export type {SharedWorker} from '../types/shared-worker.js'; diff --git a/entrypoints/plugin.js b/entrypoints/plugin.js new file mode 100644 index 000000000..26442d45c --- /dev/null +++ b/entrypoints/plugin.js @@ -0,0 +1,8 @@ +import {registerSharedWorker} from '../lib/worker/plugin.js'; + +const plugin = { + registerSharedWorker, +}; + +export default plugin; +export {registerSharedWorker} from '../lib/worker/plugin.js'; diff --git a/entrypoints/plugin.mjs b/entrypoints/plugin.mjs deleted file mode 100644 index f777eb4f7..000000000 --- a/entrypoints/plugin.mjs +++ /dev/null @@ -1,4 +0,0 @@ -import * as plugin from '../lib/worker/plugin.cjs'; - -const {registerSharedWorker} = plugin; -export {registerSharedWorker}; diff --git a/index.d.ts b/index.d.ts index 66c0e85d2..b6b883d29 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,4 +1,4 @@ // For compatibility with resolution algorithms other than Node16. -export * from './entrypoints/main.cjs'; -export {default} from './entrypoints/main.cjs'; +export * from './entrypoints/main.js'; +export {default} from './entrypoints/main.js'; diff --git a/lib/api.js b/lib/api.js index c4f5fa034..7c6403da2 100644 --- a/lib/api.js +++ b/lib/api.js @@ -15,7 +15,7 @@ import fork from './fork.js'; import * as globs from './globs.js'; import isCi from './is-ci.js'; import {getApplicableLineNumbers} from './line-numbers.js'; -import {setCappedTimeout} from './now-and-timers.cjs'; +import {setCappedTimeout} from './now-and-timers.js'; import {observeWorkerProcess} from './plugin-support/shared-workers.js'; import RunStatus from './run-status.js'; import scheduler from './scheduler.js'; diff --git a/lib/cli.js b/lib/cli.js index f198391b3..a970e8a66 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -19,7 +19,7 @@ import {splitPatternAndLineNumbers} from './line-numbers.js'; import {loadConfig} from './load-config.js'; import normalizeModuleTypes from './module-types.js'; import normalizeNodeArguments from './node-arguments.js'; -import pkg from './pkg.cjs'; +import pkg from './pkg.js'; function exit(message) { console.error(`\n ${chalk.red(figures.cross)} ${message}`); @@ -334,16 +334,7 @@ export default async function loadCli() { // eslint-disable-line complexity console.log(chalk.magenta(` ${figures.warning} Experiments are enabled. These are unsupported and may change or be removed at any time.`)); } - let projectPackageObject; - try { - projectPackageObject = JSON.parse(fs.readFileSync(path.resolve(projectDir, 'package.json'))); - } catch (error) { - if (error.code !== 'ENOENT') { - throw error; - } - } - - const {type: defaultModuleType = 'commonjs'} = projectPackageObject ?? {}; + const defaultModuleType = 'module'; const providers = []; if (Object.hasOwn(conf, 'typescript')) { @@ -377,7 +368,7 @@ export default async function loadCli() { // eslint-disable-line complexity let moduleTypes; try { - moduleTypes = normalizeModuleTypes(conf.extensions, defaultModuleType, experiments); + moduleTypes = normalizeModuleTypes(conf.extensions, defaultModuleType); } catch (error) { exit(error.message); } @@ -472,7 +463,7 @@ export default async function loadCli() { // eslint-disable-line complexity } if (process.env.TEST_AVA) { - const {controlFlow} = await import('./ipc-flow-control.cjs'); + const {controlFlow} = await import('./ipc-flow-control.js'); const bufferedSend = controlFlow(process); api.on('run', ({data: plan}) => { diff --git a/lib/create-chain.js b/lib/create-chain.js index 5b7e0c1ca..aa8edf5f3 100644 --- a/lib/create-chain.js +++ b/lib/create-chain.js @@ -169,30 +169,5 @@ export default function createChain(fn, defaults, meta) { root.meta = meta; - // The ESM and CJS type definitions export the chain (`test()` function) as - // the default. TypeScript's CJS output (when `esModuleInterop` is disabled) - // assume `require('ava').default` is available. The same goes for `import ava - // = require('ava')` syntax. - // - // Add `test.default` to make this work. Use a proxy to avoid - // `test.default.default` chains. - Object.defineProperty(root, 'default', { - configurable: false, - enumerable: false, - writable: false, - value: new Proxy(root, { - apply(target, thisArg, argumentsList) { - target.apply(thisArg, argumentsList); - }, - get(target, prop) { - if (prop === 'default') { - throw new TypeError('Cannot access default.default'); - } - - return target[prop]; - }, - }), - }); - return root; } diff --git a/lib/extensions.js b/lib/extensions.js index cd9696307..dd8b7dc2b 100644 --- a/lib/extensions.js +++ b/lib/extensions.js @@ -29,10 +29,6 @@ export default function resolveExtensions(configuredExtensions, providers = []) // Unless the default was used by providers, as long as the extensions aren't explicitly set, set the default. if (configuredExtensions === undefined) { - if (!seen.has('cjs')) { - seen.add('cjs'); - } - if (!seen.has('mjs')) { seen.add('mjs'); } diff --git a/lib/fork.js b/lib/fork.js index 140626cb7..bab356bc8 100644 --- a/lib/fork.js +++ b/lib/fork.js @@ -5,7 +5,7 @@ import {Worker} from 'node:worker_threads'; import Emittery from 'emittery'; -import {controlFlow} from './ipc-flow-control.cjs'; +import {controlFlow} from './ipc-flow-control.js'; import serializeError, {tagWorkerError} from './serialize-error.js'; let workerPath = new URL('worker/base.js', import.meta.url); diff --git a/lib/glob-helpers.cjs b/lib/glob-helpers.js similarity index 72% rename from lib/glob-helpers.cjs rename to lib/glob-helpers.js index 2c10b589c..a2248408d 100644 --- a/lib/glob-helpers.cjs +++ b/lib/glob-helpers.js @@ -1,14 +1,13 @@ -'use strict'; -const path = require('node:path'); -const process = require('node:process'); +import path from 'node:path'; +import process from 'node:process'; -const ignoreByDefault = require('ignore-by-default'); -const picomatch = require('picomatch'); +import ignoreByDefault from 'ignore-by-default'; +import picomatch from 'picomatch'; -const slash = require('./slash.cjs'); +import slash from './slash.js'; const defaultIgnorePatterns = [...ignoreByDefault.directories(), '**/node_modules']; -exports.defaultIgnorePatterns = defaultIgnorePatterns; +export {defaultIgnorePatterns}; const defaultPicomatchIgnorePatterns = [ ...defaultIgnorePatterns, @@ -42,22 +41,20 @@ const processMatchingPatterns = input => { return result; }; -exports.processMatchingPatterns = processMatchingPatterns; +export {processMatchingPatterns}; -function classify(file, {cwd, extensions, filePatterns}) { +export function classify(file, {cwd, extensions, filePatterns}) { file = normalizeFileForMatching(cwd, file); return { isTest: hasExtension(extensions, file) && !isHelperish(file) && filePatterns.length > 0 && matches(file, filePatterns), }; } -exports.classify = classify; - -const hasExtension = (extensions, file) => extensions.includes(path.extname(file).slice(1)); - -exports.hasExtension = hasExtension; +export function hasExtension(extensions, file) { + return extensions.includes(path.extname(file).slice(1)); +} -function isHelperish(file) { // Assume file has been normalized already. +export function isHelperish(file) { // Assume file has been normalized already. // File names starting with an underscore are deemed "helpers". if (path.basename(file).startsWith('_')) { return true; @@ -75,16 +72,12 @@ function isHelperish(file) { // Assume file has been normalized already. return path.dirname(file).split('/').some(dir => /^_(?:$|[^_])/.test(dir)); } -exports.isHelperish = isHelperish; - -function matches(file, patterns) { +export function matches(file, patterns) { const {match} = processMatchingPatterns(patterns); return match(file); } -exports.matches = matches; - -function normalizeFileForMatching(cwd, file) { +export function normalizeFileForMatching(cwd, file) { if (process.platform === 'win32') { cwd = slash(cwd); file = slash(file); @@ -101,9 +94,7 @@ function normalizeFileForMatching(cwd, file) { return file.slice(cwd.length + 1); } -exports.normalizeFileForMatching = normalizeFileForMatching; - -function normalizePattern(pattern) { +export function normalizePattern(pattern) { // Always use `/` in patterns, harmonizing matching across platforms if (process.platform === 'win32') { pattern = slash(pattern); @@ -124,10 +115,6 @@ function normalizePattern(pattern) { return pattern; } -exports.normalizePattern = normalizePattern; - -function normalizePatterns(patterns) { +export function normalizePatterns(patterns) { return patterns.map(pattern => normalizePattern(pattern)); } - -exports.normalizePatterns = normalizePatterns; diff --git a/lib/globs.js b/lib/globs.js index 622ff4691..a92a15650 100644 --- a/lib/globs.js +++ b/lib/globs.js @@ -10,7 +10,7 @@ import { normalizeFileForMatching, normalizePatterns, processMatchingPatterns, -} from './glob-helpers.cjs'; +} from './glob-helpers.js'; export { classify, @@ -21,13 +21,12 @@ export { hasExtension, normalizeFileForMatching, normalizePatterns, -} from './glob-helpers.cjs'; +} from './glob-helpers.js'; const defaultIgnoredByWatcherPatterns = [ '**/*.snap.md', // No need to rerun tests when the Markdown files change. '**/*.tsbuildinfo', // No need to rerun tests when TypeScript build info files change. 'ava.config.js', // Config is not reloaded so avoid rerunning tests when it changes. - 'ava.config.cjs', // Config is not reloaded so avoid rerunning tests when it changes. 'ava.config.mjs', // Config is not reloaded so avoid rerunning tests when it changes. ]; diff --git a/lib/ipc-flow-control.cjs b/lib/ipc-flow-control.js similarity index 90% rename from lib/ipc-flow-control.cjs rename to lib/ipc-flow-control.js index 7a7d5d0e9..62356017d 100644 --- a/lib/ipc-flow-control.cjs +++ b/lib/ipc-flow-control.js @@ -1,5 +1,4 @@ -'use strict'; -function controlFlow(channel) { +export function controlFlow(channel) { let errored = false; let deliverImmediately = true; @@ -36,5 +35,3 @@ function controlFlow(channel) { } }; } - -exports.controlFlow = controlFlow; diff --git a/lib/load-config.js b/lib/load-config.js index be7b36d96..44ecfde37 100644 --- a/lib/load-config.js +++ b/lib/load-config.js @@ -94,8 +94,8 @@ export async function loadConfig({configFile, resolveFrom = process.cwd(), defau try { loaded = await loadConfigFile({projectDir, configFile}); } catch (error) { - if (!configFile.endsWith('.js') && !configFile.endsWith('.cjs') && !configFile.endsWith('.mjs')) { - throw Object.assign(new Error('Could not load config file; it should have .js, .cjs or .mjs extension'), {cause: error}); + if (!configFile.endsWith('.js') && !configFile.endsWith('.mjs')) { + throw Object.assign(new Error('Could not load config file; it should have .js or .mjs extension'), {cause: error}); } throw error; @@ -111,7 +111,6 @@ export async function loadConfig({configFile, resolveFrom = process.cwd(), defau const [jsonFile, ...results] = await Promise.all([ // eslint-disable-line no-await-in-loop checkJsonFile(searchDir), loadConfigFile({projectDir, configFile: path.join(searchDir, 'ava.config.js')}), - loadConfigFile({projectDir, configFile: path.join(searchDir, 'ava.config.cjs')}), loadConfigFile({projectDir, configFile: path.join(searchDir, 'ava.config.mjs')}), ]); diff --git a/lib/module-types.js b/lib/module-types.js index 91e7a16ca..577c59fb6 100644 --- a/lib/module-types.js +++ b/lib/module-types.js @@ -1,29 +1,24 @@ -const requireTrueValue = value => { +const requireTrueValue = (value, extension) => { if (value !== true) { - throw new TypeError('When specifying module types, use `true` for ’cjs’, ’mjs’ and ’js’ extensions'); + throw new TypeError(`When specifying module types, use \`true\` for \u2018${extension}\u2019 extensions`); } }; -const normalize = (extension, type, defaultModuleType) => { +const normalize = (extension, type) => { switch (extension) { - case 'cjs': { - requireTrueValue(type); - return 'commonjs'; - } - case 'mjs': { - requireTrueValue(type); + requireTrueValue(type, extension); return 'module'; } case 'js': { - requireTrueValue(type); - return defaultModuleType; + requireTrueValue(type, extension); + return 'module'; } default: { - if (type !== 'commonjs' && type !== 'module') { - throw new TypeError(`Module type for ’${extension}’ must be ’commonjs’ or ’module’`); + if (type !== 'module') { + throw new TypeError(`Module type for \u2018${extension}\u2019 must be \u2018module\u2019`); } return type; @@ -31,36 +26,31 @@ const normalize = (extension, type, defaultModuleType) => { } }; -const deriveFromObject = (extensionsObject, defaultModuleType) => { +const deriveFromObject = extensionsObject => { const moduleTypes = {}; for (const [extension, type] of Object.entries(extensionsObject)) { - moduleTypes[extension] = normalize(extension, type, defaultModuleType); + moduleTypes[extension] = normalize(extension, type); } return moduleTypes; }; -const deriveFromArray = (extensions, defaultModuleType) => { +const deriveFromArray = extensions => { const moduleTypes = {}; for (const extension of extensions) { switch (extension) { - case 'cjs': { - moduleTypes.cjs = 'commonjs'; - break; - } - case 'mjs': { moduleTypes.mjs = 'module'; break; } case 'js': { - moduleTypes.js = defaultModuleType; + moduleTypes.js = 'module'; break; } default: { - moduleTypes[extension] = 'commonjs'; + moduleTypes[extension] = 'module'; } } } @@ -68,18 +58,17 @@ const deriveFromArray = (extensions, defaultModuleType) => { return moduleTypes; }; -export default function moduleTypes(configuredExtensions, defaultModuleType) { +export default function moduleTypes(configuredExtensions) { if (configuredExtensions === undefined) { return { - cjs: 'commonjs', mjs: 'module', - js: defaultModuleType, + js: 'module', }; } if (Array.isArray(configuredExtensions)) { - return deriveFromArray(configuredExtensions, defaultModuleType); + return deriveFromArray(configuredExtensions); } - return deriveFromObject(configuredExtensions, defaultModuleType); + return deriveFromObject(configuredExtensions); } diff --git a/lib/now-and-timers.cjs b/lib/now-and-timers.js similarity index 50% rename from lib/now-and-timers.cjs rename to lib/now-and-timers.js index 59d916aac..887219d3f 100644 --- a/lib/now-and-timers.cjs +++ b/lib/now-and-timers.js @@ -1,16 +1,19 @@ -'use strict'; -const timers = require('node:timers'); +export { + setTimeout, + clearTimeout, + setImmediate, + setInterval, + clearInterval, + clearImmediate, +} from 'node:timers'; -Object.assign(exports, timers); -exports.now = Date.now; +export const {now} = Date; // Any delay larger than this value is ignored by Node.js, with a delay of `1` // used instead. See . const MAX_DELAY = (2 ** 31) - 1; -function setCappedTimeout(callback, delay) { +export function setCappedTimeout(callback, delay) { const safeDelay = Math.min(delay, MAX_DELAY); - return timers.setTimeout(callback, safeDelay); + return globalThis.setTimeout(callback, safeDelay); } - -exports.setCappedTimeout = setCappedTimeout; diff --git a/lib/pkg.cjs b/lib/pkg.cjs deleted file mode 100644 index 8adecbd96..000000000 --- a/lib/pkg.cjs +++ /dev/null @@ -1,2 +0,0 @@ -'use strict'; -module.exports = require('../package.json'); diff --git a/lib/pkg.js b/lib/pkg.js new file mode 100644 index 000000000..bb1425312 --- /dev/null +++ b/lib/pkg.js @@ -0,0 +1 @@ +export {default} from '../package.json' with {type: 'json'}; diff --git a/lib/plugin-support/shared-worker-loader.js b/lib/plugin-support/shared-worker-loader.js index d4a3a637d..25ee8179a 100644 --- a/lib/plugin-support/shared-worker-loader.js +++ b/lib/plugin-support/shared-worker-loader.js @@ -2,7 +2,7 @@ import {EventEmitter, on} from 'node:events'; import process from 'node:process'; import {workerData, parentPort, threadId} from 'node:worker_threads'; -import pkg from '../pkg.cjs'; +import pkg from '../pkg.js'; // Used to forward messages received over the `parentPort` and any direct ports // to test workers. Every subscription adds a listener, so do not enforce any diff --git a/lib/provider-manager.js b/lib/provider-manager.js index 5285dbccb..0acc345f5 100644 --- a/lib/provider-manager.js +++ b/lib/provider-manager.js @@ -1,5 +1,5 @@ import * as globs from './globs.js'; -import pkg from './pkg.cjs'; +import pkg from './pkg.js'; export const levels = { // As the protocol changes, comparing levels by integer allows AVA to be diff --git a/lib/reporters/improper-usage-messages.js b/lib/reporters/improper-usage-messages.js index b5b9f6ce2..ea2464fb3 100644 --- a/lib/reporters/improper-usage-messages.js +++ b/lib/reporters/improper-usage-messages.js @@ -1,5 +1,5 @@ import {chalk} from '../chalk.js'; -import pkg from '../pkg.cjs'; +import pkg from '../pkg.js'; export default function buildMessage(improperUsage) { if (!improperUsage) { diff --git a/lib/runner.js b/lib/runner.js index 3272bc646..e8c219b81 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -10,7 +10,7 @@ import parseTestArgs from './parse-test-args.js'; import serializeError from './serialize-error.js'; import {load as loadSnapshots, determineSnapshotDir} from './snapshot-manager.js'; import Runnable from './test.js'; -import {waitForReady} from './worker/state.cjs'; +import {waitForReady} from './worker/state.js'; const makeFileURL = file => file.startsWith('file://') ? file : pathToFileURL(file).toString(); diff --git a/lib/slash.cjs b/lib/slash.js similarity index 80% rename from lib/slash.cjs rename to lib/slash.js index 418954c53..d483b3e56 100644 --- a/lib/slash.cjs +++ b/lib/slash.js @@ -1,12 +1,11 @@ /* Inlined from -, -since we need a CJS version. +. Copyright 2023 Sindre Sorhus Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the “Software”), to deal in +this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, @@ -15,7 +14,7 @@ subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER @@ -23,7 +22,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -function slash(path) { +export default function slash(path) { const isExtendedLengthPath = path.startsWith('\\\\?\\'); if (isExtendedLengthPath) { @@ -32,5 +31,3 @@ function slash(path) { return path.replaceAll('\\', '/'); } - -module.exports = slash; diff --git a/lib/snapshot-manager.js b/lib/snapshot-manager.js index ccf058364..7c3524fa4 100644 --- a/lib/snapshot-manager.js +++ b/lib/snapshot-manager.js @@ -13,7 +13,7 @@ import memoize from 'memoize'; import writeFileAtomic from 'write-file-atomic'; import {snapshotManager as concordanceOptions} from './concordance-options.js'; -import slash from './slash.cjs'; +import slash from './slash.js'; // Increment if encoding layout or Concordance serialization versions change. Previous AVA versions will not be able to // decode buffers generated by a newer version, so changing this value will require a major version bump of AVA itself. diff --git a/lib/test.js b/lib/test.js index 8831e12ee..681b84be7 100644 --- a/lib/test.js +++ b/lib/test.js @@ -6,7 +6,7 @@ import { AssertionError, Assertions, checkAssertionMessage, getAssertionStack, } from './assert.js'; import concordanceOptions from './concordance-options.js'; -import nowAndTimers from './now-and-timers.cjs'; +import * as nowAndTimers from './now-and-timers.js'; import parseTestArgs from './parse-test-args.js'; function isExternalAssertError(error) { diff --git a/lib/worker/base.js b/lib/worker/base.js index ef44b1a09..2a6d10904 100644 --- a/lib/worker/base.js +++ b/lib/worker/base.js @@ -1,5 +1,4 @@ import {mkdir} from 'node:fs/promises'; -import {createRequire} from 'node:module'; import path from 'node:path'; import process from 'node:process'; import {pathToFileURL} from 'node:url'; @@ -9,17 +8,17 @@ import setUpCurrentlyUnhandled from 'currently-unhandled'; import writeFileAtomic from 'write-file-atomic'; import {set as setChalk} from '../chalk.js'; -import nowAndTimers from '../now-and-timers.cjs'; +import {setImmediate} from '../now-and-timers.js'; import providerManager from '../provider-manager.js'; import Runner from '../runner.js'; import serializeError from '../serialize-error.js'; -import channel from './channel.cjs'; +import * as channel from './channel.js'; import {runCompletionHandlers} from './completion-handlers.js'; import lineNumberSelection from './line-numbers.js'; -import {set as setOptions} from './options.cjs'; -import {flags, refs, sharedWorkerTeardowns} from './state.cjs'; -import {isRunningInThread, isRunningInChildProcess} from './utils.cjs'; +import {set as setOptions} from './options.js'; +import {flags, refs, sharedWorkerTeardowns} from './state.js'; +import {isRunningInThread, isRunningInChildProcess} from './utils.js'; const currentlyUnhandled = setUpCurrentlyUnhandled(); let runner; @@ -129,7 +128,7 @@ const run = async options => { await channel.workerFreed; channel.unref(); - nowAndTimers.setImmediate(() => { + setImmediate(() => { const unhandled = currentlyUnhandled(); if (unhandled.length === 0) { return avaIsDone(); @@ -166,22 +165,14 @@ const run = async options => { } })); - const require = createRequire(import.meta.url); const load = async ref => { for (const provider of providers) { if (provider.canLoad(ref)) { - return provider.load(ref, {requireFn: require}); + return provider.load(ref, {}); } } - for (const extension of extensionsToLoadAsModules) { - if (ref.endsWith(`.${extension}`)) { - return import(pathToFileURL(ref)); - } - } - - // We still support require() since it's more easily monkey-patched. - return require(ref); + return import(pathToFileURL(ref)); }; const loadRequiredModule = async ref => { @@ -189,21 +180,14 @@ const run = async options => { // dependency. for (const provider of providers) { if (provider.canLoad(ref)) { - return provider.load(ref, {requireFn: require}); + return provider.load(ref, {}); } } // Try to load the module as a file, relative to the project directory. - // Match load() behavior. const fullPath = path.resolve(projectDir, ref); try { - for (const extension of extensionsToLoadAsModules) { - if (fullPath.endsWith(`.${extension}`)) { - return await import(pathToFileURL(fullPath)); // eslint-disable-line no-await-in-loop - } - } - - return require(fullPath); + return await import(pathToFileURL(fullPath)); } catch (error) { // If the module could not be found, assume it's not a file but a dependency. if (error.code === 'ERR_MODULE_NOT_FOUND' || error.code === 'MODULE_NOT_FOUND') { @@ -228,9 +212,9 @@ const run = async options => { for await (const [ref, ...args] of (options.require ?? [])) { const loadedModule = await loadRequiredModule(ref); - if (typeof loadedModule === 'function') { // CJS module + if (typeof loadedModule === 'function') { await loadedModule(...args); - } else if (typeof loadedModule.default === 'function') { // ES module, or exports.default from CJS + } else if (typeof loadedModule.default === 'function') { const {default: fn} = loadedModule; await fn(...args); } diff --git a/lib/worker/channel.cjs b/lib/worker/channel.js similarity index 84% rename from lib/worker/channel.cjs rename to lib/worker/channel.js index 671cc6d12..b11f02f57 100644 --- a/lib/worker/channel.cjs +++ b/lib/worker/channel.js @@ -1,11 +1,11 @@ -'use strict'; -const events = require('node:events'); -const process = require('node:process'); -const {MessageChannel, threadId} = require('node:worker_threads'); +import events from 'node:events'; +import process from 'node:process'; +import {MessageChannel, parentPort, threadId} from 'node:worker_threads'; -const timers = require('../now-and-timers.cjs'); +import {controlFlow} from '../ipc-flow-control.js'; +import {setTimeout as setTimeoutTimer} from '../now-and-timers.js'; -const {isRunningInChildProcess, isRunningInThread} = require('./utils.cjs'); +import {isRunningInChildProcess, isRunningInThread} from './utils.js'; const selectAvaMessage = async (channel, type) => { for await (const [message] of events.on(channel, 'message')) { @@ -34,7 +34,7 @@ class MessagePortHandle { this.channel = port; // Referencing the port does not immediately prevent the thread from // exiting. Use a timer to keep a reference for at least a second. - this.workaroundTimer = timers.setTimeout(() => {}, 1000).unref(); + this.workaroundTimer = setTimeoutTimer(() => {}, 1000).unref(); } forceUnref() { @@ -92,10 +92,8 @@ class IpcHandle { let handle; if (isRunningInChildProcess) { - const {controlFlow} = require('../ipc-flow-control.cjs'); handle = new IpcHandle(controlFlow(process)); } else if (isRunningInThread) { - const {parentPort} = require('node:worker_threads'); handle = new MessagePortHandle(parentPort); } @@ -103,12 +101,14 @@ if (isRunningInChildProcess) { // Node.js. In order to keep track, explicitly reference before attaching. handle.ref(); -exports.options = selectAvaMessage(handle.channel, 'options').then(message => message.ava.options); -exports.peerFailed = selectAvaMessage(handle.channel, 'peer-failed'); -exports.workerFreed = selectAvaMessage(handle.channel, 'free-worker'); -exports.send = handle.send.bind(handle); -exports.ref = handle.ref.bind(handle); -exports.unref = handle.unref.bind(handle); +/* eslint-disable unicorn/prefer-top-level-await */ +export const options = selectAvaMessage(handle.channel, 'options').then(message => message.ava.options); +export const peerFailed = selectAvaMessage(handle.channel, 'peer-failed'); +export const workerFreed = selectAvaMessage(handle.channel, 'free-worker'); +/* eslint-enable unicorn/prefer-top-level-await */ +export const send = handle.send.bind(handle); +export const ref = handle.ref.bind(handle); +export const unref = handle.unref.bind(handle); let channelCounter = 0; let messageCounter = 0; @@ -136,7 +136,7 @@ function createChannelEmitter(channelId) { return [emitter, () => channelEmitters.delete(channelId)]; } -function registerSharedWorker(filename, initialData) { +export function registerSharedWorker(filename, initialData) { const channelId = `${threadId}/channel/${++channelCounter}`; const {port1: ourPort, port2: theirPort} = new MessageChannel(); @@ -242,5 +242,3 @@ function registerSharedWorker(filename, initialData) { }, }; } - -exports.registerSharedWorker = registerSharedWorker; diff --git a/lib/worker/completion-handlers.js b/lib/worker/completion-handlers.js index ddf4b479e..e566b4204 100644 --- a/lib/worker/completion-handlers.js +++ b/lib/worker/completion-handlers.js @@ -1,13 +1,13 @@ import process from 'node:process'; -import state from './state.cjs'; +import {completionHandlers} from './state.js'; export function runCompletionHandlers() { - for (const handler of state.completionHandlers) { + for (const handler of completionHandlers) { process.nextTick(() => handler()); } } export function registerCompletionHandler(handler) { - state.completionHandlers.push(handler); + completionHandlers.push(handler); } diff --git a/lib/worker/guard-environment.cjs b/lib/worker/guard-environment.js similarity index 59% rename from lib/worker/guard-environment.cjs rename to lib/worker/guard-environment.js index 2a17a84b8..90d4a8afd 100644 --- a/lib/worker/guard-environment.cjs +++ b/lib/worker/guard-environment.js @@ -1,8 +1,7 @@ -'use strict'; -const path = require('node:path'); -const process = require('node:process'); +import path from 'node:path'; +import process from 'node:process'; -const {isRunningInThread, isRunningInChildProcess} = require('./utils.cjs'); +import {isRunningInThread, isRunningInChildProcess} from './utils.js'; // Check if the test is being run without AVA cli if (!isRunningInChildProcess && !isRunningInThread) { @@ -14,6 +13,6 @@ if (!isRunningInChildProcess && !isRunningInThread) { process.exit(1); // eslint-disable-line unicorn/no-process-exit } else { - throw new Error('The ’ava’ module can only be imported in test files'); + throw new Error('The \u2018ava\u2019 module can only be imported in test files'); } } diff --git a/lib/worker/line-numbers.js b/lib/worker/line-numbers.js index bf3280311..75f1ce834 100644 --- a/lib/worker/line-numbers.js +++ b/lib/worker/line-numbers.js @@ -1,16 +1,12 @@ import * as fs from 'node:fs'; -import {createRequire, findSourceMap} from 'node:module'; +import {findSourceMap} from 'node:module'; import {pathToFileURL} from 'node:url'; +import * as acorn from 'acorn'; +import * as walk from 'acorn-walk'; import callsites from 'callsites'; -const require = createRequire(import.meta.url); - function parse(file) { - // Avoid loading these until we actually need to select tests by line number. - const acorn = require('acorn'); - const walk = require('acorn-walk'); - const ast = acorn.parse(fs.readFileSync(file, 'utf8'), { ecmaVersion: 'latest', locations: true, diff --git a/lib/worker/main.cjs b/lib/worker/main.cjs deleted file mode 100644 index 50940fd61..000000000 --- a/lib/worker/main.cjs +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; -require('./guard-environment.cjs'); // eslint-disable-line import-x/no-unassigned-import - -const assert = require('node:assert'); - -const {flags, refs} = require('./state.cjs'); - -assert(refs.runnerChain); - -flags.loadedMain = true; - -module.exports = refs.runnerChain; diff --git a/lib/worker/main.js b/lib/worker/main.js new file mode 100644 index 000000000..a8be74c81 --- /dev/null +++ b/lib/worker/main.js @@ -0,0 +1,11 @@ +import './guard-environment.js'; // eslint-disable-line import-x/no-unassigned-import + +import assert from 'node:assert'; + +import {flags, refs} from './state.js'; + +assert.ok(refs.runnerChain); + +flags.loadedMain = true; + +export default refs.runnerChain; diff --git a/lib/worker/options.cjs b/lib/worker/options.js similarity index 74% rename from lib/worker/options.cjs rename to lib/worker/options.js index 8a6ca21fa..159e18daf 100644 --- a/lib/worker/options.cjs +++ b/lib/worker/options.js @@ -1,17 +1,16 @@ -'use strict'; let options = null; -exports.get = () => { +export function get() { if (!options) { throw new Error('Options have not yet been set'); } return options; -}; +} -exports.set = newOptions => { +export function set(newOptions) { if (options) { throw new Error('Options have already been set'); } options = newOptions; -}; +} diff --git a/lib/worker/plugin.cjs b/lib/worker/plugin.js similarity index 85% rename from lib/worker/plugin.cjs rename to lib/worker/plugin.js index 4ec0b6662..9d07105c7 100644 --- a/lib/worker/plugin.cjs +++ b/lib/worker/plugin.js @@ -1,10 +1,10 @@ -const pkg = require('../../package.json'); +import pkg from '../pkg.js'; -const {registerSharedWorker: register} = require('./channel.cjs'); -const options = require('./options.cjs'); -const {sharedWorkerTeardowns, waitForReady} = require('./state.cjs'); +import {registerSharedWorker as register} from './channel.js'; +import {get as getOptions} from './options.js'; +import {sharedWorkerTeardowns, waitForReady} from './state.js'; -require('./guard-environment.cjs'); // eslint-disable-line import-x/no-unassigned-import +import './guard-environment.js'; // eslint-disable-line import-x/no-unassigned-import const workers = new Map(); const workerTeardownFns = new WeakMap(); @@ -83,13 +83,13 @@ function createSharedWorker(filename, initialData, teardown) { }; } -function registerSharedWorker({ +export function registerSharedWorker({ filename, initialData, supportedProtocols, teardown, }) { - const options_ = options.get(); + const options_ = getOptions(); if (!options_.workerThreads) { throw new Error('Shared workers can be used only when worker threads are enabled'); @@ -126,5 +126,3 @@ function registerSharedWorker({ return worker; } - -exports.registerSharedWorker = registerSharedWorker; diff --git a/lib/worker/state.cjs b/lib/worker/state.cjs deleted file mode 100644 index 3cd9e2d29..000000000 --- a/lib/worker/state.cjs +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; -exports.flags = {loadedMain: false}; -exports.refs = {runnerChain: null}; -exports.completionHandlers = []; -exports.sharedWorkerTeardowns = []; -exports.waitForReady = []; diff --git a/lib/worker/state.js b/lib/worker/state.js new file mode 100644 index 000000000..70d435e3c --- /dev/null +++ b/lib/worker/state.js @@ -0,0 +1,5 @@ +export const flags = {loadedMain: false}; +export const refs = {runnerChain: null}; +export const completionHandlers = []; +export const sharedWorkerTeardowns = []; +export const waitForReady = []; diff --git a/lib/worker/utils.cjs b/lib/worker/utils.cjs deleted file mode 100644 index a24bbf589..000000000 --- a/lib/worker/utils.cjs +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; -const process = require('node:process'); -const {isMainThread} = require('node:worker_threads'); - -exports.isRunningInThread = isMainThread === false; -exports.isRunningInChildProcess = typeof process.send === 'function'; diff --git a/lib/worker/utils.js b/lib/worker/utils.js new file mode 100644 index 000000000..781e4ea30 --- /dev/null +++ b/lib/worker/utils.js @@ -0,0 +1,5 @@ +import process from 'node:process'; +import {isMainThread} from 'node:worker_threads'; + +export const isRunningInThread = isMainThread === false; +export const isRunningInChildProcess = typeof process.send === 'function'; diff --git a/package-lock.json b/package-lock.json index 63caae839..68e51985b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,7 +50,7 @@ "yargs": "^18.0.0" }, "bin": { - "ava": "entrypoints/cli.mjs" + "ava": "entrypoints/cli.js" }, "devDependencies": { "@ava/test": "github:avajs/test", @@ -70,7 +70,7 @@ "zen-observable": "^0.10.0" }, "engines": { - "node": "^20.19 || ^22.20 || ^24.12 || >=25" + "node": "^22.20 || ^24.12 || >=25" }, "peerDependencies": { "@ava/typescript": "*" diff --git a/package.json b/package.json index ceb305de1..87e7c2c87 100644 --- a/package.json +++ b/package.json @@ -9,32 +9,20 @@ }, "homepage": "https://avajs.dev", "bin": { - "ava": "entrypoints/cli.mjs" + "ava": "entrypoints/cli.js" }, "exports": { ".": { - "import": { - "types": "./entrypoints/main.d.mts", - "default": "./entrypoints/main.mjs" - }, - "require": { - "types": "./entrypoints/main.d.cts", - "default": "./entrypoints/main.cjs" - } + "types": "./entrypoints/main.d.ts", + "default": "./entrypoints/main.js" }, - "./eslint-plugin-helper": "./entrypoints/eslint-plugin-helper.cjs", + "./eslint-plugin-helper": "./entrypoints/eslint-plugin-helper.js", "./plugin": { - "import": { - "types": "./entrypoints/plugin.d.mts", - "default": "./entrypoints/plugin.mjs" - }, - "require": { - "types": "./entrypoints/plugin.d.cts", - "default": "./entrypoints/plugin.cjs" - } + "types": "./entrypoints/plugin.d.ts", + "default": "./entrypoints/plugin.js" }, "./internal": { - "types": "./entrypoints/internal.d.mts" + "types": "./entrypoints/internal.d.ts" } }, "type": "module", diff --git a/plugin.d.ts b/plugin.d.ts index a1524f2cc..c1d2f5bc0 100644 --- a/plugin.d.ts +++ b/plugin.d.ts @@ -1,3 +1,3 @@ // For compatibility with resolution algorithms other than Node16. -export * from './entrypoints/plugin.cjs'; +export * from './entrypoints/plugin.js'; diff --git a/test-tap/api.js b/test-tap/api.js index 5ed41ef5f..e4cc34bf3 100644 --- a/test-tap/api.js +++ b/test-tap/api.js @@ -1,27 +1,31 @@ import fs from 'node:fs'; import path from 'node:path'; -import process from 'node:process'; import {fileURLToPath} from 'node:url'; import ciInfo from 'ci-info'; import {test} from 'tap'; import Api from '../lib/api.js'; +import normalizeExtensions from '../lib/extensions.js'; import {normalizeGlobs} from '../lib/globs.js'; +import normalizeModuleTypes from '../lib/module-types.js'; const __dirname = fileURLToPath(new URL('.', import.meta.url)); const ROOT_DIR = path.join(__dirname, '..'); async function apiCreator(options = {}) { + const providers = options.providers ?? []; + options.projectDir ??= ROOT_DIR; options.chalkOptions = {level: 0}; options.concurrency = 2; - options.extensions ??= ['cjs']; options.experiments = {}; + options.extensions = normalizeExtensions(options.extensions, providers); + options.moduleTypes ??= normalizeModuleTypes(options.extensions, 'module'); options.globs = normalizeGlobs({ - files: options.files, ignoredByWatcher: options.watchMode?.ignoreChanges, extensions: options.extensions, providers: [], + files: options.files, ignoredByWatcher: options.watchMode?.ignoreChanges, extensions: options.extensions, providers, }); - options.nodeArguments = process.execArgv; + options.nodeArguments = []; const instance = new Api(options); return instance; @@ -57,7 +61,7 @@ for (const opt of options) { }); }); - return api.run({files: [path.join(__dirname, 'fixture/fail-fast/single-file/test.cjs')]}) + return api.run({files: [path.join(__dirname, 'fixture/fail-fast/single-file/test.js')]}) .then(runStatus => { t.ok(api.options.failFast); t.strictSame(tests, [{ @@ -103,19 +107,19 @@ for (const opt of options) { return api.run({ files: [ - path.join(__dirname, 'fixture/fail-fast/multiple-files/fails.cjs'), - path.join(__dirname, 'fixture/fail-fast/multiple-files/passes.cjs'), + path.join(__dirname, 'fixture/fail-fast/multiple-files/fails.js'), + path.join(__dirname, 'fixture/fail-fast/multiple-files/passes.js'), ], }) .then(runStatus => { t.ok(api.options.failFast); t.strictSame(tests, [{ ok: true, - testFile: path.join(__dirname, 'fixture/fail-fast/multiple-files/fails.cjs'), + testFile: path.join(__dirname, 'fixture/fail-fast/multiple-files/fails.js'), title: 'first pass', }, { ok: false, - testFile: path.join(__dirname, 'fixture/fail-fast/multiple-files/fails.cjs'), + testFile: path.join(__dirname, 'fixture/fail-fast/multiple-files/fails.js'), title: 'second fail', }]); t.equal(runStatus.stats.passedTests, 1); @@ -149,8 +153,8 @@ for (const opt of options) { }); }); - const fails = path.join(__dirname, 'fixture/fail-fast/multiple-files/fails.cjs'); - const passesSlow = path.join(__dirname, 'fixture/fail-fast/multiple-files/passes-slow.cjs'); + const fails = path.join(__dirname, 'fixture/fail-fast/multiple-files/fails.js'); + const passesSlow = path.join(__dirname, 'fixture/fail-fast/multiple-files/passes-slow.js'); const runStatus = await api.run({files: [fails, passesSlow]}); t.ok(api.options.failFast); @@ -160,21 +164,21 @@ for (const opt of options) { t.strictSame(tests.filter(({testFile}) => testFile === fails), [{ ok: true, - testFile: path.join(__dirname, 'fixture/fail-fast/multiple-files/fails.cjs'), + testFile: path.join(__dirname, 'fixture/fail-fast/multiple-files/fails.js'), title: 'first pass', }, { ok: false, - testFile: path.join(__dirname, 'fixture/fail-fast/multiple-files/fails.cjs'), + testFile: path.join(__dirname, 'fixture/fail-fast/multiple-files/fails.js'), title: 'second fail', }, { ok: true, - testFile: path.join(__dirname, 'fixture/fail-fast/multiple-files/fails.cjs'), + testFile: path.join(__dirname, 'fixture/fail-fast/multiple-files/fails.js'), title: 'third pass', }]); if (runStatus.stats.passedTests === 3) { t.strictSame(tests.filter(({testFile}) => testFile === passesSlow), [{ ok: true, - testFile: path.join(__dirname, 'fixture/fail-fast/multiple-files/passes-slow.cjs'), + testFile: path.join(__dirname, 'fixture/fail-fast/multiple-files/passes-slow.js'), title: 'first pass', }]); } @@ -222,15 +226,15 @@ for (const opt of options) { return api.run({ files: [ - path.join(__dirname, 'fixture/fail-fast/crash/crashes.cjs'), - path.join(__dirname, 'fixture/fail-fast/crash/passes.cjs'), + path.join(__dirname, 'fixture/fail-fast/crash/crashes.js'), + path.join(__dirname, 'fixture/fail-fast/crash/passes.js'), ], }) .then(runStatus => { t.ok(api.options.failFast); t.strictSame(tests, []); t.equal(workerFailures.length, 1); - t.equal(workerFailures[0].testFile, path.join(__dirname, 'fixture', 'fail-fast', 'crash', 'crashes.cjs')); + t.equal(workerFailures[0].testFile, path.join(__dirname, 'fixture', 'fail-fast', 'crash', 'crashes.js')); t.equal(runStatus.stats.passedTests, 0); t.equal(runStatus.stats.failedTests, 0); }); @@ -280,9 +284,9 @@ for (const opt of options) { return api.run({ files: [ - path.join(__dirname, 'fixture/fail-fast/timeout/fails.cjs'), - path.join(__dirname, 'fixture/fail-fast/timeout/passes.cjs'), - path.join(__dirname, 'fixture/fail-fast/timeout/passes-slow.cjs'), + path.join(__dirname, 'fixture/fail-fast/timeout/fails.js'), + path.join(__dirname, 'fixture/fail-fast/timeout/passes.js'), + path.join(__dirname, 'fixture/fail-fast/timeout/passes-slow.js'), ], }) .then(runStatus => { @@ -302,8 +306,8 @@ for (const opt of options) { return api.run({ files: [ - path.join(__dirname, 'fixture/fail-fast/without-error/a.cjs'), - path.join(__dirname, 'fixture/fail-fast/without-error/b.cjs'), + path.join(__dirname, 'fixture/fail-fast/without-error/a.js'), + path.join(__dirname, 'fixture/fail-fast/without-error/b.js'), ], }) .then(runStatus => { @@ -318,7 +322,7 @@ for (const opt of options) { serial: true, }); - return api.run({files: [path.join(__dirname, 'fixture/serial.cjs')]}) + return api.run({files: [path.join(__dirname, 'fixture/serial.js')]}) .then(runStatus => { t.ok(api.options.serial); t.equal(runStatus.stats.passedTests, 3); @@ -328,7 +332,7 @@ for (const opt of options) { test(`run from package.json folder by default - workerThreads: ${opt.workerThreads}`, async t => { const api = await apiCreator(opt); - return api.run({files: [path.join(__dirname, 'fixture/process-cwd-default.cjs')]}) + return api.run({files: [path.join(__dirname, 'fixture/process-cwd-default.js')]}) .then(runStatus => { t.equal(runStatus.stats.passedTests, 1); }); @@ -337,14 +341,14 @@ for (const opt of options) { test(`absolute paths - workerThreads: ${opt.workerThreads}`, async t => { const api = await apiCreator(opt); - return api.run({files: [path.resolve('test-tap/fixture/es2015.cjs')]}) + return api.run({files: [path.resolve('test-tap/fixture/es2015.js')]}) .then(runStatus => { t.equal(runStatus.stats.passedTests, 1); }); }); test(`symlink to directory containing test files - workerThreads: ${opt.workerThreads}`, async t => { - const api = await apiCreator({...opt, files: ['test-tap/fixture/symlink/*.cjs']}); + const api = await apiCreator({...opt, files: ['test-tap/fixture/symlink/*.js']}); return api.run() .then(runStatus => { @@ -355,7 +359,7 @@ for (const opt of options) { test(`symlink to test file directly - workerThreads: ${opt.workerThreads}`, async t => { const api = await apiCreator(opt); - return api.run({files: [path.join(__dirname, 'fixture/symlinkfile.cjs')]}) + return api.run({files: [path.join(__dirname, 'fixture/symlinkfile.js')]}) .then(runStatus => { t.equal(runStatus.stats.passedTests, 1); }); @@ -365,7 +369,7 @@ for (const opt of options) { t.plan(1); const api = await apiCreator(opt); - return api.run({files: [path.join(__dirname, 'fixture/ignored-dirs/node_modules/test.cjs')]}) + return api.run({files: [path.join(__dirname, 'fixture/ignored-dirs/node_modules/test.js')]}) .then(runStatus => { t.equal(runStatus.stats.declaredTests, 0); }); @@ -379,7 +383,7 @@ for (const opt of options) { projectDir: path.join(__dirname, 'fixture/caching'), }); - return api.run({files: [path.join(__dirname, 'fixture/caching/test.cjs')]}) + return api.run({files: [path.join(__dirname, 'fixture/caching/test.js')]}) .then(() => { const files = fs.readdirSync(path.join(__dirname, 'fixture/caching/node_modules/.cache/ava')); if (files.length === 1) { @@ -400,7 +404,7 @@ for (const opt of options) { cacheEnabled: false, }); - return api.run({files: [path.join(__dirname, 'fixture/caching/test.cjs')]}) + return api.run({files: [path.join(__dirname, 'fixture/caching/test.js')]}) .then(() => { t.notOk(fs.existsSync(path.join(__dirname, 'fixture/caching/node_modules/.cache/ava'))); }); @@ -409,7 +413,7 @@ for (const opt of options) { test(`test file with only skipped tests does not create a failure - workerThreads: ${opt.workerThreads}`, async t => { const api = await apiCreator(); - return api.run({...opt, files: [path.join(__dirname, 'fixture/skip-only.cjs')]}) + return api.run({...opt, files: [path.join(__dirname, 'fixture/skip-only.js')]}) .then(runStatus => { t.equal(runStatus.stats.selectedTests, 1); t.equal(runStatus.stats.skippedTests, 1); @@ -420,7 +424,7 @@ for (const opt of options) { test(`test file with only skipped tests does not run hooks - workerThreads: ${opt.workerThreads}`, async t => { const api = await apiCreator(opt); - return api.run({files: [path.join(__dirname, 'fixture/hooks-skipped.cjs')]}) + return api.run({files: [path.join(__dirname, 'fixture/hooks-skipped.js')]}) .then(runStatus => { t.equal(runStatus.stats.selectedTests, 1); t.equal(runStatus.stats.skippedTests, 1); @@ -437,9 +441,9 @@ for (const opt of options) { return api.run({ files: [ - path.join(__dirname, 'fixture/test-count.cjs'), - path.join(__dirname, 'fixture/test-count-2.cjs'), - path.join(__dirname, 'fixture/test-count-3.cjs'), + path.join(__dirname, 'fixture/test-count.js'), + path.join(__dirname, 'fixture/test-count-2.js'), + path.join(__dirname, 'fixture/test-count-3.js'), ], }).then(runStatus => { t.equal(runStatus.stats.passedTests, 4, 'pass count'); @@ -468,9 +472,9 @@ for (const opt of options) { return api.run({ files: [ - path.join(__dirname, 'fixture/match-no-match.cjs'), - path.join(__dirname, 'fixture/match-no-match-2.cjs'), - path.join(__dirname, 'fixture/test-count.cjs'), + path.join(__dirname, 'fixture/match-no-match.js'), + path.join(__dirname, 'fixture/match-no-match-2.js'), + path.join(__dirname, 'fixture/test-count.js'), ], }).then(runStatus => { t.equal(runStatus.stats.passedTests, 1); @@ -483,7 +487,7 @@ test('run from package.json folder by default', async t => { workerThreads: false, }); - return api.run({files: [path.join(__dirname, 'fixture/process-cwd-default.cjs')]}) + return api.run({files: [path.join(__dirname, 'fixture/process-cwd-default.js')]}) .then(runStatus => { t.equal(runStatus.stats.passedTests, 1); }); diff --git a/test-tap/assert.js b/test-tap/assert.js index ae0fd3bac..06986bac0 100644 --- a/test-tap/assert.js +++ b/test-tap/assert.js @@ -6,7 +6,7 @@ import {test} from 'tap'; import * as assert from '../lib/assert.js'; import * as snapshotManager from '../lib/snapshot-manager.js'; -import {set as setOptions} from '../lib/worker/options.cjs'; +import {set as setOptions} from '../lib/worker/options.js'; setOptions({chalkOptions: {level: 0}}); @@ -1475,7 +1475,7 @@ test('.snapshot()', async t => { const projectDir = fileURLToPath(new URL('fixture', import.meta.url)); const manager = snapshotManager.load({ - file: path.join(projectDir, 'assert.cjs'), + file: path.join(projectDir, 'assert.js'), projectDir, fixedLocation: null, recordNewSnapshots: updating, diff --git a/test-tap/eslint-plugin-helper.js b/test-tap/eslint-plugin-helper.js index a0404a881..4a868fc94 100644 --- a/test-tap/eslint-plugin-helper.js +++ b/test-tap/eslint-plugin-helper.js @@ -3,7 +3,7 @@ import {fileURLToPath} from 'node:url'; import {test} from 'tap'; -import {load} from '../entrypoints/eslint-plugin-helper.cjs'; +import {load} from '../entrypoints/eslint-plugin-helper.js'; const projectDir = fileURLToPath(new URL('fixture/eslint-plugin-helper', import.meta.url)); const overrideDir = fileURLToPath(new URL('fixture/eslint-plugin-helper/for-overriding', import.meta.url)); @@ -41,7 +41,7 @@ test('classifies files according to the configuration', t => { isHelper: false, isTest: false, }); - t.same(helper.classifyFile(path.join(projectDir, 'tests/test.cjs')), { + t.same(helper.classifyFile(path.join(projectDir, 'tests/test.js')), { isHelper: false, isTest: false, }); @@ -74,7 +74,7 @@ test('classifies files according to configuration override', t => { isHelper: false, isTest: false, }); - t.same(helper.classifyFile(path.join(overrideDir, 'tests/test.cjs')), { + t.same(helper.classifyFile(path.join(overrideDir, 'tests/test.js')), { isHelper: false, isTest: false, }); diff --git a/test-tap/fixture/assert.cjs.md b/test-tap/fixture/assert.js.md similarity index 69% rename from test-tap/fixture/assert.cjs.md rename to test-tap/fixture/assert.js.md index eacab4935..6fac103bf 100644 --- a/test-tap/fixture/assert.cjs.md +++ b/test-tap/fixture/assert.js.md @@ -1,6 +1,6 @@ -# Snapshot report for `assert.cjs` +# Snapshot report for `assert.js` -The actual snapshot is saved in `assert.cjs.snap`. +The actual snapshot is saved in `assert.js.snap`. Generated by [AVA](https://avajs.dev). diff --git a/test-tap/fixture/assert.cjs.snap b/test-tap/fixture/assert.js.snap similarity index 100% rename from test-tap/fixture/assert.cjs.snap rename to test-tap/fixture/assert.js.snap diff --git a/test/config/fixtures/mjs-with-tests/dir-a-wrapper/dir-a/dir-a-wrapper-3.js b/test-tap/fixture/ava-paths/target/test.js similarity index 100% rename from test/config/fixtures/mjs-with-tests/dir-a-wrapper/dir-a/dir-a-wrapper-3.js rename to test-tap/fixture/ava-paths/target/test.js diff --git a/test-tap/fixture/caching/test.cjs b/test-tap/fixture/caching/test.cjs deleted file mode 100644 index 1ac48f081..000000000 --- a/test-tap/fixture/caching/test.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../../entrypoints/main.cjs'); - -test('test', t => { - t.true(2 + 2 === 4); -}); diff --git a/test-tap/fixture/caching/test.js b/test-tap/fixture/caching/test.js new file mode 100644 index 000000000..7593cabeb --- /dev/null +++ b/test-tap/fixture/caching/test.js @@ -0,0 +1,5 @@ +import test from '../../../entrypoints/main.js'; + +test('test', t => { + t.true(2 + 2 === 4); +}); diff --git a/test-tap/fixture/cjs.cjs b/test-tap/fixture/cjs.cjs deleted file mode 100644 index 7a002957a..000000000 --- a/test-tap/fixture/cjs.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../entrypoints/main.cjs'); - -test('pass', t => { - t.pass(); -}); diff --git a/test-tap/fixture/error-in-anonymous-function.cjs b/test-tap/fixture/error-in-anonymous-function.js similarity index 69% rename from test-tap/fixture/error-in-anonymous-function.cjs rename to test-tap/fixture/error-in-anonymous-function.js index b72330f11..e99f49fc5 100644 --- a/test-tap/fixture/error-in-anonymous-function.cjs +++ b/test-tap/fixture/error-in-anonymous-function.js @@ -1,4 +1,4 @@ -const test = require('../../entrypoints/main.cjs'); +import test from '../../entrypoints/main.js'; const getAnonymousFn = () => () => { throw new Error(); diff --git a/test-tap/fixture/es2015.cjs b/test-tap/fixture/es2015.cjs deleted file mode 100644 index b499209db..000000000 --- a/test-tap/fixture/es2015.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../entrypoints/main.cjs'); - -test('test', t => { - t.pass(); -}); diff --git a/test-tap/fixture/es2015.js b/test-tap/fixture/es2015.js new file mode 100644 index 000000000..0c7f2e2ee --- /dev/null +++ b/test-tap/fixture/es2015.js @@ -0,0 +1,5 @@ +import test from '../../entrypoints/main.js'; + +test('test', t => { + t.pass(); +}); diff --git a/test-tap/fixture/eslint-plugin-helper/ava.config.mjs b/test-tap/fixture/eslint-plugin-helper/ava.config.js similarity index 100% rename from test-tap/fixture/eslint-plugin-helper/ava.config.mjs rename to test-tap/fixture/eslint-plugin-helper/ava.config.js diff --git a/test-tap/fixture/eslint-plugin-helper/for-overriding/ava.config.mjs b/test-tap/fixture/eslint-plugin-helper/for-overriding/ava.config.js similarity index 100% rename from test-tap/fixture/eslint-plugin-helper/for-overriding/ava.config.mjs rename to test-tap/fixture/eslint-plugin-helper/for-overriding/ava.config.js diff --git a/test-tap/fixture/extensions/test.foo.bar b/test-tap/fixture/extensions/test.foo.bar index e42d5b244..c66edfb09 100644 --- a/test-tap/fixture/extensions/test.foo.bar +++ b/test-tap/fixture/extensions/test.foo.bar @@ -1,4 +1,4 @@ -const test = require('../../../entrypoints/main.cjs'); +import test from '../../../entrypoints/main.js'; const one = {one: 1}; const two = {two: 2}; diff --git a/test-tap/fixture/fail-fast/crash/crashes.cjs b/test-tap/fixture/fail-fast/crash/crashes.cjs deleted file mode 100644 index 07098e4ff..000000000 --- a/test-tap/fixture/fail-fast/crash/crashes.cjs +++ /dev/null @@ -1,3 +0,0 @@ -require('../../../../entrypoints/main.cjs'); // eslint-disable-line import-x/no-unassigned-import - -process.exit(1); // eslint-disable-line unicorn/no-process-exit diff --git a/test-tap/fixture/fail-fast/crash/crashes.js b/test-tap/fixture/fail-fast/crash/crashes.js new file mode 100644 index 000000000..c5e77c0d6 --- /dev/null +++ b/test-tap/fixture/fail-fast/crash/crashes.js @@ -0,0 +1,3 @@ +import '../../../../entrypoints/main.js'; // eslint-disable-line import-x/no-unassigned-import + +process.exit(1); // eslint-disable-line unicorn/no-process-exit diff --git a/test-tap/fixture/fail-fast/crash/passes.cjs b/test-tap/fixture/fail-fast/crash/passes.cjs deleted file mode 100644 index 0ae796505..000000000 --- a/test-tap/fixture/fail-fast/crash/passes.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -test('first pass', t => { - t.pass(); -}); diff --git a/test-tap/fixture/fail-fast/crash/passes.js b/test-tap/fixture/fail-fast/crash/passes.js new file mode 100644 index 000000000..5723ace61 --- /dev/null +++ b/test-tap/fixture/fail-fast/crash/passes.js @@ -0,0 +1,5 @@ +import test from '../../../../entrypoints/main.js'; + +test('first pass', t => { + t.pass(); +}); diff --git a/test-tap/fixture/fail-fast/multiple-files/fails.cjs b/test-tap/fixture/fail-fast/multiple-files/fails.js similarity index 83% rename from test-tap/fixture/fail-fast/multiple-files/fails.cjs rename to test-tap/fixture/fail-fast/multiple-files/fails.js index c43c6c708..954041de7 100644 --- a/test-tap/fixture/fail-fast/multiple-files/fails.cjs +++ b/test-tap/fixture/fail-fast/multiple-files/fails.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; // Allow some time for all workers to launch. const grace = new Promise(resolve => { diff --git a/test-tap/fixture/fail-fast/multiple-files/passes-slow.cjs b/test-tap/fixture/fail-fast/multiple-files/passes-slow.js similarity index 73% rename from test-tap/fixture/fail-fast/multiple-files/passes-slow.cjs rename to test-tap/fixture/fail-fast/multiple-files/passes-slow.js index 9dd4ebbd0..b5efeb229 100644 --- a/test-tap/fixture/fail-fast/multiple-files/passes-slow.cjs +++ b/test-tap/fixture/fail-fast/multiple-files/passes-slow.js @@ -1,7 +1,7 @@ -const events = require('node:events'); -const {parentPort} = require('node:worker_threads'); +import events from 'node:events'; +import {parentPort} from 'node:worker_threads'; -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test.serial('first pass', async t => { t.pass(); diff --git a/test-tap/fixture/fail-fast/multiple-files/passes.cjs b/test-tap/fixture/fail-fast/multiple-files/passes.cjs deleted file mode 100644 index 0ae796505..000000000 --- a/test-tap/fixture/fail-fast/multiple-files/passes.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -test('first pass', t => { - t.pass(); -}); diff --git a/test-tap/fixture/fail-fast/multiple-files/passes.js b/test-tap/fixture/fail-fast/multiple-files/passes.js new file mode 100644 index 000000000..5723ace61 --- /dev/null +++ b/test-tap/fixture/fail-fast/multiple-files/passes.js @@ -0,0 +1,5 @@ +import test from '../../../../entrypoints/main.js'; + +test('first pass', t => { + t.pass(); +}); diff --git a/test-tap/fixture/fail-fast/single-file/test.cjs b/test-tap/fixture/fail-fast/single-file/test.js similarity index 68% rename from test-tap/fixture/fail-fast/single-file/test.cjs rename to test-tap/fixture/fail-fast/single-file/test.js index f405ec691..8e508db45 100644 --- a/test-tap/fixture/fail-fast/single-file/test.cjs +++ b/test-tap/fixture/fail-fast/single-file/test.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('first pass', t => { t.pass(); diff --git a/test-tap/fixture/fail-fast/timeout/fails.cjs b/test-tap/fixture/fail-fast/timeout/fails.cjs deleted file mode 100644 index a34b55d5f..000000000 --- a/test-tap/fixture/fail-fast/timeout/fails.cjs +++ /dev/null @@ -1,8 +0,0 @@ -const {setTimeout: delay} = require('node:timers/promises'); - -const test = require('../../../../entrypoints/main.cjs'); - -test('slow pass', async t => { - await delay(1000); - t.pass(); -}); diff --git a/test-tap/fixture/fail-fast/timeout/fails.js b/test-tap/fixture/fail-fast/timeout/fails.js new file mode 100644 index 000000000..367415665 --- /dev/null +++ b/test-tap/fixture/fail-fast/timeout/fails.js @@ -0,0 +1,8 @@ +import {setTimeout as delay} from 'node:timers/promises'; + +import test from '../../../../entrypoints/main.js'; + +test('slow pass', async t => { + await delay(1000); + t.pass(); +}); diff --git a/test-tap/fixture/fail-fast/timeout/passes-slow.cjs b/test-tap/fixture/fail-fast/timeout/passes-slow.cjs deleted file mode 100644 index 00dd977a9..000000000 --- a/test-tap/fixture/fail-fast/timeout/passes-slow.cjs +++ /dev/null @@ -1,9 +0,0 @@ -const {setTimeout: delay} = require('node:timers/promises'); - -const test = require('../../../../entrypoints/main.cjs'); - -test('slow pass with timeout', async t => { - t.timeout(120); - await delay(110); - t.pass(); -}); diff --git a/test-tap/fixture/fail-fast/timeout/passes-slow.js b/test-tap/fixture/fail-fast/timeout/passes-slow.js new file mode 100644 index 000000000..7034d7749 --- /dev/null +++ b/test-tap/fixture/fail-fast/timeout/passes-slow.js @@ -0,0 +1,9 @@ +import {setTimeout as delay} from 'node:timers/promises'; + +import test from '../../../../entrypoints/main.js'; + +test('slow pass with timeout', async t => { + t.timeout(120); + await delay(110); + t.pass(); +}); diff --git a/test-tap/fixture/fail-fast/timeout/passes.cjs b/test-tap/fixture/fail-fast/timeout/passes.cjs deleted file mode 100644 index 0ae796505..000000000 --- a/test-tap/fixture/fail-fast/timeout/passes.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -test('first pass', t => { - t.pass(); -}); diff --git a/test-tap/fixture/fail-fast/timeout/passes.js b/test-tap/fixture/fail-fast/timeout/passes.js new file mode 100644 index 000000000..5723ace61 --- /dev/null +++ b/test-tap/fixture/fail-fast/timeout/passes.js @@ -0,0 +1,5 @@ +import test from '../../../../entrypoints/main.js'; + +test('first pass', t => { + t.pass(); +}); diff --git a/test-tap/fixture/fail-fast/without-error/a.cjs b/test-tap/fixture/fail-fast/without-error/a.cjs deleted file mode 100644 index e0d287c19..000000000 --- a/test-tap/fixture/fail-fast/without-error/a.cjs +++ /dev/null @@ -1,3 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -test('pass', t => t.pass()); diff --git a/test-tap/fixture/fail-fast/without-error/a.js b/test-tap/fixture/fail-fast/without-error/a.js new file mode 100644 index 000000000..18e96c62e --- /dev/null +++ b/test-tap/fixture/fail-fast/without-error/a.js @@ -0,0 +1,3 @@ +import test from '../../../../entrypoints/main.js'; + +test('pass', t => t.pass()); diff --git a/test-tap/fixture/fail-fast/without-error/b.cjs b/test-tap/fixture/fail-fast/without-error/b.js similarity index 53% rename from test-tap/fixture/fail-fast/without-error/b.cjs rename to test-tap/fixture/fail-fast/without-error/b.js index ea2877b4f..79f33f3fe 100644 --- a/test-tap/fixture/fail-fast/without-error/b.cjs +++ b/test-tap/fixture/fail-fast/without-error/b.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; setTimeout(() => { test.serial('pass', t => t.pass()); diff --git a/test-tap/fixture/formatting-color.cjs b/test-tap/fixture/formatting-color.js similarity index 53% rename from test-tap/fixture/formatting-color.cjs rename to test-tap/fixture/formatting-color.js index 3a2ae247b..fa7848cc0 100644 --- a/test-tap/fixture/formatting-color.cjs +++ b/test-tap/fixture/formatting-color.js @@ -1,4 +1,4 @@ -const test = require('../../entrypoints/main.cjs'); +import test from '../../entrypoints/main.js'; test('test', t => { t.deepEqual({foo: 1}, {foo: 2}); diff --git a/test-tap/fixture/globs/custom-extension/test/do-not-compile.cjs b/test-tap/fixture/globs/custom-extension/test/do-not-compile.js similarity index 100% rename from test-tap/fixture/globs/custom-extension/test/do-not-compile.cjs rename to test-tap/fixture/globs/custom-extension/test/do-not-compile.js diff --git a/test-tap/fixture/globs/custom-extension/test/helpers/b.cjs b/test-tap/fixture/globs/custom-extension/test/helpers/b.js similarity index 100% rename from test-tap/fixture/globs/custom-extension/test/helpers/b.cjs rename to test-tap/fixture/globs/custom-extension/test/helpers/b.js diff --git a/test-tap/fixture/globs/cwd/dir-a/test/bar.cjs b/test-tap/fixture/globs/cwd/dir-a/test/bar.js similarity index 100% rename from test-tap/fixture/globs/cwd/dir-a/test/bar.cjs rename to test-tap/fixture/globs/cwd/dir-a/test/bar.js diff --git a/test-tap/fixture/globs/cwd/dir-a/test/foo.cjs b/test-tap/fixture/globs/cwd/dir-a/test/foo.js similarity index 100% rename from test-tap/fixture/globs/cwd/dir-a/test/foo.cjs rename to test-tap/fixture/globs/cwd/dir-a/test/foo.js diff --git a/test-tap/fixture/globs/cwd/dir-b/test/baz.cjs b/test-tap/fixture/globs/cwd/dir-b/test/baz.js similarity index 100% rename from test-tap/fixture/globs/cwd/dir-b/test/baz.cjs rename to test-tap/fixture/globs/cwd/dir-b/test/baz.js diff --git a/test-tap/fixture/globs/default-patterns/sub/directory/__tests__/_foo.cjs b/test-tap/fixture/globs/default-patterns/sub/directory/__tests__/_foo.js similarity index 100% rename from test-tap/fixture/globs/default-patterns/sub/directory/__tests__/_foo.cjs rename to test-tap/fixture/globs/default-patterns/sub/directory/__tests__/_foo.js diff --git a/test-tap/fixture/globs/default-patterns/sub/directory/__tests__/fixtures/foo.cjs b/test-tap/fixture/globs/default-patterns/sub/directory/__tests__/fixtures/foo.js similarity index 100% rename from test-tap/fixture/globs/default-patterns/sub/directory/__tests__/fixtures/foo.cjs rename to test-tap/fixture/globs/default-patterns/sub/directory/__tests__/fixtures/foo.js diff --git a/test-tap/fixture/globs/default-patterns/sub/directory/__tests__/foo.cjs b/test-tap/fixture/globs/default-patterns/sub/directory/__tests__/foo.js similarity index 100% rename from test-tap/fixture/globs/default-patterns/sub/directory/__tests__/foo.cjs rename to test-tap/fixture/globs/default-patterns/sub/directory/__tests__/foo.js diff --git a/test-tap/fixture/globs/default-patterns/sub/directory/__tests__/helpers/foo.cjs b/test-tap/fixture/globs/default-patterns/sub/directory/__tests__/helpers/foo.js similarity index 100% rename from test-tap/fixture/globs/default-patterns/sub/directory/__tests__/helpers/foo.cjs rename to test-tap/fixture/globs/default-patterns/sub/directory/__tests__/helpers/foo.js diff --git a/test-tap/fixture/globs/default-patterns/sub/directory/bar.spec.cjs b/test-tap/fixture/globs/default-patterns/sub/directory/bar.spec.js similarity index 100% rename from test-tap/fixture/globs/default-patterns/sub/directory/bar.spec.cjs rename to test-tap/fixture/globs/default-patterns/sub/directory/bar.spec.js diff --git a/test-tap/fixture/globs/default-patterns/sub/directory/bar.test.cjs b/test-tap/fixture/globs/default-patterns/sub/directory/bar.test.js similarity index 100% rename from test-tap/fixture/globs/default-patterns/sub/directory/bar.test.cjs rename to test-tap/fixture/globs/default-patterns/sub/directory/bar.test.js diff --git a/test-tap/fixture/globs/default-patterns/test-foo.cjs b/test-tap/fixture/globs/default-patterns/test-foo.js similarity index 100% rename from test-tap/fixture/globs/default-patterns/test-foo.cjs rename to test-tap/fixture/globs/default-patterns/test-foo.js diff --git a/test-tap/fixture/globs/default-patterns/test.cjs b/test-tap/fixture/globs/default-patterns/test.js similarity index 100% rename from test-tap/fixture/globs/default-patterns/test.cjs rename to test-tap/fixture/globs/default-patterns/test.js diff --git a/test-tap/fixture/globs/default-patterns/test/_foo-help.cjs b/test-tap/fixture/globs/default-patterns/test/_foo-help.js similarity index 100% rename from test-tap/fixture/globs/default-patterns/test/_foo-help.cjs rename to test-tap/fixture/globs/default-patterns/test/_foo-help.js diff --git a/test-tap/fixture/globs/default-patterns/test/baz.cjs b/test-tap/fixture/globs/default-patterns/test/baz.js similarity index 100% rename from test-tap/fixture/globs/default-patterns/test/baz.cjs rename to test-tap/fixture/globs/default-patterns/test/baz.js diff --git a/test-tap/fixture/globs/default-patterns/test/deep/deep.cjs b/test-tap/fixture/globs/default-patterns/test/deep/deep.js similarity index 100% rename from test-tap/fixture/globs/default-patterns/test/deep/deep.cjs rename to test-tap/fixture/globs/default-patterns/test/deep/deep.js diff --git a/test-tap/fixture/globs/default-patterns/test/fixtures/foo-fixt.cjs b/test-tap/fixture/globs/default-patterns/test/fixtures/foo-fixt.js similarity index 100% rename from test-tap/fixture/globs/default-patterns/test/fixtures/foo-fixt.cjs rename to test-tap/fixture/globs/default-patterns/test/fixtures/foo-fixt.js diff --git a/test-tap/fixture/globs/default-patterns/test/helpers/test.cjs b/test-tap/fixture/globs/default-patterns/test/helpers/test.js similarity index 100% rename from test-tap/fixture/globs/default-patterns/test/helpers/test.cjs rename to test-tap/fixture/globs/default-patterns/test/helpers/test.js diff --git a/test-tap/fixture/globs/default-patterns/tests/_foo-help.cjs b/test-tap/fixture/globs/default-patterns/tests/_foo-help.js similarity index 100% rename from test-tap/fixture/globs/default-patterns/tests/_foo-help.cjs rename to test-tap/fixture/globs/default-patterns/tests/_foo-help.js diff --git a/test-tap/fixture/globs/default-patterns/tests/baz.cjs b/test-tap/fixture/globs/default-patterns/tests/baz.js similarity index 100% rename from test-tap/fixture/globs/default-patterns/tests/baz.cjs rename to test-tap/fixture/globs/default-patterns/tests/baz.js diff --git a/test-tap/fixture/globs/default-patterns/tests/deep/deep.cjs b/test-tap/fixture/globs/default-patterns/tests/deep/deep.js similarity index 100% rename from test-tap/fixture/globs/default-patterns/tests/deep/deep.cjs rename to test-tap/fixture/globs/default-patterns/tests/deep/deep.js diff --git a/test-tap/fixture/globs/default-patterns/tests/fixtures/foo-fixt.cjs b/test-tap/fixture/globs/default-patterns/tests/fixtures/foo-fixt.js similarity index 100% rename from test-tap/fixture/globs/default-patterns/tests/fixtures/foo-fixt.cjs rename to test-tap/fixture/globs/default-patterns/tests/fixtures/foo-fixt.js diff --git a/test-tap/fixture/globs/default-patterns/tests/helpers/test.cjs b/test-tap/fixture/globs/default-patterns/tests/helpers/test.js similarity index 100% rename from test-tap/fixture/globs/default-patterns/tests/helpers/test.cjs rename to test-tap/fixture/globs/default-patterns/tests/helpers/test.js diff --git a/test-tap/fixture/hooks-skipped.cjs b/test-tap/fixture/hooks-skipped.js similarity index 85% rename from test-tap/fixture/hooks-skipped.cjs rename to test-tap/fixture/hooks-skipped.js index 05f7a73ca..915c93723 100644 --- a/test-tap/fixture/hooks-skipped.cjs +++ b/test-tap/fixture/hooks-skipped.js @@ -1,4 +1,4 @@ -const test = require('../../entrypoints/main.cjs'); +import test from '../../entrypoints/main.js'; test.before(() => { throw new Error('should not run'); diff --git a/test-tap/fixture/ignored-dirs/helpers/test.cjs b/test-tap/fixture/ignored-dirs/helpers/test.cjs deleted file mode 100644 index deef4eb31..000000000 --- a/test-tap/fixture/ignored-dirs/helpers/test.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -test('test', t => { - t.pass(); -}); diff --git a/test-tap/fixture/ignored-dirs/helpers/test.js b/test-tap/fixture/ignored-dirs/helpers/test.js new file mode 100644 index 000000000..e6493ddf6 --- /dev/null +++ b/test-tap/fixture/ignored-dirs/helpers/test.js @@ -0,0 +1,5 @@ +import test from '../../../../entrypoints/main.js'; + +test('test', t => { + t.pass(); +}); diff --git a/test-tap/fixture/ignored-dirs/test.cjs b/test-tap/fixture/ignored-dirs/test.cjs deleted file mode 100644 index b97019959..000000000 --- a/test-tap/fixture/ignored-dirs/test.cjs +++ /dev/null @@ -1,3 +0,0 @@ -const test = require('../../../entrypoints/main.cjs'); - -test('pass', t => t.pass()); diff --git a/test-tap/fixture/ignored-dirs/test.js b/test-tap/fixture/ignored-dirs/test.js new file mode 100644 index 000000000..90089c2d8 --- /dev/null +++ b/test-tap/fixture/ignored-dirs/test.js @@ -0,0 +1,3 @@ +import test from '../../../entrypoints/main.js'; + +test('pass', t => t.pass()); diff --git a/test-tap/fixture/infinity-stack-trace.cjs b/test-tap/fixture/infinity-stack-trace.js similarity index 71% rename from test-tap/fixture/infinity-stack-trace.cjs rename to test-tap/fixture/infinity-stack-trace.js index 3a6fcd85b..4a6cab6ee 100644 --- a/test-tap/fixture/infinity-stack-trace.cjs +++ b/test-tap/fixture/infinity-stack-trace.js @@ -1,4 +1,4 @@ -const test = require('../../entrypoints/main.cjs'); +import test from '../../entrypoints/main.js'; Error.stackTraceLimit = 1; diff --git a/test-tap/fixture/js.js b/test-tap/fixture/js.js new file mode 100644 index 000000000..76259d42e --- /dev/null +++ b/test-tap/fixture/js.js @@ -0,0 +1,5 @@ +import test from '../../entrypoints/main.js'; + +test('pass', t => { + t.pass(); +}); diff --git a/test-tap/fixture/load-config/cjs/ava.config.cjs b/test-tap/fixture/load-config/cjs/ava.config.cjs deleted file mode 100644 index 1f0b965a1..000000000 --- a/test-tap/fixture/load-config/cjs/ava.config.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const configFactory = ({projectDir}) => ({ - files: projectDir, -}); - -module.exports = configFactory; diff --git a/test-tap/fixture/load-config/cjs/package.json b/test-tap/fixture/load-config/cjs/package.json deleted file mode 100644 index 0967ef424..000000000 --- a/test-tap/fixture/load-config/cjs/package.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/test-tap/fixture/load-config/file-yes-cjs-yes/ava.config.cjs b/test-tap/fixture/load-config/file-yes-cjs-yes/ava.config.cjs deleted file mode 100644 index f7426f1bb..000000000 --- a/test-tap/fixture/load-config/file-yes-cjs-yes/ava.config.cjs +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - files: 'package-yes-files-yes-test-value', -}; diff --git a/test-tap/fixture/load-config/require/ava.config.js b/test-tap/fixture/load-config/require/ava.config.js deleted file mode 100644 index 2383c4d9b..000000000 --- a/test-tap/fixture/load-config/require/ava.config.js +++ /dev/null @@ -1,3 +0,0 @@ -const config = require('./cjs.cjs'); // eslint-disable-line unicorn/prefer-module - -export default config; diff --git a/test-tap/fixture/load-config/require/cjs.cjs b/test-tap/fixture/load-config/require/cjs.cjs deleted file mode 100644 index cbaf3a7fa..000000000 --- a/test-tap/fixture/load-config/require/cjs.cjs +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - files: 'config-file-cjs-test-value', -}; diff --git a/test-tap/fixture/load-config/require/package.json b/test-tap/fixture/load-config/require/package.json deleted file mode 100644 index bedb411a9..000000000 --- a/test-tap/fixture/load-config/require/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "module" -} diff --git a/test-tap/fixture/long-running.cjs b/test-tap/fixture/long-running.js similarity index 54% rename from test-tap/fixture/long-running.cjs rename to test-tap/fixture/long-running.js index 3c8796ebb..353305050 100644 --- a/test-tap/fixture/long-running.cjs +++ b/test-tap/fixture/long-running.js @@ -1,6 +1,6 @@ -const {setTimeout: delay} = require('node:timers/promises'); +import {setTimeout as delay} from 'node:timers/promises'; -const test = require('../../entrypoints/main.cjs'); +import test from '../../entrypoints/main.js'; test('slow', async t => { t.log('helpful log of a pending test'); diff --git a/test-tap/fixture/match-no-match-2.cjs b/test-tap/fixture/match-no-match-2.js similarity index 76% rename from test-tap/fixture/match-no-match-2.cjs rename to test-tap/fixture/match-no-match-2.js index a2fb58582..65465d1c6 100644 --- a/test-tap/fixture/match-no-match-2.cjs +++ b/test-tap/fixture/match-no-match-2.js @@ -1,4 +1,4 @@ -const test = require('../../entrypoints/main.cjs'); +import test from '../../entrypoints/main.js'; test('this test will match', t => { t.pass(); diff --git a/test-tap/fixture/match-no-match.cjs b/test-tap/fixture/match-no-match.js similarity index 68% rename from test-tap/fixture/match-no-match.cjs rename to test-tap/fixture/match-no-match.js index 9710548a7..8b3fc9021 100644 --- a/test-tap/fixture/match-no-match.cjs +++ b/test-tap/fixture/match-no-match.js @@ -1,4 +1,4 @@ -const test = require('../../entrypoints/main.cjs'); +import test from '../../entrypoints/main.js'; test('foo', t => { t.pass(); diff --git a/test-tap/fixture/matcher-skip.cjs b/test-tap/fixture/matcher-skip.js similarity index 79% rename from test-tap/fixture/matcher-skip.cjs rename to test-tap/fixture/matcher-skip.js index 5d7d69d3b..71f59dd79 100644 --- a/test-tap/fixture/matcher-skip.cjs +++ b/test-tap/fixture/matcher-skip.js @@ -1,4 +1,4 @@ -const test = require('../../entrypoints/main.cjs'); +import test from '../../entrypoints/main.js'; test('foo', t => { t.pass(); diff --git a/test-tap/fixture/mjs.mjs b/test-tap/fixture/mjs.mjs index 37b160d18..76259d42e 100644 --- a/test-tap/fixture/mjs.mjs +++ b/test-tap/fixture/mjs.mjs @@ -1,4 +1,4 @@ -import test from '../../entrypoints/main.mjs'; +import test from '../../entrypoints/main.js'; test('pass', t => { t.pass(); diff --git a/test-tap/fixture/no-tests.cjs b/test-tap/fixture/no-tests.cjs deleted file mode 100644 index 498d1d1c2..000000000 --- a/test-tap/fixture/no-tests.cjs +++ /dev/null @@ -1 +0,0 @@ -require('../../entrypoints/main.cjs'); // eslint-disable-line import-x/no-unassigned-import diff --git a/test-tap/fixture/no-tests.js b/test-tap/fixture/no-tests.js new file mode 100644 index 000000000..8dd081bfe --- /dev/null +++ b/test-tap/fixture/no-tests.js @@ -0,0 +1 @@ +import '../../entrypoints/main.js'; // eslint-disable-line import-x/no-unassigned-import diff --git a/test-tap/fixture/node-env-foo.cjs b/test-tap/fixture/node-env-foo.js similarity index 61% rename from test-tap/fixture/node-env-foo.cjs rename to test-tap/fixture/node-env-foo.js index 3a5418cdf..0bafc3f1b 100644 --- a/test-tap/fixture/node-env-foo.cjs +++ b/test-tap/fixture/node-env-foo.js @@ -1,4 +1,4 @@ -const test = require('../../entrypoints/main.cjs'); +import test from '../../entrypoints/main.js'; test('NODE_ENV is foo', t => { t.plan(1); diff --git a/test-tap/fixture/node-env-test.cjs b/test-tap/fixture/node-env-test.js similarity index 62% rename from test-tap/fixture/node-env-test.cjs rename to test-tap/fixture/node-env-test.js index fcf5a3ca3..55366b360 100644 --- a/test-tap/fixture/node-env-test.cjs +++ b/test-tap/fixture/node-env-test.js @@ -1,4 +1,4 @@ -const test = require('../../entrypoints/main.cjs'); +import test from '../../entrypoints/main.js'; test('NODE_ENV is test', t => { t.plan(1); diff --git a/test-tap/fixture/package-config/fail-without-assertions/test.cjs b/test-tap/fixture/package-config/fail-without-assertions/test.cjs deleted file mode 100644 index 828875daa..000000000 --- a/test-tap/fixture/package-config/fail-without-assertions/test.cjs +++ /dev/null @@ -1,3 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -test('test', () => {}); diff --git a/test-tap/fixture/package-config/fail-without-assertions/test.js b/test-tap/fixture/package-config/fail-without-assertions/test.js new file mode 100644 index 000000000..33876f199 --- /dev/null +++ b/test-tap/fixture/package-config/fail-without-assertions/test.js @@ -0,0 +1,3 @@ +import test from '../../../../entrypoints/main.js'; + +test('test', () => {}); diff --git a/test-tap/fixture/parallel-runs/custom-comparator/0-1.cjs b/test-tap/fixture/parallel-runs/custom-comparator/0-1.js similarity index 57% rename from test-tap/fixture/parallel-runs/custom-comparator/0-1.cjs rename to test-tap/fixture/parallel-runs/custom-comparator/0-1.js index 5b1c05662..d410148d2 100644 --- a/test-tap/fixture/parallel-runs/custom-comparator/0-1.cjs +++ b/test-tap/fixture/parallel-runs/custom-comparator/0-1.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('at expected index', t => { t.is(process.env.CI_NODE_INDEX, '2'); diff --git a/test-tap/fixture/parallel-runs/custom-comparator/0-2.cjs b/test-tap/fixture/parallel-runs/custom-comparator/0-2.js similarity index 57% rename from test-tap/fixture/parallel-runs/custom-comparator/0-2.cjs rename to test-tap/fixture/parallel-runs/custom-comparator/0-2.js index 5b1c05662..d410148d2 100644 --- a/test-tap/fixture/parallel-runs/custom-comparator/0-2.cjs +++ b/test-tap/fixture/parallel-runs/custom-comparator/0-2.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('at expected index', t => { t.is(process.env.CI_NODE_INDEX, '2'); diff --git a/test-tap/fixture/parallel-runs/custom-comparator/0-3.cjs b/test-tap/fixture/parallel-runs/custom-comparator/0-3.js similarity index 57% rename from test-tap/fixture/parallel-runs/custom-comparator/0-3.cjs rename to test-tap/fixture/parallel-runs/custom-comparator/0-3.js index 5b1c05662..d410148d2 100644 --- a/test-tap/fixture/parallel-runs/custom-comparator/0-3.cjs +++ b/test-tap/fixture/parallel-runs/custom-comparator/0-3.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('at expected index', t => { t.is(process.env.CI_NODE_INDEX, '2'); diff --git a/test-tap/fixture/parallel-runs/custom-comparator/1-2.cjs b/test-tap/fixture/parallel-runs/custom-comparator/1-1.js similarity index 57% rename from test-tap/fixture/parallel-runs/custom-comparator/1-2.cjs rename to test-tap/fixture/parallel-runs/custom-comparator/1-1.js index ccb999168..7447a8383 100644 --- a/test-tap/fixture/parallel-runs/custom-comparator/1-2.cjs +++ b/test-tap/fixture/parallel-runs/custom-comparator/1-1.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('at expected index', t => { t.is(process.env.CI_NODE_INDEX, '1'); diff --git a/test-tap/fixture/parallel-runs/custom-comparator/1-3.cjs b/test-tap/fixture/parallel-runs/custom-comparator/1-2.js similarity index 57% rename from test-tap/fixture/parallel-runs/custom-comparator/1-3.cjs rename to test-tap/fixture/parallel-runs/custom-comparator/1-2.js index ccb999168..7447a8383 100644 --- a/test-tap/fixture/parallel-runs/custom-comparator/1-3.cjs +++ b/test-tap/fixture/parallel-runs/custom-comparator/1-2.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('at expected index', t => { t.is(process.env.CI_NODE_INDEX, '1'); diff --git a/test-tap/fixture/parallel-runs/less-files-than-ci-total/9.cjs b/test-tap/fixture/parallel-runs/custom-comparator/1-3.js similarity index 57% rename from test-tap/fixture/parallel-runs/less-files-than-ci-total/9.cjs rename to test-tap/fixture/parallel-runs/custom-comparator/1-3.js index ccb999168..7447a8383 100644 --- a/test-tap/fixture/parallel-runs/less-files-than-ci-total/9.cjs +++ b/test-tap/fixture/parallel-runs/custom-comparator/1-3.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('at expected index', t => { t.is(process.env.CI_NODE_INDEX, '1'); diff --git a/test-tap/fixture/parallel-runs/custom-comparator/2-1.cjs b/test-tap/fixture/parallel-runs/custom-comparator/2-1.js similarity index 57% rename from test-tap/fixture/parallel-runs/custom-comparator/2-1.cjs rename to test-tap/fixture/parallel-runs/custom-comparator/2-1.js index a40e62fb8..1b3300b18 100644 --- a/test-tap/fixture/parallel-runs/custom-comparator/2-1.cjs +++ b/test-tap/fixture/parallel-runs/custom-comparator/2-1.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('at expected index', t => { t.is(process.env.CI_NODE_INDEX, '0'); diff --git a/test-tap/fixture/parallel-runs/custom-comparator/2-2.cjs b/test-tap/fixture/parallel-runs/custom-comparator/2-2.js similarity index 57% rename from test-tap/fixture/parallel-runs/custom-comparator/2-2.cjs rename to test-tap/fixture/parallel-runs/custom-comparator/2-2.js index a40e62fb8..1b3300b18 100644 --- a/test-tap/fixture/parallel-runs/custom-comparator/2-2.cjs +++ b/test-tap/fixture/parallel-runs/custom-comparator/2-2.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('at expected index', t => { t.is(process.env.CI_NODE_INDEX, '0'); diff --git a/test-tap/fixture/parallel-runs/custom-comparator/2-3.cjs b/test-tap/fixture/parallel-runs/custom-comparator/2-3.js similarity index 57% rename from test-tap/fixture/parallel-runs/custom-comparator/2-3.cjs rename to test-tap/fixture/parallel-runs/custom-comparator/2-3.js index a40e62fb8..1b3300b18 100644 --- a/test-tap/fixture/parallel-runs/custom-comparator/2-3.cjs +++ b/test-tap/fixture/parallel-runs/custom-comparator/2-3.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('at expected index', t => { t.is(process.env.CI_NODE_INDEX, '0'); diff --git a/test-tap/fixture/parallel-runs/custom-comparator/ava.config.js b/test-tap/fixture/parallel-runs/custom-comparator/ava.config.js index 935e14cf2..6d91eb613 100644 --- a/test-tap/fixture/parallel-runs/custom-comparator/ava.config.js +++ b/test-tap/fixture/parallel-runs/custom-comparator/ava.config.js @@ -1,5 +1,5 @@ export default { - files: ['*.cjs'], + files: ['[0-9]*.js'], // Descending order sortTestFiles: (a, b) => b.localeCompare(a, [], {numeric: true}), }; diff --git a/test-tap/fixture/parallel-runs/less-files-than-ci-total/2.cjs b/test-tap/fixture/parallel-runs/less-files-than-ci-total/2.js similarity index 57% rename from test-tap/fixture/parallel-runs/less-files-than-ci-total/2.cjs rename to test-tap/fixture/parallel-runs/less-files-than-ci-total/2.js index a40e62fb8..1b3300b18 100644 --- a/test-tap/fixture/parallel-runs/less-files-than-ci-total/2.cjs +++ b/test-tap/fixture/parallel-runs/less-files-than-ci-total/2.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('at expected index', t => { t.is(process.env.CI_NODE_INDEX, '0'); diff --git a/test-tap/fixture/parallel-runs/custom-comparator/1-1.cjs b/test-tap/fixture/parallel-runs/less-files-than-ci-total/9.js similarity index 57% rename from test-tap/fixture/parallel-runs/custom-comparator/1-1.cjs rename to test-tap/fixture/parallel-runs/less-files-than-ci-total/9.js index ccb999168..7447a8383 100644 --- a/test-tap/fixture/parallel-runs/custom-comparator/1-1.cjs +++ b/test-tap/fixture/parallel-runs/less-files-than-ci-total/9.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('at expected index', t => { t.is(process.env.CI_NODE_INDEX, '1'); diff --git a/test-tap/fixture/parallel-runs/less-files-than-ci-total/package.json b/test-tap/fixture/parallel-runs/less-files-than-ci-total/package.json index 82a861884..a0befd106 100644 --- a/test-tap/fixture/parallel-runs/less-files-than-ci-total/package.json +++ b/test-tap/fixture/parallel-runs/less-files-than-ci-total/package.json @@ -1,7 +1,7 @@ { "ava": { "files": [ - "*.cjs" + "*.js" ] } } diff --git a/test-tap/fixture/parallel-runs/more-files-than-ci-total/10.cjs b/test-tap/fixture/parallel-runs/more-files-than-ci-total/10.cjs deleted file mode 100644 index ccb999168..000000000 --- a/test-tap/fixture/parallel-runs/more-files-than-ci-total/10.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -test('at expected index', t => { - t.is(process.env.CI_NODE_INDEX, '1'); -}); diff --git a/test-tap/fixture/parallel-runs/more-files-than-ci-total/10.js b/test-tap/fixture/parallel-runs/more-files-than-ci-total/10.js new file mode 100644 index 000000000..7447a8383 --- /dev/null +++ b/test-tap/fixture/parallel-runs/more-files-than-ci-total/10.js @@ -0,0 +1,5 @@ +import test from '../../../../entrypoints/main.js'; + +test('at expected index', t => { + t.is(process.env.CI_NODE_INDEX, '1'); +}); diff --git a/test-tap/fixture/parallel-runs/more-files-than-ci-total/2.cjs b/test-tap/fixture/parallel-runs/more-files-than-ci-total/2.cjs deleted file mode 100644 index a40e62fb8..000000000 --- a/test-tap/fixture/parallel-runs/more-files-than-ci-total/2.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -test('at expected index', t => { - t.is(process.env.CI_NODE_INDEX, '0'); -}); diff --git a/test-tap/fixture/parallel-runs/more-files-than-ci-total/2.js b/test-tap/fixture/parallel-runs/more-files-than-ci-total/2.js new file mode 100644 index 000000000..1b3300b18 --- /dev/null +++ b/test-tap/fixture/parallel-runs/more-files-than-ci-total/2.js @@ -0,0 +1,5 @@ +import test from '../../../../entrypoints/main.js'; + +test('at expected index', t => { + t.is(process.env.CI_NODE_INDEX, '0'); +}); diff --git a/test-tap/fixture/parallel-runs/more-files-than-ci-total/2a.cjs b/test-tap/fixture/parallel-runs/more-files-than-ci-total/2a.cjs deleted file mode 100644 index a40e62fb8..000000000 --- a/test-tap/fixture/parallel-runs/more-files-than-ci-total/2a.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -test('at expected index', t => { - t.is(process.env.CI_NODE_INDEX, '0'); -}); diff --git a/test-tap/fixture/parallel-runs/more-files-than-ci-total/2a.js b/test-tap/fixture/parallel-runs/more-files-than-ci-total/2a.js new file mode 100644 index 000000000..1b3300b18 --- /dev/null +++ b/test-tap/fixture/parallel-runs/more-files-than-ci-total/2a.js @@ -0,0 +1,5 @@ +import test from '../../../../entrypoints/main.js'; + +test('at expected index', t => { + t.is(process.env.CI_NODE_INDEX, '0'); +}); diff --git a/test-tap/fixture/parallel-runs/more-files-than-ci-total/9.cjs b/test-tap/fixture/parallel-runs/more-files-than-ci-total/9.cjs deleted file mode 100644 index a40e62fb8..000000000 --- a/test-tap/fixture/parallel-runs/more-files-than-ci-total/9.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -test('at expected index', t => { - t.is(process.env.CI_NODE_INDEX, '0'); -}); diff --git a/test-tap/fixture/parallel-runs/more-files-than-ci-total/9.js b/test-tap/fixture/parallel-runs/more-files-than-ci-total/9.js new file mode 100644 index 000000000..1b3300b18 --- /dev/null +++ b/test-tap/fixture/parallel-runs/more-files-than-ci-total/9.js @@ -0,0 +1,5 @@ +import test from '../../../../entrypoints/main.js'; + +test('at expected index', t => { + t.is(process.env.CI_NODE_INDEX, '0'); +}); diff --git a/test-tap/fixture/parallel-runs/more-files-than-ci-total/Ab.cjs b/test-tap/fixture/parallel-runs/more-files-than-ci-total/Ab.js similarity index 67% rename from test-tap/fixture/parallel-runs/more-files-than-ci-total/Ab.cjs rename to test-tap/fixture/parallel-runs/more-files-than-ci-total/Ab.js index 12fdfb043..d1833c607 100644 --- a/test-tap/fixture/parallel-runs/more-files-than-ci-total/Ab.cjs +++ b/test-tap/fixture/parallel-runs/more-files-than-ci-total/Ab.js @@ -1,5 +1,5 @@ /* eslint-disable unicorn/filename-case */ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('at expected index', t => { t.is(process.env.CI_NODE_INDEX, '1'); diff --git a/test-tap/fixture/parallel-runs/more-files-than-ci-total/a.cjs b/test-tap/fixture/parallel-runs/more-files-than-ci-total/a.cjs deleted file mode 100644 index ccb999168..000000000 --- a/test-tap/fixture/parallel-runs/more-files-than-ci-total/a.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -test('at expected index', t => { - t.is(process.env.CI_NODE_INDEX, '1'); -}); diff --git a/test-tap/fixture/parallel-runs/more-files-than-ci-total/a.js b/test-tap/fixture/parallel-runs/more-files-than-ci-total/a.js new file mode 100644 index 000000000..7447a8383 --- /dev/null +++ b/test-tap/fixture/parallel-runs/more-files-than-ci-total/a.js @@ -0,0 +1,5 @@ +import test from '../../../../entrypoints/main.js'; + +test('at expected index', t => { + t.is(process.env.CI_NODE_INDEX, '1'); +}); diff --git a/test-tap/fixture/parallel-runs/more-files-than-ci-total/b.cjs b/test-tap/fixture/parallel-runs/more-files-than-ci-total/b.js similarity index 57% rename from test-tap/fixture/parallel-runs/more-files-than-ci-total/b.cjs rename to test-tap/fixture/parallel-runs/more-files-than-ci-total/b.js index 5b1c05662..d410148d2 100644 --- a/test-tap/fixture/parallel-runs/more-files-than-ci-total/b.cjs +++ b/test-tap/fixture/parallel-runs/more-files-than-ci-total/b.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('at expected index', t => { t.is(process.env.CI_NODE_INDEX, '2'); diff --git a/test-tap/fixture/parallel-runs/more-files-than-ci-total/c.cjs b/test-tap/fixture/parallel-runs/more-files-than-ci-total/c.cjs deleted file mode 100644 index 5b1c05662..000000000 --- a/test-tap/fixture/parallel-runs/more-files-than-ci-total/c.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -test('at expected index', t => { - t.is(process.env.CI_NODE_INDEX, '2'); -}); diff --git a/test-tap/fixture/parallel-runs/more-files-than-ci-total/c.js b/test-tap/fixture/parallel-runs/more-files-than-ci-total/c.js new file mode 100644 index 000000000..d410148d2 --- /dev/null +++ b/test-tap/fixture/parallel-runs/more-files-than-ci-total/c.js @@ -0,0 +1,5 @@ +import test from '../../../../entrypoints/main.js'; + +test('at expected index', t => { + t.is(process.env.CI_NODE_INDEX, '2'); +}); diff --git a/test-tap/fixture/parallel-runs/more-files-than-ci-total/package.json b/test-tap/fixture/parallel-runs/more-files-than-ci-total/package.json index 82a861884..a0befd106 100644 --- a/test-tap/fixture/parallel-runs/more-files-than-ci-total/package.json +++ b/test-tap/fixture/parallel-runs/more-files-than-ci-total/package.json @@ -1,7 +1,7 @@ { "ava": { "files": [ - "*.cjs" + "*.js" ] } } diff --git a/test-tap/fixture/parallel-runs/no-files/package.json b/test-tap/fixture/parallel-runs/no-files/package.json index 82a861884..a0befd106 100644 --- a/test-tap/fixture/parallel-runs/no-files/package.json +++ b/test-tap/fixture/parallel-runs/no-files/package.json @@ -1,7 +1,7 @@ { "ava": { "files": [ - "*.cjs" + "*.js" ] } } diff --git a/test-tap/fixture/pkg-type-module/test.js b/test-tap/fixture/pkg-type-module/test.js index 15195a7ff..0d343d02a 100644 --- a/test-tap/fixture/pkg-type-module/test.js +++ b/test-tap/fixture/pkg-type-module/test.js @@ -1,4 +1,4 @@ -import test from '../../../entrypoints/main.mjs'; +import test from '../../../entrypoints/main.js'; test('pass', t => { t.pass(); diff --git a/test-tap/fixture/process-cwd-default.cjs b/test-tap/fixture/process-cwd-default.js similarity index 74% rename from test-tap/fixture/process-cwd-default.cjs rename to test-tap/fixture/process-cwd-default.js index 17c35b8b5..51304ddc7 100644 --- a/test-tap/fixture/process-cwd-default.cjs +++ b/test-tap/fixture/process-cwd-default.js @@ -1,6 +1,6 @@ -const path = require('node:path'); +import path from 'node:path'; -const test = require('../../entrypoints/main.cjs'); +import test from '../../entrypoints/main.js'; test('test', async t => { const {packageConfigSync, packageJsonPath} = await import('package-config'); diff --git a/test-tap/fixture/process-cwd-pkgdir.cjs b/test-tap/fixture/process-cwd-pkgdir.cjs deleted file mode 100644 index 13b075adf..000000000 --- a/test-tap/fixture/process-cwd-pkgdir.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../entrypoints/main.cjs'); - -test('test', t => { - t.is(process.cwd(), __dirname); -}); diff --git a/test-tap/fixture/process-cwd-pkgdir.js b/test-tap/fixture/process-cwd-pkgdir.js new file mode 100644 index 000000000..7a4f4553a --- /dev/null +++ b/test-tap/fixture/process-cwd-pkgdir.js @@ -0,0 +1,7 @@ +import {fileURLToPath} from 'node:url'; + +import test from '../../entrypoints/main.js'; + +test('test', t => { + t.is(process.cwd(), fileURLToPath(new URL('.', import.meta.url))); +}); diff --git a/test-tap/fixture/report/README.md b/test-tap/fixture/report/README.md index 929be91b9..ad2876092 100644 --- a/test-tap/fixture/report/README.md +++ b/test-tap/fixture/report/README.md @@ -1,3 +1,3 @@ -To run these tests directly, `cd` into the respective directories and invoke via `node ../../../../entrypoints/cli.mjs`. +To run these tests directly, `cd` into the respective directories and invoke via `node ../../../../entrypoints/cli.js`. Note that the `report` helper sorts the test files before running tests. diff --git a/test-tap/fixture/report/edgecases/ast-syntax-error.cjs b/test-tap/fixture/report/edgecases/ast-syntax-error.cjs deleted file mode 100644 index 7bde727f5..000000000 --- a/test-tap/fixture/report/edgecases/ast-syntax-error.cjs +++ /dev/null @@ -1,7 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -const fn = do { - t => t.pass(); -}; - -test('fn', fn); diff --git a/test-tap/fixture/report/edgecases/ast-syntax-error.js b/test-tap/fixture/report/edgecases/ast-syntax-error.js new file mode 100644 index 000000000..b8c92ed8b --- /dev/null +++ b/test-tap/fixture/report/edgecases/ast-syntax-error.js @@ -0,0 +1,7 @@ +import test from '../../../../entrypoints/main.js'; + +const fn = do { + t => t.pass(); +}; + +test('fn', fn); diff --git a/test-tap/fixture/report/edgecases/ava-import-no-test-declaration.cjs b/test-tap/fixture/report/edgecases/ava-import-no-test-declaration.cjs deleted file mode 100644 index 2b5c1939e..000000000 --- a/test-tap/fixture/report/edgecases/ava-import-no-test-declaration.cjs +++ /dev/null @@ -1 +0,0 @@ -require('../../../../entrypoints/main.cjs'); // eslint-disable-line import-x/no-unassigned-import diff --git a/test-tap/fixture/report/edgecases/ava-import-no-test-declaration.js b/test-tap/fixture/report/edgecases/ava-import-no-test-declaration.js new file mode 100644 index 000000000..0a9962015 --- /dev/null +++ b/test-tap/fixture/report/edgecases/ava-import-no-test-declaration.js @@ -0,0 +1 @@ +import '../../../../entrypoints/main.js'; // eslint-disable-line import-x/no-unassigned-import diff --git a/test-tap/fixture/report/edgecases/import-and-use-test-member.cjs b/test-tap/fixture/report/edgecases/import-and-use-test-member.cjs deleted file mode 100644 index 892440da3..000000000 --- a/test-tap/fixture/report/edgecases/import-and-use-test-member.cjs +++ /dev/null @@ -1,3 +0,0 @@ -const {test} = require('../../../../entrypoints/main.cjs'); - -test('pass', t => t.pass()); diff --git a/test-tap/fixture/report/edgecases/import-and-use-test-member.js b/test-tap/fixture/report/edgecases/import-and-use-test-member.js new file mode 100644 index 000000000..405ee42a3 --- /dev/null +++ b/test-tap/fixture/report/edgecases/import-and-use-test-member.js @@ -0,0 +1,3 @@ +const {test} = await import('../../../../entrypoints/main.js'); + +test('pass', t => t.pass()); diff --git a/test-tap/fixture/report/edgecases/no-ava-import.cjs b/test-tap/fixture/report/edgecases/no-ava-import.js similarity index 100% rename from test-tap/fixture/report/edgecases/no-ava-import.cjs rename to test-tap/fixture/report/edgecases/no-ava-import.js diff --git a/test-tap/fixture/report/edgecases/test.cjs b/test-tap/fixture/report/edgecases/test.cjs deleted file mode 100644 index 3da3b2d3e..000000000 --- a/test-tap/fixture/report/edgecases/test.cjs +++ /dev/null @@ -1,3 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -test('passes', t => t.pass()); diff --git a/test-tap/fixture/report/edgecases/test.js b/test-tap/fixture/report/edgecases/test.js new file mode 100644 index 000000000..32c4bbc22 --- /dev/null +++ b/test-tap/fixture/report/edgecases/test.js @@ -0,0 +1,3 @@ +import test from '../../../../entrypoints/main.js'; + +test('passes', t => t.pass()); diff --git a/test-tap/fixture/report/edgecases/throws.cjs b/test-tap/fixture/report/edgecases/throws.js similarity index 100% rename from test-tap/fixture/report/edgecases/throws.cjs rename to test-tap/fixture/report/edgecases/throws.js diff --git a/test-tap/fixture/report/failfast/a.cjs b/test-tap/fixture/report/failfast/a.cjs deleted file mode 100644 index 44c876b0c..000000000 --- a/test-tap/fixture/report/failfast/a.cjs +++ /dev/null @@ -1,3 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -test('fails', t => t.fail()); diff --git a/test-tap/fixture/report/failfast/a.js b/test-tap/fixture/report/failfast/a.js new file mode 100644 index 000000000..47c9ed8f8 --- /dev/null +++ b/test-tap/fixture/report/failfast/a.js @@ -0,0 +1,3 @@ +import test from '../../../../entrypoints/main.js'; + +test('fails', t => t.fail()); diff --git a/test-tap/fixture/report/failfast/b.cjs b/test-tap/fixture/report/failfast/b.cjs deleted file mode 100644 index 3da3b2d3e..000000000 --- a/test-tap/fixture/report/failfast/b.cjs +++ /dev/null @@ -1,3 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -test('passes', t => t.pass()); diff --git a/test-tap/fixture/report/failfast/b.js b/test-tap/fixture/report/failfast/b.js new file mode 100644 index 000000000..32c4bbc22 --- /dev/null +++ b/test-tap/fixture/report/failfast/b.js @@ -0,0 +1,3 @@ +import test from '../../../../entrypoints/main.js'; + +test('passes', t => t.pass()); diff --git a/test-tap/fixture/report/failfast2/a.cjs b/test-tap/fixture/report/failfast2/a.js similarity index 51% rename from test-tap/fixture/report/failfast2/a.cjs rename to test-tap/fixture/report/failfast2/a.js index c41a2ca74..b3f384adf 100644 --- a/test-tap/fixture/report/failfast2/a.cjs +++ b/test-tap/fixture/report/failfast2/a.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('fails', t => t.fail()); test('passes', t => t.pass()); diff --git a/test-tap/fixture/report/failfast2/b.cjs b/test-tap/fixture/report/failfast2/b.cjs deleted file mode 100644 index 3da3b2d3e..000000000 --- a/test-tap/fixture/report/failfast2/b.cjs +++ /dev/null @@ -1,3 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -test('passes', t => t.pass()); diff --git a/test-tap/fixture/report/failfast2/b.js b/test-tap/fixture/report/failfast2/b.js new file mode 100644 index 000000000..32c4bbc22 --- /dev/null +++ b/test-tap/fixture/report/failfast2/b.js @@ -0,0 +1,3 @@ +import test from '../../../../entrypoints/main.js'; + +test('passes', t => t.pass()); diff --git a/test-tap/fixture/report/only/a.cjs b/test-tap/fixture/report/only/a.js similarity index 53% rename from test-tap/fixture/report/only/a.cjs rename to test-tap/fixture/report/only/a.js index 0858aecdc..87faf91cd 100644 --- a/test-tap/fixture/report/only/a.cjs +++ b/test-tap/fixture/report/only/a.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test.only('only', t => t.pass()); diff --git a/test-tap/fixture/report/only/b.cjs b/test-tap/fixture/report/only/b.cjs deleted file mode 100644 index 3da3b2d3e..000000000 --- a/test-tap/fixture/report/only/b.cjs +++ /dev/null @@ -1,3 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -test('passes', t => t.pass()); diff --git a/test-tap/fixture/report/only/b.js b/test-tap/fixture/report/only/b.js new file mode 100644 index 000000000..32c4bbc22 --- /dev/null +++ b/test-tap/fixture/report/only/b.js @@ -0,0 +1,3 @@ +import test from '../../../../entrypoints/main.js'; + +test('passes', t => t.pass()); diff --git a/test-tap/fixture/report/regular/bad-test-chain.cjs b/test-tap/fixture/report/regular/bad-test-chain.cjs deleted file mode 100644 index c7e8f73fd..000000000 --- a/test-tap/fixture/report/regular/bad-test-chain.cjs +++ /dev/null @@ -1,3 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -test.serial.test('passes', t => t.pass()); diff --git a/test-tap/fixture/report/regular/bad-test-chain.js b/test-tap/fixture/report/regular/bad-test-chain.js new file mode 100644 index 000000000..7d5c01026 --- /dev/null +++ b/test-tap/fixture/report/regular/bad-test-chain.js @@ -0,0 +1,3 @@ +import test from '../../../../entrypoints/main.js'; + +test.serial.test('passes', t => t.pass()); diff --git a/test-tap/fixture/report/regular/nested-objects.cjs b/test-tap/fixture/report/regular/nested-objects.js similarity index 85% rename from test-tap/fixture/report/regular/nested-objects.cjs rename to test-tap/fixture/report/regular/nested-objects.js index 0e60e8788..8581341e7 100644 --- a/test-tap/fixture/report/regular/nested-objects.cjs +++ b/test-tap/fixture/report/regular/nested-objects.js @@ -1,6 +1,6 @@ -const {inspect} = require('node:util'); +import {inspect} from 'node:util'; -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; inspect.defaultOptions.depth = 4; diff --git a/test-tap/fixture/report/regular/output-in-hook.cjs b/test-tap/fixture/report/regular/output-in-hook.js similarity index 88% rename from test-tap/fixture/report/regular/output-in-hook.cjs rename to test-tap/fixture/report/regular/output-in-hook.js index e33d2f628..b06537d1f 100644 --- a/test-tap/fixture/report/regular/output-in-hook.cjs +++ b/test-tap/fixture/report/regular/output-in-hook.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test.before(() => {}); diff --git a/test-tap/fixture/report/regular/test.cjs b/test-tap/fixture/report/regular/test.js similarity index 88% rename from test-tap/fixture/report/regular/test.cjs rename to test-tap/fixture/report/regular/test.js index 7abee60c7..4d5c51c9f 100644 --- a/test-tap/fixture/report/regular/test.cjs +++ b/test-tap/fixture/report/regular/test.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('passes', t => t.pass()); diff --git a/test-tap/fixture/report/regular/traces-in-t-throws.cjs b/test-tap/fixture/report/regular/traces-in-t-throws.js similarity index 91% rename from test-tap/fixture/report/regular/traces-in-t-throws.cjs rename to test-tap/fixture/report/regular/traces-in-t-throws.js index 3cccf6833..f003d89af 100644 --- a/test-tap/fixture/report/regular/traces-in-t-throws.cjs +++ b/test-tap/fixture/report/regular/traces-in-t-throws.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; function throwError() { throw new Error('uh-oh'); diff --git a/test-tap/fixture/report/regular/uncaught-exception.cjs b/test-tap/fixture/report/regular/uncaught-exception.js similarity index 64% rename from test-tap/fixture/report/regular/uncaught-exception.cjs rename to test-tap/fixture/report/regular/uncaught-exception.js index db4039997..63f8d7a9c 100644 --- a/test-tap/fixture/report/regular/uncaught-exception.cjs +++ b/test-tap/fixture/report/regular/uncaught-exception.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('passes', t => { setImmediate(() => { diff --git a/test-tap/fixture/report/regular/unhandled-rejection.cjs b/test-tap/fixture/report/regular/unhandled-rejection.js similarity index 78% rename from test-tap/fixture/report/regular/unhandled-rejection.cjs rename to test-tap/fixture/report/regular/unhandled-rejection.js index e3b1e5ef7..637eab449 100644 --- a/test-tap/fixture/report/regular/unhandled-rejection.cjs +++ b/test-tap/fixture/report/regular/unhandled-rejection.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; const passes = t => { Promise.reject(new Error('Can’t catch me')); diff --git a/test-tap/fixture/report/timeoutcontextlogs/a.cjs b/test-tap/fixture/report/timeoutcontextlogs/a.js similarity index 77% rename from test-tap/fixture/report/timeoutcontextlogs/a.cjs rename to test-tap/fixture/report/timeoutcontextlogs/a.js index 23a58d138..102577538 100644 --- a/test-tap/fixture/report/timeoutcontextlogs/a.cjs +++ b/test-tap/fixture/report/timeoutcontextlogs/a.js @@ -1,6 +1,6 @@ -const {setTimeout: delay} = require('node:timers/promises'); +import {setTimeout as delay} from 'node:timers/promises'; -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('a passes', t => t.pass()); diff --git a/test-tap/fixture/report/timeoutcontextlogs/b.cjs b/test-tap/fixture/report/timeoutcontextlogs/b.js similarity index 73% rename from test-tap/fixture/report/timeoutcontextlogs/b.cjs rename to test-tap/fixture/report/timeoutcontextlogs/b.js index d7d08852e..3571ccb3c 100644 --- a/test-tap/fixture/report/timeoutcontextlogs/b.cjs +++ b/test-tap/fixture/report/timeoutcontextlogs/b.js @@ -1,6 +1,6 @@ -const {setTimeout: delay} = require('node:timers/promises'); +import {setTimeout as delay} from 'node:timers/promises'; -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('a passes', t => t.pass()); diff --git a/test-tap/fixture/report/timeoutinmultiplefiles/a.cjs b/test-tap/fixture/report/timeoutinmultiplefiles/a.js similarity index 63% rename from test-tap/fixture/report/timeoutinmultiplefiles/a.cjs rename to test-tap/fixture/report/timeoutinmultiplefiles/a.js index 68b73b53a..979324b88 100644 --- a/test-tap/fixture/report/timeoutinmultiplefiles/a.cjs +++ b/test-tap/fixture/report/timeoutinmultiplefiles/a.js @@ -1,6 +1,6 @@ -const {setTimeout: delay} = require('node:timers/promises'); +import {setTimeout as delay} from 'node:timers/promises'; -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('a passes', t => t.pass()); diff --git a/test-tap/fixture/report/timeoutinmultiplefiles/b.cjs b/test-tap/fixture/report/timeoutinmultiplefiles/b.js similarity index 69% rename from test-tap/fixture/report/timeoutinmultiplefiles/b.cjs rename to test-tap/fixture/report/timeoutinmultiplefiles/b.js index 0c55b93f6..435d7eaf6 100644 --- a/test-tap/fixture/report/timeoutinmultiplefiles/b.cjs +++ b/test-tap/fixture/report/timeoutinmultiplefiles/b.js @@ -1,6 +1,6 @@ -const {setTimeout: delay} = require('node:timers/promises'); +import {setTimeout as delay} from 'node:timers/promises'; -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('b passes', t => t.pass()); diff --git a/test-tap/fixture/report/timeoutinsinglefile/a.cjs b/test-tap/fixture/report/timeoutinsinglefile/a.js similarity index 62% rename from test-tap/fixture/report/timeoutinsinglefile/a.cjs rename to test-tap/fixture/report/timeoutinsinglefile/a.js index b1fc9fe56..5bfa7d137 100644 --- a/test-tap/fixture/report/timeoutinsinglefile/a.cjs +++ b/test-tap/fixture/report/timeoutinsinglefile/a.js @@ -1,6 +1,6 @@ -const {setTimeout: delay} = require('node:timers/promises'); +import {setTimeout as delay} from 'node:timers/promises'; -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('passes', t => t.pass()); diff --git a/test-tap/fixture/report/timeoutwithmatch/a.cjs b/test-tap/fixture/report/timeoutwithmatch/a.js similarity index 70% rename from test-tap/fixture/report/timeoutwithmatch/a.cjs rename to test-tap/fixture/report/timeoutwithmatch/a.js index 21642a74c..fcfd49d4c 100644 --- a/test-tap/fixture/report/timeoutwithmatch/a.cjs +++ b/test-tap/fixture/report/timeoutwithmatch/a.js @@ -1,6 +1,6 @@ -const {setTimeout: delay} = require('node:timers/promises'); +import {setTimeout as delay} from 'node:timers/promises'; -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; test('passes needle', t => t.pass()); diff --git a/test-tap/fixture/report/watch/test.cjs b/test-tap/fixture/report/watch/test.cjs deleted file mode 100644 index 3da3b2d3e..000000000 --- a/test-tap/fixture/report/watch/test.cjs +++ /dev/null @@ -1,3 +0,0 @@ -const test = require('../../../../entrypoints/main.cjs'); - -test('passes', t => t.pass()); diff --git a/test-tap/fixture/report/watch/test.js b/test-tap/fixture/report/watch/test.js new file mode 100644 index 000000000..32c4bbc22 --- /dev/null +++ b/test-tap/fixture/report/watch/test.js @@ -0,0 +1,3 @@ +import test from '../../../../entrypoints/main.js'; + +test('passes', t => t.pass()); diff --git a/test-tap/fixture/reset-cache/test.cjs b/test-tap/fixture/reset-cache/test.cjs deleted file mode 100644 index b97019959..000000000 --- a/test-tap/fixture/reset-cache/test.cjs +++ /dev/null @@ -1,3 +0,0 @@ -const test = require('../../../entrypoints/main.cjs'); - -test('pass', t => t.pass()); diff --git a/test-tap/fixture/reset-cache/test.js b/test-tap/fixture/reset-cache/test.js new file mode 100644 index 000000000..90089c2d8 --- /dev/null +++ b/test-tap/fixture/reset-cache/test.js @@ -0,0 +1,3 @@ +import test from '../../../entrypoints/main.js'; + +test('pass', t => t.pass()); diff --git a/test-tap/fixture/serial.cjs b/test-tap/fixture/serial.js similarity index 69% rename from test-tap/fixture/serial.cjs rename to test-tap/fixture/serial.js index a54a73dd1..5e280780b 100644 --- a/test-tap/fixture/serial.cjs +++ b/test-tap/fixture/serial.js @@ -1,6 +1,6 @@ -const {setTimeout: delay} = require('node:timers/promises'); +import {setTimeout as delay} from 'node:timers/promises'; -const test = require('../../entrypoints/main.cjs'); +import test from '../../entrypoints/main.js'; const tests = []; diff --git a/test-tap/fixture/skip-only.cjs b/test-tap/fixture/skip-only.cjs deleted file mode 100644 index 6c6659ea6..000000000 --- a/test-tap/fixture/skip-only.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../entrypoints/main.cjs'); - -test.skip('test', t => { - t.fail(); -}); diff --git a/test-tap/fixture/skip-only.js b/test-tap/fixture/skip-only.js new file mode 100644 index 000000000..3c1947475 --- /dev/null +++ b/test-tap/fixture/skip-only.js @@ -0,0 +1,5 @@ +import test from '../../entrypoints/main.js'; + +test.skip('test', t => { + t.fail(); +}); diff --git a/test-tap/fixture/snapshots/test.cjs b/test-tap/fixture/snapshots/__tests__-dir/__tests__/test.js similarity index 72% rename from test-tap/fixture/snapshots/test.cjs rename to test-tap/fixture/snapshots/__tests__-dir/__tests__/test.js index e66cee105..cdb9504c5 100644 --- a/test-tap/fixture/snapshots/test.cjs +++ b/test-tap/fixture/snapshots/__tests__-dir/__tests__/test.js @@ -1,4 +1,4 @@ -const test = require('../../../entrypoints/main.cjs'); +import test from '../../../../../entrypoints/main.js'; test('test title', t => { t.snapshot({foo: 'bar'}); diff --git a/test-tap/fixture/snapshots/test-content/package.json b/test-tap/fixture/snapshots/test-content/package.json index 4b1c5e66f..631548f59 100644 --- a/test-tap/fixture/snapshots/test-content/package.json +++ b/test-tap/fixture/snapshots/test-content/package.json @@ -1,7 +1,7 @@ { "ava": { "files": [ - "tests/test.cjs" + "tests/test.js" ] } } diff --git a/test-tap/fixture/snapshots/test-content/test.cjs.md.expected b/test-tap/fixture/snapshots/test-content/test.js.md.expected similarity index 53% rename from test-tap/fixture/snapshots/test-content/test.cjs.md.expected rename to test-tap/fixture/snapshots/test-content/test.js.md.expected index c867d3fe6..677e9fc31 100644 --- a/test-tap/fixture/snapshots/test-content/test.cjs.md.expected +++ b/test-tap/fixture/snapshots/test-content/test.js.md.expected @@ -1,6 +1,6 @@ -# Snapshot report for `tests/test.cjs` +# Snapshot report for `tests/test.js` -The actual snapshot is saved in `test.cjs.snap`. +The actual snapshot is saved in `test.js.snap`. Generated by [AVA](https://avajs.dev). diff --git a/test-tap/fixture/snapshots/test-content/test.cjs.snap.expected b/test-tap/fixture/snapshots/test-content/test.js.snap.expected similarity index 100% rename from test-tap/fixture/snapshots/test-content/test.cjs.snap.expected rename to test-tap/fixture/snapshots/test-content/test.js.snap.expected diff --git a/test-tap/fixture/snapshots/test-content/tests/test.cjs b/test-tap/fixture/snapshots/test-content/tests/test.cjs deleted file mode 100644 index 76d89abec..000000000 --- a/test-tap/fixture/snapshots/test-content/tests/test.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../../../../entrypoints/main.cjs'); - -test('test title', t => { - t.snapshot({foo: 'bar'}); -}); diff --git a/test-tap/fixture/snapshots/test-content/tests/test.js b/test-tap/fixture/snapshots/test-content/tests/test.js new file mode 100644 index 000000000..0cb9cca6c --- /dev/null +++ b/test-tap/fixture/snapshots/test-content/tests/test.js @@ -0,0 +1,5 @@ +import test from '../../../../../entrypoints/main.js'; + +test('test title', t => { + t.snapshot({foo: 'bar'}); +}); diff --git a/test-tap/fixture/snapshots/test-dir/test/test.cjs b/test-tap/fixture/snapshots/test-dir/test/test.cjs deleted file mode 100644 index 27b2608f4..000000000 --- a/test-tap/fixture/snapshots/test-dir/test/test.cjs +++ /dev/null @@ -1,11 +0,0 @@ -const test = require('../../../../../entrypoints/main.cjs'); - -test('test title', t => { - t.snapshot({foo: 'bar'}); - - t.snapshot({answer: 42}); -}); - -test('another test', t => { - t.snapshot(new Map()); -}); diff --git a/test-tap/fixture/snapshots/watcher-rerun/test.cjs b/test-tap/fixture/snapshots/test-dir/test/test.js similarity index 71% rename from test-tap/fixture/snapshots/watcher-rerun/test.cjs rename to test-tap/fixture/snapshots/test-dir/test/test.js index 67414868b..cdb9504c5 100644 --- a/test-tap/fixture/snapshots/watcher-rerun/test.cjs +++ b/test-tap/fixture/snapshots/test-dir/test/test.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../../entrypoints/main.js'; test('test title', t => { t.snapshot({foo: 'bar'}); diff --git a/test-tap/fixture/snapshots/test-snapshot-location/package.json b/test-tap/fixture/snapshots/test-snapshot-location/package.json index 213c6f91c..1d09ac4fc 100644 --- a/test-tap/fixture/snapshots/test-snapshot-location/package.json +++ b/test-tap/fixture/snapshots/test-snapshot-location/package.json @@ -1,7 +1,7 @@ { "ava": { "files": [ - "src/**/*test.cjs" + "src/**/*test.js" ], "snapshotDir": "snapshot-fixtures" } diff --git a/test-tap/fixture/snapshots/test-snapshot-location/src/feature/nested-feature/test.cjs b/test-tap/fixture/snapshots/test-snapshot-location/src/feature/nested-feature/test.js similarity index 72% rename from test-tap/fixture/snapshots/test-snapshot-location/src/feature/nested-feature/test.cjs rename to test-tap/fixture/snapshots/test-snapshot-location/src/feature/nested-feature/test.js index 8289c51ef..0af0ff783 100644 --- a/test-tap/fixture/snapshots/test-snapshot-location/src/feature/nested-feature/test.cjs +++ b/test-tap/fixture/snapshots/test-snapshot-location/src/feature/nested-feature/test.js @@ -1,4 +1,4 @@ -const test = require('../../../../../../../entrypoints/main.cjs'); +import test from '../../../../../../../entrypoints/main.js'; test('test nested feature title', t => { t.snapshot({foo: 'bar'}); diff --git a/test-tap/fixture/snapshots/test-snapshot-location/src/feature/test.cjs b/test-tap/fixture/snapshots/test-snapshot-location/src/feature/test.js similarity index 71% rename from test-tap/fixture/snapshots/test-snapshot-location/src/feature/test.cjs rename to test-tap/fixture/snapshots/test-snapshot-location/src/feature/test.js index 5bfad39aa..f85c7b573 100644 --- a/test-tap/fixture/snapshots/test-snapshot-location/src/feature/test.cjs +++ b/test-tap/fixture/snapshots/test-snapshot-location/src/feature/test.js @@ -1,4 +1,4 @@ -const test = require('../../../../../../entrypoints/main.cjs'); +import test from '../../../../../../entrypoints/main.js'; test('test feature title', t => { t.snapshot({foo: 'bar'}); diff --git a/test-tap/fixture/snapshots/test-snapshot-location/src/test.cjs b/test-tap/fixture/snapshots/test-snapshot-location/src/test.js similarity index 70% rename from test-tap/fixture/snapshots/test-snapshot-location/src/test.cjs rename to test-tap/fixture/snapshots/test-snapshot-location/src/test.js index 27b2608f4..cdb9504c5 100644 --- a/test-tap/fixture/snapshots/test-snapshot-location/src/test.cjs +++ b/test-tap/fixture/snapshots/test-snapshot-location/src/test.js @@ -1,4 +1,4 @@ -const test = require('../../../../../entrypoints/main.cjs'); +import test from '../../../../../entrypoints/main.js'; test('test title', t => { t.snapshot({foo: 'bar'}); diff --git a/test-tap/fixture/snapshots/test-sourcemaps/build/feature/__tests__/test.cjs b/test-tap/fixture/snapshots/test-sourcemaps/build/feature/__tests__/test.js similarity index 62% rename from test-tap/fixture/snapshots/test-sourcemaps/build/feature/__tests__/test.cjs rename to test-tap/fixture/snapshots/test-sourcemaps/build/feature/__tests__/test.js index eb4c73961..0f98b680c 100644 --- a/test-tap/fixture/snapshots/test-sourcemaps/build/feature/__tests__/test.cjs +++ b/test-tap/fixture/snapshots/test-sourcemaps/build/feature/__tests__/test.js @@ -1,4 +1,4 @@ -const test = require('../../../../../../../entrypoints/main.cjs'); +import test from '../../../../../../../entrypoints/main.js'; test('feature test title', t => { t.snapshot({ foo: 'bar' }); t.snapshot({ answer: 40 }); @@ -6,4 +6,4 @@ test('feature test title', t => { test('another feature test', t => { t.snapshot(new Map()); }); -//# sourceMappingURL=test.cjs.map +//# sourceMappingURL=test.js.map diff --git a/test-tap/fixture/snapshots/test-sourcemaps/build/feature/__tests__/test.cjs.map b/test-tap/fixture/snapshots/test-sourcemaps/build/feature/__tests__/test.js.map similarity index 95% rename from test-tap/fixture/snapshots/test-sourcemaps/build/feature/__tests__/test.cjs.map rename to test-tap/fixture/snapshots/test-sourcemaps/build/feature/__tests__/test.js.map index b23f4c760..f0e1baefc 100644 --- a/test-tap/fixture/snapshots/test-sourcemaps/build/feature/__tests__/test.cjs.map +++ b/test-tap/fixture/snapshots/test-sourcemaps/build/feature/__tests__/test.js.map @@ -1,6 +1,6 @@ { "version": 3, - "file": "test.cjs", + "file": "test.js", "sourceRoot": "", "sources": [ "../../../src/feature/__tests__/test.ts" diff --git a/test-tap/fixture/snapshots/test-sourcemaps/build/test.cjs.map b/test-tap/fixture/snapshots/test-sourcemaps/build/test.cjs.map deleted file mode 100644 index 0d22b0298..000000000 --- a/test-tap/fixture/snapshots/test-sourcemaps/build/test.cjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"test.cjs","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,gBAAgB,CAAC;AAElC,IAAI,CAAC,sBAAsB,EAAE,CAAC;IAC7B,CAAC,CAAC,QAAQ,CAAC,EAAC,GAAG,EAAE,KAAK,EAAC,CAAC,CAAC;IAEzB,CAAC,CAAC,QAAQ,CAAC,EAAC,MAAM,EAAE,EAAE,EAAC,CAAC,CAAC;AAC1B,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,wBAAwB,EAAE,CAAC;IAC/B,CAAC,CAAC,QAAQ,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"} diff --git a/test-tap/fixture/snapshots/test-sourcemaps/build/test.cjs b/test-tap/fixture/snapshots/test-sourcemaps/build/test.js similarity index 64% rename from test-tap/fixture/snapshots/test-sourcemaps/build/test.cjs rename to test-tap/fixture/snapshots/test-sourcemaps/build/test.js index 1b021029a..bc592f8c4 100644 --- a/test-tap/fixture/snapshots/test-sourcemaps/build/test.cjs +++ b/test-tap/fixture/snapshots/test-sourcemaps/build/test.js @@ -1,4 +1,4 @@ -const test = require('../../../../../entrypoints/main.cjs'); +import test from '../../../../../entrypoints/main.js'; test('top level test title', t => { t.snapshot({ foo: 'bar' }); t.snapshot({ answer: 42 }); @@ -6,4 +6,4 @@ test('top level test title', t => { test('another top level test', t => { t.snapshot(new Map()); }); -//# sourceMappingURL=test.cjs.map +//# sourceMappingURL=test.js.map diff --git a/test-tap/fixture/snapshots/test-sourcemaps/build/test.js.map b/test-tap/fixture/snapshots/test-sourcemaps/build/test.js.map new file mode 100644 index 000000000..fcd767f59 --- /dev/null +++ b/test-tap/fixture/snapshots/test-sourcemaps/build/test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,gBAAgB,CAAC;AAElC,IAAI,CAAC,sBAAsB,EAAE,CAAC;IAC7B,CAAC,CAAC,QAAQ,CAAC,EAAC,GAAG,EAAE,KAAK,EAAC,CAAC,CAAC;IAEzB,CAAC,CAAC,QAAQ,CAAC,EAAC,MAAM,EAAE,EAAE,EAAC,CAAC,CAAC;AAC1B,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,wBAAwB,EAAE,CAAC;IAC/B,CAAC,CAAC,QAAQ,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"} diff --git a/test-tap/fixture/snapshots/test-sourcemaps/build/test/test.cjs b/test-tap/fixture/snapshots/test-sourcemaps/build/test/test.js similarity index 60% rename from test-tap/fixture/snapshots/test-sourcemaps/build/test/test.cjs rename to test-tap/fixture/snapshots/test-sourcemaps/build/test/test.js index 68d51ed13..9ee0f6901 100644 --- a/test-tap/fixture/snapshots/test-sourcemaps/build/test/test.cjs +++ b/test-tap/fixture/snapshots/test-sourcemaps/build/test/test.js @@ -1,4 +1,4 @@ -const test = require('../../../../../../entrypoints/main.cjs'); +import test from '../../../../../../entrypoints/main.js'; test('test title', t => { t.snapshot({ foo: 'bar' }); t.snapshot({ answer: 43 }); @@ -6,4 +6,4 @@ test('test title', t => { test('another test', t => { t.snapshot(new Map()); }); -//# sourceMappingURL=test.cjs.map +//# sourceMappingURL=test.js.map diff --git a/test-tap/fixture/snapshots/test-sourcemaps/build/test/test.cjs.map b/test-tap/fixture/snapshots/test-sourcemaps/build/test/test.js.map similarity index 95% rename from test-tap/fixture/snapshots/test-sourcemaps/build/test/test.cjs.map rename to test-tap/fixture/snapshots/test-sourcemaps/build/test/test.js.map index fb3e432db..cc1dee97c 100644 --- a/test-tap/fixture/snapshots/test-sourcemaps/build/test/test.cjs.map +++ b/test-tap/fixture/snapshots/test-sourcemaps/build/test/test.js.map @@ -1,6 +1,6 @@ { "version": 3, - "file": "test.cjs", + "file": "test.js", "sourceRoot": "", "sources": [ "../../src/test/test.ts" diff --git a/test-tap/fixture/snapshots/test-sourcemaps/package.json b/test-tap/fixture/snapshots/test-sourcemaps/package.json index 088edf495..56e413658 100644 --- a/test-tap/fixture/snapshots/test-sourcemaps/package.json +++ b/test-tap/fixture/snapshots/test-sourcemaps/package.json @@ -1,7 +1,7 @@ { "ava": { "files": [ - "build/**/test.cjs" + "build/**/test.js" ] } } diff --git a/test-tap/fixture/snapshots/test-sourcemaps/src/feature/__tests__/test.ts b/test-tap/fixture/snapshots/test-sourcemaps/src/feature/__tests__/test.ts index 859d3890d..002bd0075 100644 --- a/test-tap/fixture/snapshots/test-sourcemaps/src/feature/__tests__/test.ts +++ b/test-tap/fixture/snapshots/test-sourcemaps/src/feature/__tests__/test.ts @@ -1,4 +1,4 @@ -import test from '../../../../../../../entrypoints/main.cjs'; +import test from '../../../../../../../entrypoints/main.js'; test('feature test title', t => { t.snapshot({foo: 'bar'}); diff --git a/test-tap/fixture/snapshots/test-sourcemaps/src/test.ts b/test-tap/fixture/snapshots/test-sourcemaps/src/test.ts index 17d6155d1..b72aebe33 100644 --- a/test-tap/fixture/snapshots/test-sourcemaps/src/test.ts +++ b/test-tap/fixture/snapshots/test-sourcemaps/src/test.ts @@ -1,4 +1,4 @@ -import test from '../../../../../entrypoints/main.cjs'; +import test from '../../../../../entrypoints/main.js'; test('top level test title', t => { t.snapshot({foo: 'bar'}); diff --git a/test-tap/fixture/snapshots/test-sourcemaps/src/test/test.ts b/test-tap/fixture/snapshots/test-sourcemaps/src/test/test.ts index d265daf43..52352d9d3 100644 --- a/test-tap/fixture/snapshots/test-sourcemaps/src/test/test.ts +++ b/test-tap/fixture/snapshots/test-sourcemaps/src/test/test.ts @@ -1,4 +1,4 @@ -import test from '../../../../../../entrypoints/main.cjs'; +import test from '../../../../../../entrypoints/main.js'; test('test title', t => { t.snapshot({foo: 'bar'}); diff --git a/test-tap/fixture/snapshots/test-sourcemaps/tsconfig.json b/test-tap/fixture/snapshots/test-sourcemaps/tsconfig.json index 79639151e..24a56a7e8 100644 --- a/test-tap/fixture/snapshots/test-sourcemaps/tsconfig.json +++ b/test-tap/fixture/snapshots/test-sourcemaps/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "target": "es6", - "module": "commonjs", + "module": "es2022", "outDir": "build", "sourceMap": true, "strictNullChecks": true diff --git a/test-tap/fixture/snapshots/__tests__-dir/__tests__/test.cjs b/test-tap/fixture/snapshots/test.js similarity index 70% rename from test-tap/fixture/snapshots/__tests__-dir/__tests__/test.cjs rename to test-tap/fixture/snapshots/test.js index 27b2608f4..56392c076 100644 --- a/test-tap/fixture/snapshots/__tests__-dir/__tests__/test.cjs +++ b/test-tap/fixture/snapshots/test.js @@ -1,4 +1,4 @@ -const test = require('../../../../../entrypoints/main.cjs'); +import test from '../../../entrypoints/main.js'; test('test title', t => { t.snapshot({foo: 'bar'}); diff --git a/test-tap/fixture/snapshots/tests-dir/package.json b/test-tap/fixture/snapshots/tests-dir/package.json index b3747dcca..f3c62b6bf 100644 --- a/test-tap/fixture/snapshots/tests-dir/package.json +++ b/test-tap/fixture/snapshots/tests-dir/package.json @@ -1,7 +1,7 @@ { "ava": { "files": [ - "tests/**/*.cjs" + "tests/**/*.js" ] } } diff --git a/test-tap/fixture/snapshots/tests-dir/tests/test.cjs b/test-tap/fixture/snapshots/tests-dir/tests/test.cjs deleted file mode 100644 index 27b2608f4..000000000 --- a/test-tap/fixture/snapshots/tests-dir/tests/test.cjs +++ /dev/null @@ -1,11 +0,0 @@ -const test = require('../../../../../entrypoints/main.cjs'); - -test('test title', t => { - t.snapshot({foo: 'bar'}); - - t.snapshot({answer: 42}); -}); - -test('another test', t => { - t.snapshot(new Map()); -}); diff --git a/test-tap/fixture/snapshots/tests-dir/tests/test.js b/test-tap/fixture/snapshots/tests-dir/tests/test.js new file mode 100644 index 000000000..cdb9504c5 --- /dev/null +++ b/test-tap/fixture/snapshots/tests-dir/tests/test.js @@ -0,0 +1,11 @@ +import test from '../../../../../entrypoints/main.js'; + +test('test title', t => { + t.snapshot({foo: 'bar'}); + + t.snapshot({answer: 42}); +}); + +test('another test', t => { + t.snapshot(new Map()); +}); diff --git a/test-tap/fixture/snapshots/watcher-rerun-unlink/test.cjs b/test-tap/fixture/snapshots/watcher-rerun-unlink/test.js similarity index 83% rename from test-tap/fixture/snapshots/watcher-rerun-unlink/test.cjs rename to test-tap/fixture/snapshots/watcher-rerun-unlink/test.js index cf144058c..594304e1d 100644 --- a/test-tap/fixture/snapshots/watcher-rerun-unlink/test.cjs +++ b/test-tap/fixture/snapshots/watcher-rerun-unlink/test.js @@ -1,4 +1,4 @@ -const test = require('../../../../entrypoints/main.cjs'); +import test from '../../../../entrypoints/main.js'; if (process.env.TEMPLATE) { test('test title', t => { diff --git a/test-tap/fixture/snapshots/watcher-rerun/test.js b/test-tap/fixture/snapshots/watcher-rerun/test.js new file mode 100644 index 000000000..9aede5eb5 --- /dev/null +++ b/test-tap/fixture/snapshots/watcher-rerun/test.js @@ -0,0 +1,11 @@ +import test from '../../../../entrypoints/main.js'; + +test('test title', t => { + t.snapshot({foo: 'bar'}); + + t.snapshot({answer: 42}); +}); + +test('another test', t => { + t.snapshot(new Map()); +}); diff --git a/test-tap/fixture/sort-tests/0.cjs b/test-tap/fixture/sort-tests/0.cjs deleted file mode 100644 index 1af77b598..000000000 --- a/test-tap/fixture/sort-tests/0.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../../entrypoints/main.cjs'); - -test('should run third', t => { - t.pass(); -}); diff --git a/test-tap/fixture/sort-tests/0.js b/test-tap/fixture/sort-tests/0.js new file mode 100644 index 000000000..84f657c56 --- /dev/null +++ b/test-tap/fixture/sort-tests/0.js @@ -0,0 +1,5 @@ +import test from '../../../entrypoints/main.js'; + +test('should run third', t => { + t.pass(); +}); diff --git a/test-tap/fixture/sort-tests/1.cjs b/test-tap/fixture/sort-tests/1.cjs deleted file mode 100644 index e1e0ff47b..000000000 --- a/test-tap/fixture/sort-tests/1.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../../entrypoints/main.cjs'); - -test('should run second', t => { - t.pass(); -}); diff --git a/test-tap/fixture/sort-tests/1.js b/test-tap/fixture/sort-tests/1.js new file mode 100644 index 000000000..503fe92e0 --- /dev/null +++ b/test-tap/fixture/sort-tests/1.js @@ -0,0 +1,5 @@ +import test from '../../../entrypoints/main.js'; + +test('should run second', t => { + t.pass(); +}); diff --git a/test-tap/fixture/sort-tests/2.cjs b/test-tap/fixture/sort-tests/2.cjs deleted file mode 100644 index 9ad7df09f..000000000 --- a/test-tap/fixture/sort-tests/2.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../../entrypoints/main.cjs'); - -test('should run first', t => { - t.pass(); -}); diff --git a/test-tap/fixture/sort-tests/2.js b/test-tap/fixture/sort-tests/2.js new file mode 100644 index 000000000..7226c73eb --- /dev/null +++ b/test-tap/fixture/sort-tests/2.js @@ -0,0 +1,5 @@ +import test from '../../../entrypoints/main.js'; + +test('should run first', t => { + t.pass(); +}); diff --git a/test-tap/fixture/sort-tests/ava.config.js b/test-tap/fixture/sort-tests/ava.config.js index 58d098288..813cd4294 100644 --- a/test-tap/fixture/sort-tests/ava.config.js +++ b/test-tap/fixture/sort-tests/ava.config.js @@ -1,5 +1,5 @@ export default { - files: ['*.cjs'], + files: ['[0-9]*.js'], // Descending order sortTestFiles: (a, b) => b.localeCompare(a, [], {numeric: true}), concurrency: 1, diff --git a/test-tap/fixture/stalled-tests/observable.cjs b/test-tap/fixture/stalled-tests/observable.cjs deleted file mode 100644 index 3e6f149d7..000000000 --- a/test-tap/fixture/stalled-tests/observable.cjs +++ /dev/null @@ -1,7 +0,0 @@ -const Observable = require('zen-observable'); - -const test = require('../../../entrypoints/main.cjs'); - -test('test', t => new Observable(() => { - t.pass(); -})); diff --git a/test-tap/fixture/stalled-tests/observable.js b/test-tap/fixture/stalled-tests/observable.js new file mode 100644 index 000000000..5831291f7 --- /dev/null +++ b/test-tap/fixture/stalled-tests/observable.js @@ -0,0 +1,7 @@ +import Observable from 'zen-observable'; + +import test from '../../../entrypoints/main.js'; + +test('test', t => new Observable(() => { + t.pass(); +})); diff --git a/test-tap/fixture/stalled-tests/promise.cjs b/test-tap/fixture/stalled-tests/promise.js similarity index 50% rename from test-tap/fixture/stalled-tests/promise.cjs rename to test-tap/fixture/stalled-tests/promise.js index 4809486a5..63f6ad732 100644 --- a/test-tap/fixture/stalled-tests/promise.cjs +++ b/test-tap/fixture/stalled-tests/promise.js @@ -1,4 +1,4 @@ -const test = require('../../../entrypoints/main.cjs'); +import test from '../../../entrypoints/main.js'; test('test', t => new Promise(() => { t.pass(); diff --git a/test-tap/fixture/symlinkdir/symlink.cjs b/test-tap/fixture/symlinkdir/symlink.cjs deleted file mode 100644 index d9c09eae3..000000000 --- a/test-tap/fixture/symlinkdir/symlink.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../../entrypoints/main.cjs'); - -test('test', t => { - t.pass(); -}); diff --git a/test-tap/fixture/symlinkdir/symlink.js b/test-tap/fixture/symlinkdir/symlink.js new file mode 100644 index 000000000..7bb179e98 --- /dev/null +++ b/test-tap/fixture/symlinkdir/symlink.js @@ -0,0 +1,5 @@ +import test from '../../../entrypoints/main.js'; + +test('test', t => { + t.pass(); +}); diff --git a/test-tap/fixture/symlinkfile.cjs b/test-tap/fixture/symlinkfile.cjs deleted file mode 120000 index eb469079c..000000000 --- a/test-tap/fixture/symlinkfile.cjs +++ /dev/null @@ -1 +0,0 @@ -target-symlink.cjs \ No newline at end of file diff --git a/test-tap/fixture/symlinkfile.js b/test-tap/fixture/symlinkfile.js new file mode 120000 index 000000000..fe40077d6 --- /dev/null +++ b/test-tap/fixture/symlinkfile.js @@ -0,0 +1 @@ +target-symlink.js \ No newline at end of file diff --git a/test-tap/fixture/tap/test.cjs b/test-tap/fixture/tap/test.cjs deleted file mode 100644 index c4bdb1447..000000000 --- a/test-tap/fixture/tap/test.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../../entrypoints/main.cjs'); - -test('works', t => { - t.pass(); -}); diff --git a/test-tap/fixture/tap/test.js b/test-tap/fixture/tap/test.js new file mode 100644 index 000000000..4f3f9d9e2 --- /dev/null +++ b/test-tap/fixture/tap/test.js @@ -0,0 +1,5 @@ +import test from '../../../entrypoints/main.js'; + +test('works', t => { + t.pass(); +}); diff --git a/test-tap/fixture/target-symlink.cjs b/test-tap/fixture/target-symlink.cjs deleted file mode 100644 index b499209db..000000000 --- a/test-tap/fixture/target-symlink.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../entrypoints/main.cjs'); - -test('test', t => { - t.pass(); -}); diff --git a/test-tap/fixture/target-symlink.js b/test-tap/fixture/target-symlink.js new file mode 100644 index 000000000..0c7f2e2ee --- /dev/null +++ b/test-tap/fixture/target-symlink.js @@ -0,0 +1,5 @@ +import test from '../../entrypoints/main.js'; + +test('test', t => { + t.pass(); +}); diff --git a/test-tap/fixture/test-count-2.cjs b/test-tap/fixture/test-count-2.js similarity index 74% rename from test-tap/fixture/test-count-2.cjs rename to test-tap/fixture/test-count-2.js index c38b9b1fa..9459f7843 100644 --- a/test-tap/fixture/test-count-2.cjs +++ b/test-tap/fixture/test-count-2.js @@ -1,4 +1,4 @@ -const test = require('../../entrypoints/main.cjs'); +import test from '../../entrypoints/main.js'; test('passCount', t => { t.pass(); diff --git a/test-tap/fixture/test-count-3.cjs b/test-tap/fixture/test-count-3.js similarity index 78% rename from test-tap/fixture/test-count-3.cjs rename to test-tap/fixture/test-count-3.js index 6cfd0a54d..ecfcf9f86 100644 --- a/test-tap/fixture/test-count-3.cjs +++ b/test-tap/fixture/test-count-3.js @@ -1,4 +1,4 @@ -const test = require('../../entrypoints/main.cjs'); +import test from '../../entrypoints/main.js'; test('passCount', t => { t.pass(); diff --git a/test-tap/fixture/test-count.cjs b/test-tap/fixture/test-count.js similarity index 74% rename from test-tap/fixture/test-count.cjs rename to test-tap/fixture/test-count.js index c38b9b1fa..9459f7843 100644 --- a/test-tap/fixture/test-count.cjs +++ b/test-tap/fixture/test-count.js @@ -1,4 +1,4 @@ -const test = require('../../entrypoints/main.cjs'); +import test from '../../entrypoints/main.js'; test('passCount', t => { t.pass(); diff --git a/test-tap/fixture/try-snapshot.cjs.md b/test-tap/fixture/try-snapshot.js.md similarity index 75% rename from test-tap/fixture/try-snapshot.cjs.md rename to test-tap/fixture/try-snapshot.js.md index 9098f82d2..2ceb2c743 100644 --- a/test-tap/fixture/try-snapshot.cjs.md +++ b/test-tap/fixture/try-snapshot.js.md @@ -1,6 +1,6 @@ -# Snapshot report for `try-snapshot.cjs` +# Snapshot report for `try-snapshot.js` -The actual snapshot is saved in `try-snapshot.cjs.snap`. +The actual snapshot is saved in `try-snapshot.js.snap`. Generated by [AVA](https://avajs.dev). diff --git a/test-tap/fixture/try-snapshot.cjs.snap b/test-tap/fixture/try-snapshot.js.snap similarity index 100% rename from test-tap/fixture/try-snapshot.cjs.snap rename to test-tap/fixture/try-snapshot.js.snap diff --git a/test-tap/fixture/with-dependencies/no-tests.cjs b/test-tap/fixture/with-dependencies/no-tests.cjs deleted file mode 100644 index d01c1b480..000000000 --- a/test-tap/fixture/with-dependencies/no-tests.cjs +++ /dev/null @@ -1,3 +0,0 @@ -require('./dep-1.js'); // eslint-disable-line import-x/no-unassigned-import -require('./dep-2.js'); // eslint-disable-line import-x/no-unassigned-import -require('./dep-3.custom'); // eslint-disable-line import-x/no-unassigned-import diff --git a/test-tap/fixture/with-dependencies/no-tests.js b/test-tap/fixture/with-dependencies/no-tests.js new file mode 100644 index 000000000..1731db22a --- /dev/null +++ b/test-tap/fixture/with-dependencies/no-tests.js @@ -0,0 +1,3 @@ +import './dep-1.js'; // eslint-disable-line import-x/no-unassigned-import +import './dep-2.js'; // eslint-disable-line import-x/no-unassigned-import +import './dep-3.custom'; // eslint-disable-line import-x/no-unassigned-import diff --git a/test-tap/fixture/with-dependencies/require-custom.cjs b/test-tap/fixture/with-dependencies/require-custom.cjs deleted file mode 100644 index 6a46d7edb..000000000 --- a/test-tap/fixture/with-dependencies/require-custom.cjs +++ /dev/null @@ -1,2 +0,0 @@ -/* eslint-disable n/no-deprecated-api */ -require.extensions['.custom'] = require.extensions['.js']; diff --git a/test-tap/fixture/with-dependencies/test-failure.cjs b/test-tap/fixture/with-dependencies/test-failure.cjs deleted file mode 100644 index 921f55996..000000000 --- a/test-tap/fixture/with-dependencies/test-failure.cjs +++ /dev/null @@ -1,9 +0,0 @@ -const test = require('../../../entrypoints/main.cjs'); - -require('./dep-1.js'); // eslint-disable-line import-x/no-unassigned-import -require('./dep-2.js'); // eslint-disable-line import-x/no-unassigned-import -require('./dep-3.custom'); // eslint-disable-line import-x/no-unassigned-import - -test('hey ho', t => { - t.fail(); -}); diff --git a/test-tap/fixture/with-dependencies/test-failure.js b/test-tap/fixture/with-dependencies/test-failure.js new file mode 100644 index 000000000..3a9243324 --- /dev/null +++ b/test-tap/fixture/with-dependencies/test-failure.js @@ -0,0 +1,9 @@ +import test from '../../../entrypoints/main.js'; + +import './dep-1.js'; // eslint-disable-line import-x/no-unassigned-import +import './dep-2.js'; // eslint-disable-line import-x/no-unassigned-import +import './dep-3.custom'; // eslint-disable-line import-x/no-unassigned-import + +test('hey ho', t => { + t.fail(); +}); diff --git a/test-tap/fixture/with-dependencies/test-uncaught-exception.cjs b/test-tap/fixture/with-dependencies/test-uncaught-exception.cjs deleted file mode 100644 index 7b38960cf..000000000 --- a/test-tap/fixture/with-dependencies/test-uncaught-exception.cjs +++ /dev/null @@ -1,13 +0,0 @@ -const test = require('../../../entrypoints/main.cjs'); - -require('./dep-1.js'); // eslint-disable-line import-x/no-unassigned-import -require('./dep-2.js'); // eslint-disable-line import-x/no-unassigned-import -require('./dep-3.custom'); // eslint-disable-line import-x/no-unassigned-import - -test('hey ho', t => { - t.pass(); -}); - -setImmediate(() => { - throw new Error('oops'); -}); diff --git a/test-tap/fixture/with-dependencies/test-uncaught-exception.js b/test-tap/fixture/with-dependencies/test-uncaught-exception.js new file mode 100644 index 000000000..b040fa1ea --- /dev/null +++ b/test-tap/fixture/with-dependencies/test-uncaught-exception.js @@ -0,0 +1,13 @@ +import test from '../../../entrypoints/main.js'; + +import './dep-1.js'; // eslint-disable-line import-x/no-unassigned-import +import './dep-2.js'; // eslint-disable-line import-x/no-unassigned-import +import './dep-3.custom'; // eslint-disable-line import-x/no-unassigned-import + +test('hey ho', t => { + t.pass(); +}); + +setImmediate(() => { + throw new Error('oops'); +}); diff --git a/test-tap/fixture/with-dependencies/test.cjs b/test-tap/fixture/with-dependencies/test.cjs deleted file mode 100644 index deec33241..000000000 --- a/test-tap/fixture/with-dependencies/test.cjs +++ /dev/null @@ -1,9 +0,0 @@ -const test = require('../../../entrypoints/main.cjs'); - -require('./dep-1.js'); // eslint-disable-line import-x/no-unassigned-import -require('./dep-2.js'); // eslint-disable-line import-x/no-unassigned-import -require('./dep-3.custom'); // eslint-disable-line import-x/no-unassigned-import - -test('hey ho', t => { - t.pass(); -}); diff --git a/test-tap/fixture/with-dependencies/test.js b/test-tap/fixture/with-dependencies/test.js new file mode 100644 index 000000000..dc822a89e --- /dev/null +++ b/test-tap/fixture/with-dependencies/test.js @@ -0,0 +1,9 @@ +import test from '../../../entrypoints/main.js'; + +import './dep-1.js'; // eslint-disable-line import-x/no-unassigned-import +import './dep-2.js'; // eslint-disable-line import-x/no-unassigned-import +import './dep-3.custom'; // eslint-disable-line import-x/no-unassigned-import + +test('hey ho', t => { + t.pass(); +}); diff --git a/test-tap/fixture/worker-argv.cjs b/test-tap/fixture/worker-argv.cjs deleted file mode 100644 index 5f875da28..000000000 --- a/test-tap/fixture/worker-argv.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('../../entrypoints/main.cjs'); - -test('argv', t => { - t.deepEqual(process.argv, [process.execPath, require.resolve('../../lib/worker/base'), '--hello', 'world']); -}); diff --git a/test-tap/fixture/worker-argv.js b/test-tap/fixture/worker-argv.js new file mode 100644 index 000000000..6aa28867b --- /dev/null +++ b/test-tap/fixture/worker-argv.js @@ -0,0 +1,7 @@ +import {fileURLToPath} from 'node:url'; + +import test from '../../entrypoints/main.js'; + +test('argv', t => { + t.deepEqual(process.argv, [process.execPath, fileURLToPath(import.meta.resolve('../../lib/worker/base.js')), '--hello', 'world']); +}); diff --git a/test-tap/globs.js b/test-tap/globs.js index cd14118d6..4e7187324 100644 --- a/test-tap/globs.js +++ b/test-tap/globs.js @@ -201,39 +201,39 @@ test('isTest after provider modifications', t => { t.end(); }); -test('findFiles finds non-ignored files (just .cjs)', async t => { +test('findFiles finds non-ignored files (just .js)', async t => { const fixtureDir = fixture('default-patterns'); process.chdir(fixtureDir); const expected = [ - 'sub/directory/__tests__/_foo.cjs', - 'sub/directory/__tests__/foo.cjs', - 'sub/directory/bar.spec.cjs', - 'sub/directory/bar.test.cjs', - 'test-foo.cjs', - 'test.cjs', - 'test/_foo-help.cjs', - 'test/baz.cjs', - 'test/deep/deep.cjs', - 'tests/baz.cjs', - 'tests/deep/deep.cjs', - 'tests/_foo-help.cjs', + 'sub/directory/__tests__/_foo.js', + 'sub/directory/__tests__/foo.js', + 'sub/directory/bar.spec.js', + 'sub/directory/bar.test.js', + 'test-foo.js', + 'test.js', + 'test/_foo-help.js', + 'test/baz.js', + 'test/deep/deep.js', + 'tests/baz.js', + 'tests/deep/deep.js', + 'tests/_foo-help.js', ].map(file => path.join(fixtureDir, file)).toSorted(); const actual = await globs.findFiles({ cwd: fixtureDir, - ...globs.normalizeGlobs({files: ['!**/fixtures/*.*', '!**/helpers/*.*'], extensions: ['cjs'], providers: []}), + ...globs.normalizeGlobs({files: ['!**/fixtures/*.*', '!**/helpers/*.*'], extensions: ['js'], providers: []}), }); actual.sort(); t.same(actual, expected); }); -test('findFiles finds non-ignored files (.cjs, .jsx)', async t => { +test('findFiles finds non-ignored files (.js, .jsx)', async t => { const fixtureDir = fixture('custom-extension'); process.chdir(fixtureDir); const expected = [ - 'test/do-not-compile.cjs', + 'test/do-not-compile.js', 'test/foo.jsx', 'test/sub/_helper.jsx', 'test/sub/bar.jsx', @@ -241,7 +241,7 @@ test('findFiles finds non-ignored files (.cjs, .jsx)', async t => { const actual = await globs.findFiles({ cwd: fixtureDir, - ...globs.normalizeGlobs({files: ['!**/fixtures/*', '!**/helpers/*'], extensions: ['cjs', 'jsx'], providers: []}), + ...globs.normalizeGlobs({files: ['!**/fixtures/*', '!**/helpers/*'], extensions: ['js', 'jsx'], providers: []}), }); actual.sort(); t.same(actual, expected); diff --git a/test-tap/helper/cli.js b/test-tap/helper/cli.js index 45d439cf7..c76c4fb07 100644 --- a/test-tap/helper/cli.js +++ b/test-tap/helper/cli.js @@ -3,7 +3,7 @@ import path from 'node:path'; import {fileURLToPath} from 'node:url'; const __dirname = fileURLToPath(new URL('.', import.meta.url)); -const cliPath = fileURLToPath(new URL('../../entrypoints/cli.mjs', import.meta.url)); +const cliPath = fileURLToPath(new URL('../../entrypoints/cli.js', import.meta.url)); export function execCli(args, options, cb) { let dirname; diff --git a/test-tap/helper/report.js b/test-tap/helper/report.js index e39ec51da..b22e591eb 100644 --- a/test-tap/helper/report.js +++ b/test-tap/helper/report.js @@ -7,7 +7,8 @@ import {globbySync} from 'globby'; import Api from '../../lib/api.js'; import {_testOnlyReplaceWorkerPath} from '../../lib/fork.js'; import {normalizeGlobs} from '../../lib/globs.js'; -import pkg from '../../lib/pkg.cjs'; +import normalizeModuleTypes from '../../lib/module-types.js'; +import pkg from '../../lib/pkg.js'; _testOnlyReplaceWorkerPath(new URL('report-worker.js', import.meta.url)); @@ -60,7 +61,7 @@ const run = async (type, reporter, {match = [], filter} = {}) => { const providers = []; const options = { - extensions: ['cjs'], + extensions: ['js'], failFast: type === 'failFast' || type === 'failFast2', failWithoutAssertions: false, serial: type === 'failFast' || type === 'failFast2', @@ -68,6 +69,7 @@ const run = async (type, reporter, {match = [], filter} = {}) => { cacheEnabled: false, experiments: {}, match, + nodeArguments: [], providers, projectDir, timeout: type.startsWith('timeout') ? '2.5s' : undefined, @@ -76,17 +78,18 @@ const run = async (type, reporter, {match = [], filter} = {}) => { snapshotDir: false, chalkOptions: {level: 1}, workerThreads: false, - env: { + environmentVariables: { NODE_NO_WARNINGS: '1', }, }; - options.globs = normalizeGlobs({extensions: options.extensions, files: ['*'], providers: []}); + options.moduleTypes = normalizeModuleTypes(options.extensions, 'module'); + options.globs = normalizeGlobs({extensions: options.extensions, files: ['*'], providers}); const api = new Api(options); api.on('run', ({data: plan}) => reporter.startRun(plan)); - const files = globbySync('*.cjs', { + const files = globbySync('*.js', { absolute: true, brace: true, case: false, @@ -132,7 +135,7 @@ exports.watch = reporter => run('watch', reporter); exports.edgeCases = reporter => run('edgeCases', reporter, { filter: [ {pattern: '**/*'}, - {pattern: '**/test.cjs', lineNumbers: [2]}, - {pattern: '**/ast-syntax-error.cjs', lineNumbers: [7]}, + {pattern: '**/test.js', lineNumbers: [2]}, + {pattern: '**/ast-syntax-error.js', lineNumbers: [7]}, ], }); diff --git a/test-tap/hooks.js b/test-tap/hooks.js index c54768069..f7de490d5 100644 --- a/test-tap/hooks.js +++ b/test-tap/hooks.js @@ -1,7 +1,7 @@ import {test} from 'tap'; import Runner from '../lib/runner.js'; -import {set as setOptions} from '../lib/worker/options.cjs'; +import {set as setOptions} from '../lib/worker/options.js'; setOptions({}); diff --git a/test-tap/integration/assorted.js b/test-tap/integration/assorted.js index 91cefff66..00c5c868c 100644 --- a/test-tap/integration/assorted.js +++ b/test-tap/integration/assorted.js @@ -12,17 +12,15 @@ import {execCli} from '../helper/cli.js'; const __dirname = fileURLToPath(new URL('.', import.meta.url)); test('timeout', {skip: ciInfo.isCI}, t => { - execCli(['long-running.cjs', '-T', '1s'], (error, stdout) => { + execCli(['long-running.js', '-T', '1s'], (error, stdout) => { t.ok(error); - t.match(stdout, 'helpful log of a pending test'); t.match(stdout, /Timed out/); t.end(); }); }); test('interrupt', {skip: ciInfo.isCI}, t => { - const proc = execCli(['long-running.cjs'], (_, stdout) => { - t.match(stdout, 'helpful log of a pending test'); + const proc = execCli(['long-running.js'], (_, stdout) => { t.match(stdout, /SIGINT/); t.end(); }); @@ -33,15 +31,15 @@ test('interrupt', {skip: ciInfo.isCI}, t => { }); test('include anonymous functions in error reports', t => { - execCli('error-in-anonymous-function.cjs', (error, stdout) => { + execCli('error-in-anonymous-function.js', (error, stdout) => { t.ok(error); - t.match(stdout, /error-in-anonymous-function\.cjs:4:8/); + t.match(stdout, /error-in-anonymous-function\.js:4:8/); t.end(); }); }); test('--match works', t => { - execCli(['-m=foo', '-m=bar', '-m=!baz', '-m=t* a* f*', '-m=!t* a* n* f*', 'matcher-skip.cjs'], error => { + execCli(['-m=foo', '-m=bar', '-m=!baz', '-m=t* a* f*', '-m=!t* a* n* f*', 'matcher-skip.js'], error => { t.error(error); t.end(); }); @@ -49,7 +47,7 @@ test('--match works', t => { for (const tapFlag of ['--tap', '-t']) { test(`${tapFlag} should produce TAP output`, t => { - execCli([tapFlag, 'test.cjs'], {dirname: 'fixture/tap'}, error => { + execCli([tapFlag, 'test.js'], {dirname: 'fixture/tap'}, error => { t.ok(!error); t.end(); }); @@ -65,7 +63,7 @@ test('works when no files are found', t => { }); test('should warn ava is required without the cli', t => { - childProcess.execFile(process.execPath, [path.resolve(__dirname, '../../entrypoints/main.cjs')], error => { + childProcess.execFile(process.execPath, [path.resolve(__dirname, '../../entrypoints/main.js')], error => { t.ok(error); t.match(error.message, /Test files must be run with the AVA CLI/); t.end(); @@ -80,7 +78,7 @@ test('tests without assertions do not fail if failWithoutAssertions option is se }); test('--no-color disables formatting colors', t => { - execCli(['--no-color', 'formatting-color.cjs'], (error, stdout) => { + execCli(['--no-color', 'formatting-color.js'], (error, stdout) => { t.ok(error); t.equal(stripVTControlCharacters(stdout), stdout); t.end(); @@ -88,7 +86,7 @@ test('--no-color disables formatting colors', t => { }); test('--color enables formatting colors', t => { - execCli(['--color', 'formatting-color.cjs'], (error, stdout) => { + execCli(['--color', 'formatting-color.js'], (error, stdout) => { t.ok(error); t.not(stripVTControlCharacters(stdout), stdout); t.end(); @@ -96,7 +94,7 @@ test('--color enables formatting colors', t => { }); test('sets NODE_ENV to test when it is not set', t => { - execCli('node-env-test.cjs', {env: {}}, (error, stdout) => { + execCli('node-env-test.js', {env: {}}, (error, stdout) => { t.error(error); t.match(stdout, /1 test passed/); t.end(); @@ -104,7 +102,7 @@ test('sets NODE_ENV to test when it is not set', t => { }); test('doesn’t set NODE_ENV when it is set', t => { - execCli('node-env-foo.cjs', {env: {NODE_ENV: 'foo'}}, (error, stdout) => { + execCli('node-env-foo.js', {env: {NODE_ENV: 'foo'}}, (error, stdout) => { t.error(error); t.match(stdout, /1 test passed/); t.end(); @@ -112,7 +110,7 @@ test('doesn’t set NODE_ENV when it is set', t => { }); test('additional arguments are forwarded to the worker', t => { - execCli(['worker-argv.cjs', '--serial', '--', '--hello', 'world'], error => { + execCli(['worker-argv.js', '--serial', '--', '--hello', 'world'], error => { t.error(error); t.end(); }); @@ -131,8 +129,8 @@ test('reset-cache resets cache', t => { }); }); -test('selects .cjs test files', t => { - execCli('cjs.cjs', (error, stdout) => { +test('selects .js test files', t => { + execCli('js.js', (error, stdout) => { t.error(error); t.match(stdout, /1 test passed/); t.end(); diff --git a/test-tap/integration/debug.js b/test-tap/integration/debug.js index 0395249d0..fa412fae8 100644 --- a/test-tap/integration/debug.js +++ b/test-tap/integration/debug.js @@ -3,7 +3,7 @@ import {test} from 'tap'; import {execCli} from '../helper/cli.js'; test('bails when using --watch while while debugging', t => { - execCli(['debug', '--watch', 'test.cjs'], {dirname: 'fixture/tap', env: {AVA_FORCE_CI: 'not-ci'}}, (error, stdout, stderr) => { + execCli(['debug', '--watch', 'test.js'], {dirname: 'fixture/tap', env: {AVA_FORCE_CI: 'not-ci'}}, (error, stdout, stderr) => { t.equal(error.code, 1); t.match(stderr, 'Watch mode is not available when debugging.'); t.end(); @@ -11,7 +11,7 @@ test('bails when using --watch while while debugging', t => { }); test('bails when debugging in CI', t => { - execCli(['debug', 'test.cjs'], {dirname: 'fixture/tap', env: {AVA_FORCE_CI: 'ci'}}, (error, stdout, stderr) => { + execCli(['debug', 'test.js'], {dirname: 'fixture/tap', env: {AVA_FORCE_CI: 'ci'}}, (error, stdout, stderr) => { t.equal(error.code, 1); t.match(stderr, 'Debugging is not available in CI.'); t.end(); @@ -19,7 +19,7 @@ test('bails when debugging in CI', t => { }); test('bails when --tap reporter is used while debugging', t => { - execCli(['debug', '--tap', 'test.cjs'], {dirname: 'fixture/tap', env: {AVA_FORCE_CI: 'not-ci'}}, (error, stdout, stderr) => { + execCli(['debug', '--tap', 'test.js'], {dirname: 'fixture/tap', env: {AVA_FORCE_CI: 'not-ci'}}, (error, stdout, stderr) => { t.equal(error.code, 1); t.match(stderr, 'The TAP reporter is not available when debugging.'); t.end(); diff --git a/test-tap/integration/repl.js b/test-tap/integration/repl.js index 5039229b9..08f898d30 100644 --- a/test-tap/integration/repl.js +++ b/test-tap/integration/repl.js @@ -2,5 +2,5 @@ import {execa} from 'execa'; import {test} from 'tap'; test('Throws error when required from the REPL', t => execa('node', ['-r', 'ava'], {reject: false}).then(result => { - t.match(result.stderr, 'The ’ava’ module can only be imported in test files'); + t.match(result.stderr, 'The ‘ava’ module can only be imported in test files'); })); diff --git a/test-tap/integration/snapshots.js b/test-tap/integration/snapshots.js index 36461129b..ab4198de1 100644 --- a/test-tap/integration/snapshots.js +++ b/test-tap/integration/snapshots.js @@ -20,7 +20,7 @@ for (const object of [ {type: 'tests', rel: 'tests-dir', dir: 'tests/snapshots'}, ]) { test(`snapshots work (${object.type})`, t => { - const snapPath = path.join(__dirname, '..', 'fixture', 'snapshots', object.rel, object.dir, 'test.cjs.snap'); + const snapPath = path.join(__dirname, '..', 'fixture', 'snapshots', object.rel, object.dir, 'test.js.snap'); try { fs.unlinkSync(snapPath); } catch (error) { @@ -45,23 +45,23 @@ for (const object of [ } test('appends to existing snapshots', t => { - const cliPath = fileURLToPath(new URL('../../entrypoints/cli.mjs', import.meta.url)); - const avaPath = fileURLToPath(new URL('../../entrypoints/main.cjs', import.meta.url)); + const cliPath = fileURLToPath(new URL('../../entrypoints/cli.js', import.meta.url)); + const avaPath = new URL('../../entrypoints/main.js', import.meta.url).toString(); const cwd = temporaryDirectory(); fs.writeFileSync(path.join(cwd, 'package.json'), '{}'); - const initial = `const test = require(${JSON.stringify(avaPath)}) + const initial = `const {default: test} = await import(${JSON.stringify(avaPath)}) test('one', t => { t.snapshot({one: true}) })`; - fs.writeFileSync(path.join(cwd, 'test.cjs'), initial); + fs.writeFileSync(path.join(cwd, 'test.js'), initial); const run = () => execa(process.execPath, [cliPath, '--no-color'], {cwd, env: {AVA_FORCE_CI: 'not-ci'}, reject: false}); return run().then(result => { t.match(result.stdout, /1 test passed/); - fs.writeFileSync(path.join(cwd, 'test.cjs'), `${initial} + fs.writeFileSync(path.join(cwd, 'test.js'), `${initial} test('two', t => { t.snapshot({two: true}) })`); @@ -69,7 +69,7 @@ test('two', t => { }).then(result => { t.match(result.stdout, /2 tests passed/); - fs.writeFileSync(path.join(cwd, 'test.cjs'), `${initial} + fs.writeFileSync(path.join(cwd, 'test.js'), `${initial} test('two', t => { t.snapshot({two: false}) })`); @@ -81,10 +81,10 @@ test('two', t => { }); test('outdated snapshot version is reported to the console', t => { - const snapPath = path.join(__dirname, '..', 'fixture', 'snapshots', 'test.cjs.snap'); + const snapPath = path.join(__dirname, '..', 'fixture', 'snapshots', 'test.js.snap'); fs.writeFileSync(snapPath, Buffer.from([0x0A, 0x00, 0x00])); - execCli(['test.cjs'], {dirname: 'fixture/snapshots'}, (error, stdout) => { + execCli(['test.js'], {dirname: 'fixture/snapshots'}, (error, stdout) => { t.ok(error); t.match(stdout, /The snapshot file is v0, but only v3 is supported\./); t.match(stdout, /File path:/); @@ -95,10 +95,10 @@ test('outdated snapshot version is reported to the console', t => { }); test('outdated snapshot version can be updated', t => { - const snapPath = path.join(__dirname, '..', 'fixture', 'snapshots', 'test.cjs.snap'); + const snapPath = path.join(__dirname, '..', 'fixture', 'snapshots', 'test.js.snap'); fs.writeFileSync(snapPath, Buffer.from([0x0A, 0x00, 0x00])); - execCli(['test.cjs', '--update-snapshots'], {dirname: 'fixture/snapshots', env: {AVA_FORCE_CI: 'not-ci'}}, (error, stdout) => { + execCli(['test.js', '--update-snapshots'], {dirname: 'fixture/snapshots', env: {AVA_FORCE_CI: 'not-ci'}}, (error, stdout) => { t.error(error); t.match(stdout, /2 tests passed/); t.end(); @@ -106,10 +106,10 @@ test('outdated snapshot version can be updated', t => { }); test('newer snapshot version is reported to the console', t => { - const snapPath = path.join(__dirname, '..', 'fixture', 'snapshots', 'test.cjs.snap'); + const snapPath = path.join(__dirname, '..', 'fixture', 'snapshots', 'test.js.snap'); fs.writeFileSync(snapPath, Buffer.from([0x0A, 0xFF, 0xFF])); - execCli(['test.cjs'], {dirname: 'fixture/snapshots'}, (error, stdout) => { + execCli(['test.js'], {dirname: 'fixture/snapshots'}, (error, stdout) => { t.ok(error); t.match(stdout, /The snapshot file is v65535, but only v3 is supported\./); t.match(stdout, /File path:/); @@ -120,10 +120,10 @@ test('newer snapshot version is reported to the console', t => { }); test('snapshot corruption is reported to the console', t => { - const snapPath = path.join(__dirname, '..', 'fixture', 'snapshots', 'test.cjs.snap'); + const snapPath = path.join(__dirname, '..', 'fixture', 'snapshots', 'test.js.snap'); fs.writeFileSync(snapPath, Buffer.from([0x0A, 0x03, 0x00])); - execCli(['test.cjs'], {dirname: 'fixture/snapshots'}, (error, stdout) => { + execCli(['test.js'], {dirname: 'fixture/snapshots'}, (error, stdout) => { t.ok(error); t.match(stdout, /The snapshot file is corrupted\./); t.match(stdout, /File path:/); @@ -134,10 +134,10 @@ test('snapshot corruption is reported to the console', t => { }); test('legacy snapshot files are reported to the console', t => { - const snapPath = path.join(__dirname, '..', 'fixture', 'snapshots', 'test.cjs.snap'); + const snapPath = path.join(__dirname, '..', 'fixture', 'snapshots', 'test.js.snap'); fs.writeFileSync(snapPath, Buffer.from('// Jest Snapshot v1, https://goo.gl/fbAQLP\n')); - execCli(['test.cjs'], {dirname: 'fixture/snapshots'}, (error, stdout) => { + execCli(['test.js'], {dirname: 'fixture/snapshots'}, (error, stdout) => { t.ok(error); t.match(stdout, /The snapshot file was created with AVA 0\.19\. It’s not supported by this AVA version\./); t.match(stdout, /File path:/); @@ -205,8 +205,8 @@ test('snapshots resolved location from "snapshotDir" in AVA config', t => { .flatMap(snapRelativeDir => { const snapPath = path.join(__dirname, '..', relativeFixtureDir, snapDir, snapRelativeDir); return [ - path.join(snapPath, 'test.cjs.md'), - path.join(snapPath, 'test.cjs.snap'), + path.join(snapPath, 'test.js.md'), + path.join(snapPath, 'test.js.snap'), ]; }); const removeExistingSnapFixtureFiles = snapPath => { @@ -240,10 +240,10 @@ test('snapshots resolved location from "snapshotDir" in AVA config', t => { test('snapshots are identical on different platforms', t => { const fixtureDir = path.join(__dirname, '..', 'fixture', 'snapshots', 'test-content'); - const reportPath = path.join(fixtureDir, 'tests', 'snapshots', 'test.cjs.md'); - const snapPath = path.join(fixtureDir, 'tests', 'snapshots', 'test.cjs.snap'); - const expectedReportPath = path.join(fixtureDir, 'test.cjs.md.expected'); - const expectedSnapPath = path.join(fixtureDir, 'test.cjs.snap.expected'); + const reportPath = path.join(fixtureDir, 'tests', 'snapshots', 'test.js.md'); + const snapPath = path.join(fixtureDir, 'tests', 'snapshots', 'test.js.snap'); + const expectedReportPath = path.join(fixtureDir, 'test.js.md.expected'); + const expectedSnapPath = path.join(fixtureDir, 'test.js.snap.expected'); const removeFile = filePath => { try { @@ -279,8 +279,8 @@ test('snapshots are identical on different platforms', t => { test('in CI, new snapshots are not recorded', t => { const fixtureDir = path.join(__dirname, '..', 'fixture', 'snapshots', 'test-content'); - const reportPath = path.join(fixtureDir, 'tests', 'snapshots', 'test.cjs.md'); - const snapPath = path.join(fixtureDir, 'tests', 'snapshots', 'test.cjs.snap'); + const reportPath = path.join(fixtureDir, 'tests', 'snapshots', 'test.js.md'); + const snapPath = path.join(fixtureDir, 'tests', 'snapshots', 'test.js.snap'); const removeFile = filePath => { try { diff --git a/test-tap/integration/stack-traces.js b/test-tap/integration/stack-traces.js index 19858e808..1b22a2da4 100644 --- a/test-tap/integration/stack-traces.js +++ b/test-tap/integration/stack-traces.js @@ -3,12 +3,12 @@ import {test} from 'tap'; import {execCli} from '../helper/cli.js'; test('`AssertionError` should capture infinity stack trace', t => { - execCli('infinity-stack-trace.cjs', (error, stdout) => { + execCli('infinity-stack-trace.js', (error, stdout) => { t.ok(error); - t.match(stdout, /c \(.*infinity-stack-trace\.cjs:6:20\)/); - t.match(stdout, /b \(.*infinity-stack-trace\.cjs:7:18\)/); - t.match(stdout, /a \(.*infinity-stack-trace\.cjs:8:18\)/); - t.match(stdout, /.+?infinity-stack-trace\.cjs:10:2/); + t.match(stdout, /c \(.*infinity-stack-trace\.js:6:20\)/); + t.match(stdout, /b \(.*infinity-stack-trace\.js:7:18\)/); + t.match(stdout, /a \(.*infinity-stack-trace\.js:8:18\)/); + t.match(stdout, /.+?infinity-stack-trace\.js:10:2/); t.end(); }); }); diff --git a/test-tap/integration/stalled.js b/test-tap/integration/stalled.js index 92aab92f9..10622eeb8 100644 --- a/test-tap/integration/stalled.js +++ b/test-tap/integration/stalled.js @@ -3,14 +3,14 @@ import {test} from 'tap'; import {execCli} from '../helper/cli.js'; test('observable tests fail if event loop empties before they’re resolved', t => { - execCli('observable.cjs', {dirname: 'fixture/stalled-tests'}, (_, stdout) => { + execCli('observable.js', {dirname: 'fixture/stalled-tests'}, (_, stdout) => { t.match(stdout, /Observable returned by test never completed/); t.end(); }); }); test('promise tests fail if event loop empties before they’re resolved', t => { - execCli('promise.cjs', {dirname: 'fixture/stalled-tests'}, (_, stdout) => { + execCli('promise.js', {dirname: 'fixture/stalled-tests'}, (_, stdout) => { t.match(stdout, /Promise returned by test never resolved/); t.end(); }); diff --git a/test-tap/node-arguments.js b/test-tap/node-arguments.js index e7b6068d6..af9d0cdcd 100644 --- a/test-tap/node-arguments.js +++ b/test-tap/node-arguments.js @@ -4,8 +4,8 @@ import normalizeNodeArguments from '../lib/node-arguments.js'; test('combines arguments', async t => { t.same( - await normalizeNodeArguments(['--require setup.cjs'], '--throw-deprecation --zero-fill-buffers'), - [...process.execArgv, '--require setup.cjs', '--throw-deprecation', '--zero-fill-buffers'], + await normalizeNodeArguments(['--import setup.js'], '--throw-deprecation --zero-fill-buffers'), + [...process.execArgv, '--import setup.js', '--throw-deprecation', '--zero-fill-buffers'], ); t.end(); }); diff --git a/test-tap/promise.js b/test-tap/promise.js index 466cab405..8c92e18f3 100644 --- a/test-tap/promise.js +++ b/test-tap/promise.js @@ -2,7 +2,7 @@ import {test} from 'tap'; import './helper/chalk0.js'; // eslint-disable-line import-x/no-unassigned-import import Test from '../lib/test.js'; -import {set as setOptions} from '../lib/worker/options.cjs'; +import {set as setOptions} from '../lib/worker/options.js'; setOptions({}); diff --git a/test-tap/reporters/default.edgecases.v22.log b/test-tap/reporters/default.edgecases.v22.log index 8b1c5dcdf..f6970e4d3 100644 --- a/test-tap/reporters/default.edgecases.v22.log +++ b/test-tap/reporters/default.edgecases.v22.log @@ -1,27 +1,27 @@ ---tty-stream-chunk-separator - ⚠ Could not parse ast-syntax-error.cjs for line number selection + ⚠ Could not parse ast-syntax-error.js for line number selection SyntaxError: Unexpected token (3:11) ---tty-stream-chunk-separator - Uncaught exception in ast-syntax-error.cjs + Uncaught exception in ast-syntax-error.js - ~/test-tap/fixture/report/edgecases/ast-syntax-error.cjs:3 + ~/test-tap/fixture/report/edgecases/ast-syntax-error.js:3 const fn = do { ^^ SyntaxError: Unexpected token 'do' ---tty-stream-chunk-separator - ✘ ast-syntax-error.cjs exited with a non-zero exit code: 1 + ✘ ast-syntax-error.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator - ✘ No tests found in ava-import-no-test-declaration.cjs + ✘ No tests found in ava-import-no-test-declaration.js ---tty-stream-chunk-separator - Uncaught exception in import-and-use-test-member.cjs + Uncaught exception in import-and-use-test-member.js - import-and-use-test-member.cjs:3 + import-and-use-test-member.js:3 2:  3: test('pass', t => t.pass()); @@ -29,29 +29,29 @@ TypeError: test is not a function - › Object. (test-tap/fixture/report/edgecases/import-and-use-test-member.cjs:3:1) + › Object. (test-tap/fixture/report/edgecases/import-and-use-test-member.js:3:1) ---tty-stream-chunk-separator - ✘ import-and-use-test-member.cjs exited with a non-zero exit code: 1 + ✘ import-and-use-test-member.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator - ✘ No tests found in no-ava-import.cjs, make sure to import "ava" at the top of your test file + ✘ No tests found in no-ava-import.js, make sure to import "ava" at the top of your test file ---tty-stream-chunk-separator - ✘ Line numbers for test.cjs did not match any tests + ✘ Line numbers for test.js did not match any tests ---tty-stream-chunk-separator - Uncaught exception in throws.cjs + Uncaught exception in throws.js - throws.cjs:1 + throws.js:1  1: throw new Error('throws'); 2: Error: throws - › Object. (test-tap/fixture/report/edgecases/throws.cjs:1:7) + › Object. (test-tap/fixture/report/edgecases/throws.js:1:7) ---tty-stream-chunk-separator - ✘ throws.cjs exited with a non-zero exit code: 1 + ✘ throws.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator ─ diff --git a/test-tap/reporters/default.edgecases.v24.log b/test-tap/reporters/default.edgecases.v24.log index 8b1c5dcdf..f6970e4d3 100644 --- a/test-tap/reporters/default.edgecases.v24.log +++ b/test-tap/reporters/default.edgecases.v24.log @@ -1,27 +1,27 @@ ---tty-stream-chunk-separator - ⚠ Could not parse ast-syntax-error.cjs for line number selection + ⚠ Could not parse ast-syntax-error.js for line number selection SyntaxError: Unexpected token (3:11) ---tty-stream-chunk-separator - Uncaught exception in ast-syntax-error.cjs + Uncaught exception in ast-syntax-error.js - ~/test-tap/fixture/report/edgecases/ast-syntax-error.cjs:3 + ~/test-tap/fixture/report/edgecases/ast-syntax-error.js:3 const fn = do { ^^ SyntaxError: Unexpected token 'do' ---tty-stream-chunk-separator - ✘ ast-syntax-error.cjs exited with a non-zero exit code: 1 + ✘ ast-syntax-error.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator - ✘ No tests found in ava-import-no-test-declaration.cjs + ✘ No tests found in ava-import-no-test-declaration.js ---tty-stream-chunk-separator - Uncaught exception in import-and-use-test-member.cjs + Uncaught exception in import-and-use-test-member.js - import-and-use-test-member.cjs:3 + import-and-use-test-member.js:3 2:  3: test('pass', t => t.pass()); @@ -29,29 +29,29 @@ TypeError: test is not a function - › Object. (test-tap/fixture/report/edgecases/import-and-use-test-member.cjs:3:1) + › Object. (test-tap/fixture/report/edgecases/import-and-use-test-member.js:3:1) ---tty-stream-chunk-separator - ✘ import-and-use-test-member.cjs exited with a non-zero exit code: 1 + ✘ import-and-use-test-member.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator - ✘ No tests found in no-ava-import.cjs, make sure to import "ava" at the top of your test file + ✘ No tests found in no-ava-import.js, make sure to import "ava" at the top of your test file ---tty-stream-chunk-separator - ✘ Line numbers for test.cjs did not match any tests + ✘ Line numbers for test.js did not match any tests ---tty-stream-chunk-separator - Uncaught exception in throws.cjs + Uncaught exception in throws.js - throws.cjs:1 + throws.js:1  1: throw new Error('throws'); 2: Error: throws - › Object. (test-tap/fixture/report/edgecases/throws.cjs:1:7) + › Object. (test-tap/fixture/report/edgecases/throws.js:1:7) ---tty-stream-chunk-separator - ✘ throws.cjs exited with a non-zero exit code: 1 + ✘ throws.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator ─ diff --git a/test-tap/reporters/default.edgecases.v25.log b/test-tap/reporters/default.edgecases.v25.log index 8b1c5dcdf..848a8a1b7 100644 --- a/test-tap/reporters/default.edgecases.v25.log +++ b/test-tap/reporters/default.edgecases.v25.log @@ -1,27 +1,23 @@ ---tty-stream-chunk-separator - ⚠ Could not parse ast-syntax-error.cjs for line number selection + ⚠ Could not parse ast-syntax-error.js for line number selection SyntaxError: Unexpected token (3:11) ---tty-stream-chunk-separator - Uncaught exception in ast-syntax-error.cjs - - ~/test-tap/fixture/report/edgecases/ast-syntax-error.cjs:3 - const fn = do { - ^^ + Uncaught exception in ast-syntax-error.js SyntaxError: Unexpected token 'do' ---tty-stream-chunk-separator - ✘ ast-syntax-error.cjs exited with a non-zero exit code: 1 + ✘ ast-syntax-error.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator - ✘ No tests found in ava-import-no-test-declaration.cjs + ✘ No tests found in ava-import-no-test-declaration.js ---tty-stream-chunk-separator - Uncaught exception in import-and-use-test-member.cjs + Uncaught exception in import-and-use-test-member.js - import-and-use-test-member.cjs:3 + import-and-use-test-member.js:3 2:  3: test('pass', t => t.pass()); @@ -29,29 +25,29 @@ TypeError: test is not a function - › Object. (test-tap/fixture/report/edgecases/import-and-use-test-member.cjs:3:1) + › file://test-tap/fixture/report/edgecases/import-and-use-test-member.js:3:1 ---tty-stream-chunk-separator - ✘ import-and-use-test-member.cjs exited with a non-zero exit code: 1 + ✘ import-and-use-test-member.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator - ✘ No tests found in no-ava-import.cjs, make sure to import "ava" at the top of your test file + ✘ No tests found in no-ava-import.js, make sure to import "ava" at the top of your test file ---tty-stream-chunk-separator - ✘ Line numbers for test.cjs did not match any tests + ✘ Line numbers for test.js did not match any tests ---tty-stream-chunk-separator - Uncaught exception in throws.cjs + Uncaught exception in throws.js - throws.cjs:1 + throws.js:1  1: throw new Error('throws'); 2: Error: throws - › Object. (test-tap/fixture/report/edgecases/throws.cjs:1:7) + › Object. (test-tap/fixture/report/edgecases/throws.js:1:7) ---tty-stream-chunk-separator - ✘ throws.cjs exited with a non-zero exit code: 1 + ✘ throws.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator ─ diff --git a/test-tap/reporters/default.failfast.v22.log b/test-tap/reporters/default.failfast.v22.log index 1822d26dd..50c902ba6 100644 --- a/test-tap/reporters/default.failfast.v22.log +++ b/test-tap/reporters/default.failfast.v22.log @@ -6,7 +6,7 @@ a › fails - a.cjs:3 + a.js:3 2:  3: test('fails', t => t.fail()); @@ -14,7 +14,7 @@ Test failed via `t.fail()` - › test-tap/fixture/report/failfast/a.cjs:3:22 + › test-tap/fixture/report/failfast/a.js:3:22 ─ diff --git a/test-tap/reporters/default.failfast.v24.log b/test-tap/reporters/default.failfast.v24.log index 1822d26dd..50c902ba6 100644 --- a/test-tap/reporters/default.failfast.v24.log +++ b/test-tap/reporters/default.failfast.v24.log @@ -6,7 +6,7 @@ a › fails - a.cjs:3 + a.js:3 2:  3: test('fails', t => t.fail()); @@ -14,7 +14,7 @@ Test failed via `t.fail()` - › test-tap/fixture/report/failfast/a.cjs:3:22 + › test-tap/fixture/report/failfast/a.js:3:22 ─ diff --git a/test-tap/reporters/default.failfast.v25.log b/test-tap/reporters/default.failfast.v25.log index 1822d26dd..0fc2a3426 100644 --- a/test-tap/reporters/default.failfast.v25.log +++ b/test-tap/reporters/default.failfast.v25.log @@ -6,7 +6,7 @@ a › fails - a.cjs:3 + a.js:3 2:  3: test('fails', t => t.fail()); @@ -14,7 +14,7 @@ Test failed via `t.fail()` - › test-tap/fixture/report/failfast/a.cjs:3:22 + › file://test-tap/fixture/report/failfast/a.js:3:22 ─ diff --git a/test-tap/reporters/default.failfast2.v22.log b/test-tap/reporters/default.failfast2.v22.log index 29437d029..e3e69c25b 100644 --- a/test-tap/reporters/default.failfast2.v22.log +++ b/test-tap/reporters/default.failfast2.v22.log @@ -6,7 +6,7 @@ a › fails - a.cjs:3 + a.js:3 2:  3: test('fails', t => t.fail());  @@ -14,7 +14,7 @@ Test failed via `t.fail()` - › test-tap/fixture/report/failfast2/a.cjs:3:22 + › test-tap/fixture/report/failfast2/a.js:3:22 ─ diff --git a/test-tap/reporters/default.failfast2.v24.log b/test-tap/reporters/default.failfast2.v24.log index 29437d029..e3e69c25b 100644 --- a/test-tap/reporters/default.failfast2.v24.log +++ b/test-tap/reporters/default.failfast2.v24.log @@ -6,7 +6,7 @@ a › fails - a.cjs:3 + a.js:3 2:  3: test('fails', t => t.fail());  @@ -14,7 +14,7 @@ Test failed via `t.fail()` - › test-tap/fixture/report/failfast2/a.cjs:3:22 + › test-tap/fixture/report/failfast2/a.js:3:22 ─ diff --git a/test-tap/reporters/default.failfast2.v25.log b/test-tap/reporters/default.failfast2.v25.log index 29437d029..da6ebaa58 100644 --- a/test-tap/reporters/default.failfast2.v25.log +++ b/test-tap/reporters/default.failfast2.v25.log @@ -6,7 +6,7 @@ a › fails - a.cjs:3 + a.js:3 2:  3: test('fails', t => t.fail());  @@ -14,7 +14,7 @@ Test failed via `t.fail()` - › test-tap/fixture/report/failfast2/a.cjs:3:22 + › file://test-tap/fixture/report/failfast2/a.js:3:22 ─ diff --git a/test-tap/reporters/default.js b/test-tap/reporters/default.js index 818f2f7cc..b786d9126 100644 --- a/test-tap/reporters/default.js +++ b/test-tap/reporters/default.js @@ -29,7 +29,7 @@ test(async t => { ], }); const reporter = new Reporter({ - extensions: ['cjs'], + extensions: ['js'], projectDir: report.projectDir(type), durationThreshold: 60_000, reportStream: tty, diff --git a/test-tap/reporters/default.regular.v22.log b/test-tap/reporters/default.regular.v22.log index c65476560..53b6fd344 100644 --- a/test-tap/reporters/default.regular.v22.log +++ b/test-tap/reporters/default.regular.v22.log @@ -1,8 +1,8 @@ ---tty-stream-chunk-separator - Uncaught exception in bad-test-chain.cjs + Uncaught exception in bad-test-chain.js - bad-test-chain.cjs:3 + bad-test-chain.js:3 2:  3: test.serial.test('passes', t => t.pass()); @@ -10,10 +10,10 @@ TypeError: test.serial.test is not a function - › Object. (test-tap/fixture/report/regular/bad-test-chain.cjs:3:13) + › Object. (test-tap/fixture/report/regular/bad-test-chain.js:3:13) ---tty-stream-chunk-separator - ✘ bad-test-chain.cjs exited with a non-zero exit code: 1 + ✘ bad-test-chain.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator ✘ [fail]: nested-objects › format with max depth 4 ---tty-stream-chunk-separator @@ -77,9 +77,9 @@ ✔ uncaught-exception › passes ---tty-stream-chunk-separator - Uncaught exception in uncaught-exception.cjs + Uncaught exception in uncaught-exception.js - uncaught-exception.cjs:5 + uncaught-exception.js:5 4: setImmediate(() => {  5: throw new Error('Can’t catch me'); @@ -87,19 +87,19 @@ Error: Can’t catch me - › Immediate. (test-tap/fixture/report/regular/uncaught-exception.cjs:5:9) + › Immediate. (test-tap/fixture/report/regular/uncaught-exception.js:5:9) ---tty-stream-chunk-separator - ✘ uncaught-exception.cjs exited with a non-zero exit code: 1 + ✘ uncaught-exception.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator ✔ unhandled-rejection › passes ---tty-stream-chunk-separator ✔ unhandled-rejection › unhandled non-error rejection ---tty-stream-chunk-separator - Unhandled rejection in unhandled-rejection.cjs + Unhandled rejection in unhandled-rejection.js - unhandled-rejection.cjs:4 + unhandled-rejection.js:4 3: const passes = t => {  4: Promise.reject(new Error('Can’t catch me')); @@ -107,21 +107,21 @@ Error: Can’t catch me - › passes (test-tap/fixture/report/regular/unhandled-rejection.cjs:4:17) + › passes (test-tap/fixture/report/regular/unhandled-rejection.js:4:17) ---tty-stream-chunk-separator - Unhandled rejection in unhandled-rejection.cjs + Unhandled rejection in unhandled-rejection.js null ---tty-stream-chunk-separator - ✘ unhandled-rejection.cjs exited with a non-zero exit code: 1 + ✘ unhandled-rejection.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator ─ nested-objects › format with max depth 4 - nested-objects.cjs:29 + nested-objects.js:29 28: };  29: t.deepEqual(exp, act); @@ -144,13 +144,13 @@ + }, } - › test-tap/fixture/report/regular/nested-objects.cjs:29:4 + › test-tap/fixture/report/regular/nested-objects.js:29:4 nested-objects › format like with max depth 4 - nested-objects.cjs:55 + nested-objects.js:55 54: };  55: t.like(actual, pattern); @@ -167,13 +167,13 @@ }, } - › test-tap/fixture/report/regular/nested-objects.cjs:55:4 + › test-tap/fixture/report/regular/nested-objects.js:55:4 output-in-hook › failing test - output-in-hook.cjs:34 + output-in-hook.js:34 33: test('failing test', t => {  34: t.fail();  @@ -181,13 +181,13 @@ Test failed via `t.fail()` - › test-tap/fixture/report/regular/output-in-hook.cjs:34:4 + › test-tap/fixture/report/regular/output-in-hook.js:34:4 test › fails - test.cjs:9 + test.js:9 8:  9: test('fails', t => t.fail()); @@ -195,7 +195,7 @@ Test failed via `t.fail()` - › test-tap/fixture/report/regular/test.cjs:9:22 + › test-tap/fixture/report/regular/test.js:9:22 @@ -206,7 +206,7 @@ test › logs - test.cjs:18 + test.js:18 17: t.log('world');  18: t.fail();  @@ -214,13 +214,13 @@ Test failed via `t.fail()` - › test-tap/fixture/report/regular/test.cjs:18:4 + › test-tap/fixture/report/regular/test.js:18:4 test › formatted - test.cjs:22 + test.js:22 21: test('formatted', t => {  22: t.deepEqual('foo', 'bar'); @@ -231,7 +231,7 @@ - 'foo' + 'bar' - › test-tap/fixture/report/regular/test.cjs:22:4 + › test-tap/fixture/report/regular/test.js:22:4 @@ -245,7 +245,7 @@ traces-in-t-throws › throws - traces-in-t-throws.cjs:12 + traces-in-t-throws.js:12 11: test('throws', t => {  12: t.throws(() => throwError(), {instanceOf: TypeError}); @@ -261,15 +261,15 @@ Function TypeError {} - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8) - › t.throws.instanceOf (test-tap/fixture/report/regular/traces-in-t-throws.cjs:12:17) - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:12:4 + › throwError (test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › t.throws.instanceOf (test-tap/fixture/report/regular/traces-in-t-throws.js:12:17) + › test-tap/fixture/report/regular/traces-in-t-throws.js:12:4 traces-in-t-throws › notThrows - traces-in-t-throws.cjs:16 + traces-in-t-throws.js:16 15: test('notThrows', t => {  16: t.notThrows(() => throwError()); @@ -281,15 +281,15 @@ message: 'uh-oh', } - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8) - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:16:20 - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:16:4 + › throwError (test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › test-tap/fixture/report/regular/traces-in-t-throws.js:16:20 + › test-tap/fixture/report/regular/traces-in-t-throws.js:16:4 traces-in-t-throws › notThrowsAsync - traces-in-t-throws.cjs:20 + traces-in-t-throws.js:20 19: test('notThrowsAsync', async t => {  20: await t.notThrowsAsync(() => throwError()); @@ -301,15 +301,15 @@ message: 'uh-oh', } - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8) - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:20:31 - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:20:10 + › throwError (test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › test-tap/fixture/report/regular/traces-in-t-throws.js:20:31 + › test-tap/fixture/report/regular/traces-in-t-throws.js:20:10 traces-in-t-throws › throwsAsync - traces-in-t-throws.cjs:24 + traces-in-t-throws.js:24 23: test('throwsAsync', async t => {  24: await t.throwsAsync(() => throwError(), {instanceOf: TypeError}); @@ -321,15 +321,15 @@ message: 'uh-oh', } - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8) - › t.throwsAsync.instanceOf (test-tap/fixture/report/regular/traces-in-t-throws.cjs:24:28) - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:24:10 + › throwError (test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › t.throwsAsync.instanceOf (test-tap/fixture/report/regular/traces-in-t-throws.js:24:28) + › test-tap/fixture/report/regular/traces-in-t-throws.js:24:10 traces-in-t-throws › throwsAsync different error - traces-in-t-throws.cjs:28 + traces-in-t-throws.js:28 27: test('throwsAsync different error', async t => {  28: await t.throwsAsync(returnRejectedPromise, {instanceOf: TypeError}); @@ -345,8 +345,8 @@ Function TypeError {} - › returnRejectedPromise (test-tap/fixture/report/regular/traces-in-t-throws.cjs:8:24) - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:28:10 + › returnRejectedPromise (test-tap/fixture/report/regular/traces-in-t-throws.js:8:24) + › test-tap/fixture/report/regular/traces-in-t-throws.js:28:10 ─ diff --git a/test-tap/reporters/default.regular.v24.log b/test-tap/reporters/default.regular.v24.log index c65476560..53b6fd344 100644 --- a/test-tap/reporters/default.regular.v24.log +++ b/test-tap/reporters/default.regular.v24.log @@ -1,8 +1,8 @@ ---tty-stream-chunk-separator - Uncaught exception in bad-test-chain.cjs + Uncaught exception in bad-test-chain.js - bad-test-chain.cjs:3 + bad-test-chain.js:3 2:  3: test.serial.test('passes', t => t.pass()); @@ -10,10 +10,10 @@ TypeError: test.serial.test is not a function - › Object. (test-tap/fixture/report/regular/bad-test-chain.cjs:3:13) + › Object. (test-tap/fixture/report/regular/bad-test-chain.js:3:13) ---tty-stream-chunk-separator - ✘ bad-test-chain.cjs exited with a non-zero exit code: 1 + ✘ bad-test-chain.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator ✘ [fail]: nested-objects › format with max depth 4 ---tty-stream-chunk-separator @@ -77,9 +77,9 @@ ✔ uncaught-exception › passes ---tty-stream-chunk-separator - Uncaught exception in uncaught-exception.cjs + Uncaught exception in uncaught-exception.js - uncaught-exception.cjs:5 + uncaught-exception.js:5 4: setImmediate(() => {  5: throw new Error('Can’t catch me'); @@ -87,19 +87,19 @@ Error: Can’t catch me - › Immediate. (test-tap/fixture/report/regular/uncaught-exception.cjs:5:9) + › Immediate. (test-tap/fixture/report/regular/uncaught-exception.js:5:9) ---tty-stream-chunk-separator - ✘ uncaught-exception.cjs exited with a non-zero exit code: 1 + ✘ uncaught-exception.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator ✔ unhandled-rejection › passes ---tty-stream-chunk-separator ✔ unhandled-rejection › unhandled non-error rejection ---tty-stream-chunk-separator - Unhandled rejection in unhandled-rejection.cjs + Unhandled rejection in unhandled-rejection.js - unhandled-rejection.cjs:4 + unhandled-rejection.js:4 3: const passes = t => {  4: Promise.reject(new Error('Can’t catch me')); @@ -107,21 +107,21 @@ Error: Can’t catch me - › passes (test-tap/fixture/report/regular/unhandled-rejection.cjs:4:17) + › passes (test-tap/fixture/report/regular/unhandled-rejection.js:4:17) ---tty-stream-chunk-separator - Unhandled rejection in unhandled-rejection.cjs + Unhandled rejection in unhandled-rejection.js null ---tty-stream-chunk-separator - ✘ unhandled-rejection.cjs exited with a non-zero exit code: 1 + ✘ unhandled-rejection.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator ─ nested-objects › format with max depth 4 - nested-objects.cjs:29 + nested-objects.js:29 28: };  29: t.deepEqual(exp, act); @@ -144,13 +144,13 @@ + }, } - › test-tap/fixture/report/regular/nested-objects.cjs:29:4 + › test-tap/fixture/report/regular/nested-objects.js:29:4 nested-objects › format like with max depth 4 - nested-objects.cjs:55 + nested-objects.js:55 54: };  55: t.like(actual, pattern); @@ -167,13 +167,13 @@ }, } - › test-tap/fixture/report/regular/nested-objects.cjs:55:4 + › test-tap/fixture/report/regular/nested-objects.js:55:4 output-in-hook › failing test - output-in-hook.cjs:34 + output-in-hook.js:34 33: test('failing test', t => {  34: t.fail();  @@ -181,13 +181,13 @@ Test failed via `t.fail()` - › test-tap/fixture/report/regular/output-in-hook.cjs:34:4 + › test-tap/fixture/report/regular/output-in-hook.js:34:4 test › fails - test.cjs:9 + test.js:9 8:  9: test('fails', t => t.fail()); @@ -195,7 +195,7 @@ Test failed via `t.fail()` - › test-tap/fixture/report/regular/test.cjs:9:22 + › test-tap/fixture/report/regular/test.js:9:22 @@ -206,7 +206,7 @@ test › logs - test.cjs:18 + test.js:18 17: t.log('world');  18: t.fail();  @@ -214,13 +214,13 @@ Test failed via `t.fail()` - › test-tap/fixture/report/regular/test.cjs:18:4 + › test-tap/fixture/report/regular/test.js:18:4 test › formatted - test.cjs:22 + test.js:22 21: test('formatted', t => {  22: t.deepEqual('foo', 'bar'); @@ -231,7 +231,7 @@ - 'foo' + 'bar' - › test-tap/fixture/report/regular/test.cjs:22:4 + › test-tap/fixture/report/regular/test.js:22:4 @@ -245,7 +245,7 @@ traces-in-t-throws › throws - traces-in-t-throws.cjs:12 + traces-in-t-throws.js:12 11: test('throws', t => {  12: t.throws(() => throwError(), {instanceOf: TypeError}); @@ -261,15 +261,15 @@ Function TypeError {} - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8) - › t.throws.instanceOf (test-tap/fixture/report/regular/traces-in-t-throws.cjs:12:17) - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:12:4 + › throwError (test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › t.throws.instanceOf (test-tap/fixture/report/regular/traces-in-t-throws.js:12:17) + › test-tap/fixture/report/regular/traces-in-t-throws.js:12:4 traces-in-t-throws › notThrows - traces-in-t-throws.cjs:16 + traces-in-t-throws.js:16 15: test('notThrows', t => {  16: t.notThrows(() => throwError()); @@ -281,15 +281,15 @@ message: 'uh-oh', } - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8) - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:16:20 - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:16:4 + › throwError (test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › test-tap/fixture/report/regular/traces-in-t-throws.js:16:20 + › test-tap/fixture/report/regular/traces-in-t-throws.js:16:4 traces-in-t-throws › notThrowsAsync - traces-in-t-throws.cjs:20 + traces-in-t-throws.js:20 19: test('notThrowsAsync', async t => {  20: await t.notThrowsAsync(() => throwError()); @@ -301,15 +301,15 @@ message: 'uh-oh', } - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8) - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:20:31 - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:20:10 + › throwError (test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › test-tap/fixture/report/regular/traces-in-t-throws.js:20:31 + › test-tap/fixture/report/regular/traces-in-t-throws.js:20:10 traces-in-t-throws › throwsAsync - traces-in-t-throws.cjs:24 + traces-in-t-throws.js:24 23: test('throwsAsync', async t => {  24: await t.throwsAsync(() => throwError(), {instanceOf: TypeError}); @@ -321,15 +321,15 @@ message: 'uh-oh', } - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8) - › t.throwsAsync.instanceOf (test-tap/fixture/report/regular/traces-in-t-throws.cjs:24:28) - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:24:10 + › throwError (test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › t.throwsAsync.instanceOf (test-tap/fixture/report/regular/traces-in-t-throws.js:24:28) + › test-tap/fixture/report/regular/traces-in-t-throws.js:24:10 traces-in-t-throws › throwsAsync different error - traces-in-t-throws.cjs:28 + traces-in-t-throws.js:28 27: test('throwsAsync different error', async t => {  28: await t.throwsAsync(returnRejectedPromise, {instanceOf: TypeError}); @@ -345,8 +345,8 @@ Function TypeError {} - › returnRejectedPromise (test-tap/fixture/report/regular/traces-in-t-throws.cjs:8:24) - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:28:10 + › returnRejectedPromise (test-tap/fixture/report/regular/traces-in-t-throws.js:8:24) + › test-tap/fixture/report/regular/traces-in-t-throws.js:28:10 ─ diff --git a/test-tap/reporters/default.regular.v25.log b/test-tap/reporters/default.regular.v25.log index c65476560..6a784054f 100644 --- a/test-tap/reporters/default.regular.v25.log +++ b/test-tap/reporters/default.regular.v25.log @@ -1,8 +1,8 @@ ---tty-stream-chunk-separator - Uncaught exception in bad-test-chain.cjs + Uncaught exception in bad-test-chain.js - bad-test-chain.cjs:3 + bad-test-chain.js:3 2:  3: test.serial.test('passes', t => t.pass()); @@ -10,10 +10,10 @@ TypeError: test.serial.test is not a function - › Object. (test-tap/fixture/report/regular/bad-test-chain.cjs:3:13) + › file://test-tap/fixture/report/regular/bad-test-chain.js:3:13 ---tty-stream-chunk-separator - ✘ bad-test-chain.cjs exited with a non-zero exit code: 1 + ✘ bad-test-chain.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator ✘ [fail]: nested-objects › format with max depth 4 ---tty-stream-chunk-separator @@ -77,9 +77,9 @@ ✔ uncaught-exception › passes ---tty-stream-chunk-separator - Uncaught exception in uncaught-exception.cjs + Uncaught exception in uncaught-exception.js - uncaught-exception.cjs:5 + uncaught-exception.js:5 4: setImmediate(() => {  5: throw new Error('Can’t catch me'); @@ -87,19 +87,19 @@ Error: Can’t catch me - › Immediate. (test-tap/fixture/report/regular/uncaught-exception.cjs:5:9) + › Immediate. (file://test-tap/fixture/report/regular/uncaught-exception.js:5:9) ---tty-stream-chunk-separator - ✘ uncaught-exception.cjs exited with a non-zero exit code: 1 + ✘ uncaught-exception.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator ✔ unhandled-rejection › passes ---tty-stream-chunk-separator ✔ unhandled-rejection › unhandled non-error rejection ---tty-stream-chunk-separator - Unhandled rejection in unhandled-rejection.cjs + Unhandled rejection in unhandled-rejection.js - unhandled-rejection.cjs:4 + unhandled-rejection.js:4 3: const passes = t => {  4: Promise.reject(new Error('Can’t catch me')); @@ -107,21 +107,21 @@ Error: Can’t catch me - › passes (test-tap/fixture/report/regular/unhandled-rejection.cjs:4:17) + › passes (file://test-tap/fixture/report/regular/unhandled-rejection.js:4:17) ---tty-stream-chunk-separator - Unhandled rejection in unhandled-rejection.cjs + Unhandled rejection in unhandled-rejection.js null ---tty-stream-chunk-separator - ✘ unhandled-rejection.cjs exited with a non-zero exit code: 1 + ✘ unhandled-rejection.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator ─ nested-objects › format with max depth 4 - nested-objects.cjs:29 + nested-objects.js:29 28: };  29: t.deepEqual(exp, act); @@ -144,13 +144,13 @@ + }, } - › test-tap/fixture/report/regular/nested-objects.cjs:29:4 + › file://test-tap/fixture/report/regular/nested-objects.js:29:4 nested-objects › format like with max depth 4 - nested-objects.cjs:55 + nested-objects.js:55 54: };  55: t.like(actual, pattern); @@ -167,13 +167,13 @@ }, } - › test-tap/fixture/report/regular/nested-objects.cjs:55:4 + › file://test-tap/fixture/report/regular/nested-objects.js:55:4 output-in-hook › failing test - output-in-hook.cjs:34 + output-in-hook.js:34 33: test('failing test', t => {  34: t.fail();  @@ -181,13 +181,13 @@ Test failed via `t.fail()` - › test-tap/fixture/report/regular/output-in-hook.cjs:34:4 + › file://test-tap/fixture/report/regular/output-in-hook.js:34:4 test › fails - test.cjs:9 + test.js:9 8:  9: test('fails', t => t.fail()); @@ -195,7 +195,7 @@ Test failed via `t.fail()` - › test-tap/fixture/report/regular/test.cjs:9:22 + › file://test-tap/fixture/report/regular/test.js:9:22 @@ -206,7 +206,7 @@ test › logs - test.cjs:18 + test.js:18 17: t.log('world');  18: t.fail();  @@ -214,13 +214,13 @@ Test failed via `t.fail()` - › test-tap/fixture/report/regular/test.cjs:18:4 + › file://test-tap/fixture/report/regular/test.js:18:4 test › formatted - test.cjs:22 + test.js:22 21: test('formatted', t => {  22: t.deepEqual('foo', 'bar'); @@ -231,7 +231,7 @@ - 'foo' + 'bar' - › test-tap/fixture/report/regular/test.cjs:22:4 + › file://test-tap/fixture/report/regular/test.js:22:4 @@ -245,7 +245,7 @@ traces-in-t-throws › throws - traces-in-t-throws.cjs:12 + traces-in-t-throws.js:12 11: test('throws', t => {  12: t.throws(() => throwError(), {instanceOf: TypeError}); @@ -261,15 +261,15 @@ Function TypeError {} - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8) - › t.throws.instanceOf (test-tap/fixture/report/regular/traces-in-t-throws.cjs:12:17) - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:12:4 + › throwError (file://test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › t.throws.instanceOf (file://test-tap/fixture/report/regular/traces-in-t-throws.js:12:17) + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:12:4 traces-in-t-throws › notThrows - traces-in-t-throws.cjs:16 + traces-in-t-throws.js:16 15: test('notThrows', t => {  16: t.notThrows(() => throwError()); @@ -281,15 +281,15 @@ message: 'uh-oh', } - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8) - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:16:20 - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:16:4 + › throwError (file://test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:16:20 + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:16:4 traces-in-t-throws › notThrowsAsync - traces-in-t-throws.cjs:20 + traces-in-t-throws.js:20 19: test('notThrowsAsync', async t => {  20: await t.notThrowsAsync(() => throwError()); @@ -301,15 +301,15 @@ message: 'uh-oh', } - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8) - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:20:31 - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:20:10 + › throwError (file://test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:20:31 + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:20:10 traces-in-t-throws › throwsAsync - traces-in-t-throws.cjs:24 + traces-in-t-throws.js:24 23: test('throwsAsync', async t => {  24: await t.throwsAsync(() => throwError(), {instanceOf: TypeError}); @@ -321,15 +321,15 @@ message: 'uh-oh', } - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8) - › t.throwsAsync.instanceOf (test-tap/fixture/report/regular/traces-in-t-throws.cjs:24:28) - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:24:10 + › throwError (file://test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › t.throwsAsync.instanceOf (file://test-tap/fixture/report/regular/traces-in-t-throws.js:24:28) + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:24:10 traces-in-t-throws › throwsAsync different error - traces-in-t-throws.cjs:28 + traces-in-t-throws.js:28 27: test('throwsAsync different error', async t => {  28: await t.throwsAsync(returnRejectedPromise, {instanceOf: TypeError}); @@ -345,8 +345,8 @@ Function TypeError {} - › returnRejectedPromise (test-tap/fixture/report/regular/traces-in-t-throws.cjs:8:24) - › test-tap/fixture/report/regular/traces-in-t-throws.cjs:28:10 + › returnRejectedPromise (file://test-tap/fixture/report/regular/traces-in-t-throws.js:8:24) + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:28:10 ─ diff --git a/test-tap/reporters/default.timeoutcontextlogs.v22.log b/test-tap/reporters/default.timeoutcontextlogs.v22.log index 04018664f..67d9da751 100644 --- a/test-tap/reporters/default.timeoutcontextlogs.v22.log +++ b/test-tap/reporters/default.timeoutcontextlogs.v22.log @@ -7,7 +7,7 @@  ✘ Timed out while running tests - 2 tests were pending in a.cjs + 2 tests were pending in a.js ◌ a › a slow ℹ this slow test prints useful debug message just text @@ -24,7 +24,7 @@  ✘ Timed out while running tests - 2 tests were pending in b.cjs + 2 tests were pending in b.js ◌ b › a slow ℹ hello world diff --git a/test-tap/reporters/default.timeoutcontextlogs.v24.log b/test-tap/reporters/default.timeoutcontextlogs.v24.log index 04018664f..67d9da751 100644 --- a/test-tap/reporters/default.timeoutcontextlogs.v24.log +++ b/test-tap/reporters/default.timeoutcontextlogs.v24.log @@ -7,7 +7,7 @@  ✘ Timed out while running tests - 2 tests were pending in a.cjs + 2 tests were pending in a.js ◌ a › a slow ℹ this slow test prints useful debug message just text @@ -24,7 +24,7 @@  ✘ Timed out while running tests - 2 tests were pending in b.cjs + 2 tests were pending in b.js ◌ b › a slow ℹ hello world diff --git a/test-tap/reporters/default.timeoutcontextlogs.v25.log b/test-tap/reporters/default.timeoutcontextlogs.v25.log index 04018664f..67d9da751 100644 --- a/test-tap/reporters/default.timeoutcontextlogs.v25.log +++ b/test-tap/reporters/default.timeoutcontextlogs.v25.log @@ -7,7 +7,7 @@  ✘ Timed out while running tests - 2 tests were pending in a.cjs + 2 tests were pending in a.js ◌ a › a slow ℹ this slow test prints useful debug message just text @@ -24,7 +24,7 @@  ✘ Timed out while running tests - 2 tests were pending in b.cjs + 2 tests were pending in b.js ◌ b › a slow ℹ hello world diff --git a/test-tap/reporters/default.timeoutinmultiplefiles.v22.log b/test-tap/reporters/default.timeoutinmultiplefiles.v22.log index f3a678ae2..8cea846f4 100644 --- a/test-tap/reporters/default.timeoutinmultiplefiles.v22.log +++ b/test-tap/reporters/default.timeoutinmultiplefiles.v22.log @@ -7,7 +7,7 @@  ✘ Timed out while running tests - 2 tests were pending in a.cjs + 2 tests were pending in a.js ◌ a › a slow ◌ a › a slow two @@ -20,7 +20,7 @@  ✘ Timed out while running tests - 3 tests were pending in b.cjs + 3 tests were pending in b.js ◌ b › b slow ◌ b › b slow two diff --git a/test-tap/reporters/default.timeoutinmultiplefiles.v24.log b/test-tap/reporters/default.timeoutinmultiplefiles.v24.log index f3a678ae2..8cea846f4 100644 --- a/test-tap/reporters/default.timeoutinmultiplefiles.v24.log +++ b/test-tap/reporters/default.timeoutinmultiplefiles.v24.log @@ -7,7 +7,7 @@  ✘ Timed out while running tests - 2 tests were pending in a.cjs + 2 tests were pending in a.js ◌ a › a slow ◌ a › a slow two @@ -20,7 +20,7 @@  ✘ Timed out while running tests - 3 tests were pending in b.cjs + 3 tests were pending in b.js ◌ b › b slow ◌ b › b slow two diff --git a/test-tap/reporters/default.timeoutinmultiplefiles.v25.log b/test-tap/reporters/default.timeoutinmultiplefiles.v25.log index f3a678ae2..8cea846f4 100644 --- a/test-tap/reporters/default.timeoutinmultiplefiles.v25.log +++ b/test-tap/reporters/default.timeoutinmultiplefiles.v25.log @@ -7,7 +7,7 @@  ✘ Timed out while running tests - 2 tests were pending in a.cjs + 2 tests were pending in a.js ◌ a › a slow ◌ a › a slow two @@ -20,7 +20,7 @@  ✘ Timed out while running tests - 3 tests were pending in b.cjs + 3 tests were pending in b.js ◌ b › b slow ◌ b › b slow two diff --git a/test-tap/reporters/default.timeoutinsinglefile.v22.log b/test-tap/reporters/default.timeoutinsinglefile.v22.log index a1059e094..ff86d782a 100644 --- a/test-tap/reporters/default.timeoutinsinglefile.v22.log +++ b/test-tap/reporters/default.timeoutinsinglefile.v22.log @@ -7,7 +7,7 @@  ✘ Timed out while running tests - 2 tests were pending in a.cjs + 2 tests were pending in a.js ◌ slow ◌ slow two diff --git a/test-tap/reporters/default.timeoutinsinglefile.v24.log b/test-tap/reporters/default.timeoutinsinglefile.v24.log index a1059e094..ff86d782a 100644 --- a/test-tap/reporters/default.timeoutinsinglefile.v24.log +++ b/test-tap/reporters/default.timeoutinsinglefile.v24.log @@ -7,7 +7,7 @@  ✘ Timed out while running tests - 2 tests were pending in a.cjs + 2 tests were pending in a.js ◌ slow ◌ slow two diff --git a/test-tap/reporters/default.timeoutinsinglefile.v25.log b/test-tap/reporters/default.timeoutinsinglefile.v25.log index a1059e094..ff86d782a 100644 --- a/test-tap/reporters/default.timeoutinsinglefile.v25.log +++ b/test-tap/reporters/default.timeoutinsinglefile.v25.log @@ -7,7 +7,7 @@  ✘ Timed out while running tests - 2 tests were pending in a.cjs + 2 tests were pending in a.js ◌ slow ◌ slow two diff --git a/test-tap/reporters/default.timeoutwithmatch.v22.log b/test-tap/reporters/default.timeoutwithmatch.v22.log index ae7070c95..71399f4ad 100644 --- a/test-tap/reporters/default.timeoutwithmatch.v22.log +++ b/test-tap/reporters/default.timeoutwithmatch.v22.log @@ -5,7 +5,7 @@  ✘ Timed out while running tests - 2 tests were pending in a.cjs + 2 tests were pending in a.js ◌ slow needle ◌ slow three needle diff --git a/test-tap/reporters/default.timeoutwithmatch.v24.log b/test-tap/reporters/default.timeoutwithmatch.v24.log index ae7070c95..71399f4ad 100644 --- a/test-tap/reporters/default.timeoutwithmatch.v24.log +++ b/test-tap/reporters/default.timeoutwithmatch.v24.log @@ -5,7 +5,7 @@  ✘ Timed out while running tests - 2 tests were pending in a.cjs + 2 tests were pending in a.js ◌ slow needle ◌ slow three needle diff --git a/test-tap/reporters/default.timeoutwithmatch.v25.log b/test-tap/reporters/default.timeoutwithmatch.v25.log index ae7070c95..71399f4ad 100644 --- a/test-tap/reporters/default.timeoutwithmatch.v25.log +++ b/test-tap/reporters/default.timeoutwithmatch.v25.log @@ -5,7 +5,7 @@  ✘ Timed out while running tests - 2 tests were pending in a.cjs + 2 tests were pending in a.js ◌ slow needle ◌ slow three needle diff --git a/test-tap/reporters/prefix-title.js b/test-tap/reporters/prefix-title.js index 8751322ac..b0b90e59d 100644 --- a/test-tap/reporters/prefix-title.js +++ b/test-tap/reporters/prefix-title.js @@ -7,59 +7,60 @@ import {chalk} from '../../lib/chalk.js'; import prefixTitle from '../../lib/reporters/prefix-title.js'; const sep = ' ' + chalk.gray.dim(figures.pointerSmall) + ' '; +const extensions = ['js']; test('removes base if found at start of path', t => { - t.equal(prefixTitle(['cjs'], `test${path.sep}`, path.normalize('test/run-status.cjs'), 'title'), `run-status${sep}title`); + t.equal(prefixTitle(extensions, `test${path.sep}`, path.normalize('test/run-status.js'), 'title'), `run-status${sep}title`); t.end(); }); test('does not remove base if found but not at start of path', t => { - t.equal(prefixTitle(['cjs'], path.sep, path.normalize('test/run-status.cjs'), 'title'), `test${sep}run-status${sep}title`); + t.equal(prefixTitle(extensions, path.sep, path.normalize('test/run-status.js'), 'title'), `test${sep}run-status${sep}title`); t.end(); }); test('removes .js extension', t => { - t.equal(prefixTitle(['cjs'], path.sep, 'run-status.cjs', 'title'), `run-status${sep}title`); + t.equal(prefixTitle(extensions, path.sep, 'run-status.js', 'title'), `run-status${sep}title`); t.end(); }); test('does not remove .js from middle of path', t => { - t.equal(prefixTitle(['cjs'], path.sep, 'run-.js-status.cjs', 'title'), `run-.js-status${sep}title`); + t.equal(prefixTitle(extensions, path.sep, 'run-.js-status.js', 'title'), `run-.js-status${sep}title`); t.end(); }); test('removes __tests__ from path', t => { - t.equal(prefixTitle(['cjs'], path.sep, path.normalize('backend/__tests__/run-status.cjs'), 'title'), `backend${sep}run-status${sep}title`); + t.equal(prefixTitle(extensions, path.sep, path.normalize('backend/__tests__/run-status.js'), 'title'), `backend${sep}run-status${sep}title`); t.end(); }); test('removes .spec from file', t => { - t.equal(prefixTitle(['cjs'], path.sep, path.normalize('backend/run-status.spec.cjs'), 'title'), `backend${sep}run-status${sep}title`); + t.equal(prefixTitle(extensions, path.sep, path.normalize('backend/run-status.spec.js'), 'title'), `backend${sep}run-status${sep}title`); t.end(); }); test('retains .spec elsewhere in path', t => { - t.equal(prefixTitle(['cjs'], path.sep, path.normalize('backend.spec/run-status.cjs'), 'title'), `backend.spec${sep}run-status${sep}title`); + t.equal(prefixTitle(extensions, path.sep, path.normalize('backend.spec/run-status.js'), 'title'), `backend.spec${sep}run-status${sep}title`); t.end(); }); test('removes .test from file', t => { - t.equal(prefixTitle(['cjs'], path.sep, path.normalize('backend/run-status.test.cjs'), 'title'), `backend${sep}run-status${sep}title`); - t.equal(prefixTitle(['cjs'], path.sep, path.normalize('backend/run-status.tests.cjs'), 'title'), `backend${sep}run-status.tests${sep}title`); + t.equal(prefixTitle(extensions, path.sep, path.normalize('backend/run-status.test.js'), 'title'), `backend${sep}run-status${sep}title`); + t.equal(prefixTitle(extensions, path.sep, path.normalize('backend/run-status.tests.js'), 'title'), `backend${sep}run-status.tests${sep}title`); t.end(); }); test('retains .test elsewhere in path', t => { - t.equal(prefixTitle(['cjs'], path.sep, path.normalize('backend.test/run-status.cjs'), 'title'), `backend.test${sep}run-status${sep}title`); + t.equal(prefixTitle(extensions, path.sep, path.normalize('backend.test/run-status.js'), 'title'), `backend.test${sep}run-status${sep}title`); t.end(); }); test('removes test- from file', t => { - t.equal(prefixTitle(['cjs'], path.sep, path.normalize('backend/test-run-status.cjs'), 'title'), `backend${sep}run-status${sep}title`); + t.equal(prefixTitle(extensions, path.sep, path.normalize('backend/test-run-status.js'), 'title'), `backend${sep}run-status${sep}title`); t.end(); }); test('retains test- elsewhere in path', t => { - t.equal(prefixTitle(['cjs'], path.sep, path.normalize('backend-test/run-status.cjs'), 'title'), `backend-test${sep}run-status${sep}title`); + t.equal(prefixTitle(extensions, path.sep, path.normalize('backend-test/run-status.js'), 'title'), `backend-test${sep}run-status${sep}title`); t.end(); }); diff --git a/test-tap/reporters/tap.edgecases.v22.log b/test-tap/reporters/tap.edgecases.v22.log index ae0f6cb72..c0d50ec38 100644 --- a/test-tap/reporters/tap.edgecases.v22.log +++ b/test-tap/reporters/tap.edgecases.v22.log @@ -1,15 +1,15 @@ TAP version 13 ---tty-stream-chunk-separator -not ok 1 - ~/test-tap/fixture/report/edgecases/ast-syntax-error.cjs:3 +not ok 1 - ~/test-tap/fixture/report/edgecases/ast-syntax-error.js:3 --- name: SyntaxError message: Unexpected token 'do' at: 'const fn = do {' ... ---tty-stream-chunk-separator -not ok 2 - ast-syntax-error.cjs exited with a non-zero exit code: 1 +not ok 2 - ast-syntax-error.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator -not ok 3 - No tests found in ava-import-no-test-declaration.cjs +not ok 3 - No tests found in ava-import-no-test-declaration.js ---tty-stream-chunk-separator not ok 4 - TypeError: test is not a function --- @@ -17,21 +17,21 @@ not ok 4 - TypeError: test is not a function message: test is not a function at: >- Object. - (~/test-tap/fixture/report/edgecases/import-and-use-test-member.cjs:3:1) + (~/test-tap/fixture/report/edgecases/import-and-use-test-member.js:3:1) ... ---tty-stream-chunk-separator -not ok 5 - import-and-use-test-member.cjs exited with a non-zero exit code: 1 +not ok 5 - import-and-use-test-member.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator -not ok 6 - No tests found in no-ava-import.cjs, make sure to import "ava" at the top of your test file +not ok 6 - No tests found in no-ava-import.js, make sure to import "ava" at the top of your test file ---tty-stream-chunk-separator not ok 7 - Error: throws --- name: Error message: throws - at: 'Object. (~/test-tap/fixture/report/edgecases/throws.cjs:1:7)' + at: 'Object. (~/test-tap/fixture/report/edgecases/throws.js:1:7)' ... ---tty-stream-chunk-separator -not ok 8 - throws.cjs exited with a non-zero exit code: 1 +not ok 8 - throws.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator 1..0 diff --git a/test-tap/reporters/tap.edgecases.v24.log b/test-tap/reporters/tap.edgecases.v24.log index ae0f6cb72..c0d50ec38 100644 --- a/test-tap/reporters/tap.edgecases.v24.log +++ b/test-tap/reporters/tap.edgecases.v24.log @@ -1,15 +1,15 @@ TAP version 13 ---tty-stream-chunk-separator -not ok 1 - ~/test-tap/fixture/report/edgecases/ast-syntax-error.cjs:3 +not ok 1 - ~/test-tap/fixture/report/edgecases/ast-syntax-error.js:3 --- name: SyntaxError message: Unexpected token 'do' at: 'const fn = do {' ... ---tty-stream-chunk-separator -not ok 2 - ast-syntax-error.cjs exited with a non-zero exit code: 1 +not ok 2 - ast-syntax-error.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator -not ok 3 - No tests found in ava-import-no-test-declaration.cjs +not ok 3 - No tests found in ava-import-no-test-declaration.js ---tty-stream-chunk-separator not ok 4 - TypeError: test is not a function --- @@ -17,21 +17,21 @@ not ok 4 - TypeError: test is not a function message: test is not a function at: >- Object. - (~/test-tap/fixture/report/edgecases/import-and-use-test-member.cjs:3:1) + (~/test-tap/fixture/report/edgecases/import-and-use-test-member.js:3:1) ... ---tty-stream-chunk-separator -not ok 5 - import-and-use-test-member.cjs exited with a non-zero exit code: 1 +not ok 5 - import-and-use-test-member.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator -not ok 6 - No tests found in no-ava-import.cjs, make sure to import "ava" at the top of your test file +not ok 6 - No tests found in no-ava-import.js, make sure to import "ava" at the top of your test file ---tty-stream-chunk-separator not ok 7 - Error: throws --- name: Error message: throws - at: 'Object. (~/test-tap/fixture/report/edgecases/throws.cjs:1:7)' + at: 'Object. (~/test-tap/fixture/report/edgecases/throws.js:1:7)' ... ---tty-stream-chunk-separator -not ok 8 - throws.cjs exited with a non-zero exit code: 1 +not ok 8 - throws.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator 1..0 diff --git a/test-tap/reporters/tap.edgecases.v25.log b/test-tap/reporters/tap.edgecases.v25.log index ae0f6cb72..8cd3b8fa8 100644 --- a/test-tap/reporters/tap.edgecases.v25.log +++ b/test-tap/reporters/tap.edgecases.v25.log @@ -1,37 +1,35 @@ TAP version 13 ---tty-stream-chunk-separator -not ok 1 - ~/test-tap/fixture/report/edgecases/ast-syntax-error.cjs:3 +not ok 1 - SyntaxError: Unexpected token 'do' --- name: SyntaxError message: Unexpected token 'do' - at: 'const fn = do {' + at: 'compileSourceTextModule (node:internal/modules/esm/utils:354:16)' ... ---tty-stream-chunk-separator -not ok 2 - ast-syntax-error.cjs exited with a non-zero exit code: 1 +not ok 2 - ast-syntax-error.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator -not ok 3 - No tests found in ava-import-no-test-declaration.cjs +not ok 3 - No tests found in ava-import-no-test-declaration.js ---tty-stream-chunk-separator not ok 4 - TypeError: test is not a function --- name: TypeError message: test is not a function - at: >- - Object. - (~/test-tap/fixture/report/edgecases/import-and-use-test-member.cjs:3:1) + at: '/test-tap/fixture/report/edgecases/import-and-use-test-member.js:3:1' ... ---tty-stream-chunk-separator -not ok 5 - import-and-use-test-member.cjs exited with a non-zero exit code: 1 +not ok 5 - import-and-use-test-member.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator -not ok 6 - No tests found in no-ava-import.cjs, make sure to import "ava" at the top of your test file +not ok 6 - No tests found in no-ava-import.js, make sure to import "ava" at the top of your test file ---tty-stream-chunk-separator not ok 7 - Error: throws --- name: Error message: throws - at: 'Object. (~/test-tap/fixture/report/edgecases/throws.cjs:1:7)' + at: 'Object. (~/test-tap/fixture/report/edgecases/throws.js:1:7)' ... ---tty-stream-chunk-separator -not ok 8 - throws.cjs exited with a non-zero exit code: 1 +not ok 8 - throws.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator 1..0 diff --git a/test-tap/reporters/tap.failfast2.v22.log b/test-tap/reporters/tap.failfast2.v22.log index 25173088c..5f93b2d15 100644 --- a/test-tap/reporters/tap.failfast2.v22.log +++ b/test-tap/reporters/tap.failfast2.v22.log @@ -8,7 +8,7 @@ not ok 1 - a › fails at: 'ExecutionContext.fail (/lib/assert.js:288:15)' ... ---tty-stream-chunk-separator -# 1 test remaining in a.cjs +# 1 test remaining in a.js ---tty-stream-chunk-separator 1..2 diff --git a/test-tap/reporters/tap.failfast2.v24.log b/test-tap/reporters/tap.failfast2.v24.log index 25173088c..5f93b2d15 100644 --- a/test-tap/reporters/tap.failfast2.v24.log +++ b/test-tap/reporters/tap.failfast2.v24.log @@ -8,7 +8,7 @@ not ok 1 - a › fails at: 'ExecutionContext.fail (/lib/assert.js:288:15)' ... ---tty-stream-chunk-separator -# 1 test remaining in a.cjs +# 1 test remaining in a.js ---tty-stream-chunk-separator 1..2 diff --git a/test-tap/reporters/tap.failfast2.v25.log b/test-tap/reporters/tap.failfast2.v25.log index 25173088c..5f93b2d15 100644 --- a/test-tap/reporters/tap.failfast2.v25.log +++ b/test-tap/reporters/tap.failfast2.v25.log @@ -8,7 +8,7 @@ not ok 1 - a › fails at: 'ExecutionContext.fail (/lib/assert.js:288:15)' ... ---tty-stream-chunk-separator -# 1 test remaining in a.cjs +# 1 test remaining in a.js ---tty-stream-chunk-separator 1..2 diff --git a/test-tap/reporters/tap.js b/test-tap/reporters/tap.js index 4935d8520..9494121db 100644 --- a/test-tap/reporters/tap.js +++ b/test-tap/reporters/tap.js @@ -21,7 +21,7 @@ test(async t => { sanitizers: [...sanitizers, report.sanitizers.cwd, report.sanitizers.experimentalWarning, report.sanitizers.posix, report.sanitizers.tapLoaders, report.sanitizers.timers], }); const reporter = new TapReporter({ - extensions: ['cjs'], + extensions: ['js'], projectDir: report.projectDir(type), reportStream: tty, stdStream: tty, diff --git a/test-tap/reporters/tap.regular.v22.log b/test-tap/reporters/tap.regular.v22.log index f686271a1..e573737e3 100644 --- a/test-tap/reporters/tap.regular.v22.log +++ b/test-tap/reporters/tap.regular.v22.log @@ -4,10 +4,10 @@ not ok 1 - TypeError: test.serial.test is not a function --- name: TypeError message: test.serial.test is not a function - at: 'Object. (~/test-tap/fixture/report/regular/bad-test-chain.cjs:3:13)' + at: 'Object. (~/test-tap/fixture/report/regular/bad-test-chain.js:3:13)' ... ---tty-stream-chunk-separator -not ok 2 - bad-test-chain.cjs exited with a non-zero exit code: 1 +not ok 2 - bad-test-chain.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator not ok 3 - nested-objects › format with max depth 4 --- @@ -158,7 +158,7 @@ not ok 16 - traces-in-t-throws › throws } 'Expected instance of:': 'Function TypeError {}' message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8)' + at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 17 - traces-in-t-throws › notThrows @@ -171,7 +171,7 @@ not ok 17 - traces-in-t-throws › notThrows message: 'uh-oh', } message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8)' + at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 18 - traces-in-t-throws › notThrowsAsync @@ -184,7 +184,7 @@ not ok 18 - traces-in-t-throws › notThrowsAsync message: 'uh-oh', } message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8)' + at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 19 - traces-in-t-throws › throwsAsync @@ -197,7 +197,7 @@ not ok 19 - traces-in-t-throws › throwsAsync message: 'uh-oh', } message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8)' + at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 20 - traces-in-t-throws › throwsAsync different error @@ -213,7 +213,7 @@ not ok 20 - traces-in-t-throws › throwsAsync different error message: '' at: >- returnRejectedPromise - (~/test-tap/fixture/report/regular/traces-in-t-throws.cjs:8:24) + (~/test-tap/fixture/report/regular/traces-in-t-throws.js:8:24) ... ---tty-stream-chunk-separator ok 21 - uncaught-exception › passes @@ -224,10 +224,10 @@ not ok 22 - Error: Can’t catch me message: Can’t catch me at: >- Immediate. - (~/test-tap/fixture/report/regular/uncaught-exception.cjs:5:9) + (~/test-tap/fixture/report/regular/uncaught-exception.js:5:9) ... ---tty-stream-chunk-separator -not ok 23 - uncaught-exception.cjs exited with a non-zero exit code: 1 +not ok 23 - uncaught-exception.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator ok 24 - unhandled-rejection › passes ---tty-stream-chunk-separator @@ -237,7 +237,7 @@ not ok 26 - Error: Can’t catch me --- name: Error message: Can’t catch me - at: 'passes (~/test-tap/fixture/report/regular/unhandled-rejection.cjs:4:17)' + at: 'passes (~/test-tap/fixture/report/regular/unhandled-rejection.js:4:17)' ... ---tty-stream-chunk-separator not ok 27 - unhandled-rejection @@ -246,7 +246,7 @@ not ok 27 - unhandled-rejection formatted: 'null' ... ---tty-stream-chunk-separator -not ok 28 - unhandled-rejection.cjs exited with a non-zero exit code: 1 +not ok 28 - unhandled-rejection.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator 1..21 diff --git a/test-tap/reporters/tap.regular.v24.log b/test-tap/reporters/tap.regular.v24.log index f686271a1..e573737e3 100644 --- a/test-tap/reporters/tap.regular.v24.log +++ b/test-tap/reporters/tap.regular.v24.log @@ -4,10 +4,10 @@ not ok 1 - TypeError: test.serial.test is not a function --- name: TypeError message: test.serial.test is not a function - at: 'Object. (~/test-tap/fixture/report/regular/bad-test-chain.cjs:3:13)' + at: 'Object. (~/test-tap/fixture/report/regular/bad-test-chain.js:3:13)' ... ---tty-stream-chunk-separator -not ok 2 - bad-test-chain.cjs exited with a non-zero exit code: 1 +not ok 2 - bad-test-chain.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator not ok 3 - nested-objects › format with max depth 4 --- @@ -158,7 +158,7 @@ not ok 16 - traces-in-t-throws › throws } 'Expected instance of:': 'Function TypeError {}' message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8)' + at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 17 - traces-in-t-throws › notThrows @@ -171,7 +171,7 @@ not ok 17 - traces-in-t-throws › notThrows message: 'uh-oh', } message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8)' + at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 18 - traces-in-t-throws › notThrowsAsync @@ -184,7 +184,7 @@ not ok 18 - traces-in-t-throws › notThrowsAsync message: 'uh-oh', } message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8)' + at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 19 - traces-in-t-throws › throwsAsync @@ -197,7 +197,7 @@ not ok 19 - traces-in-t-throws › throwsAsync message: 'uh-oh', } message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8)' + at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 20 - traces-in-t-throws › throwsAsync different error @@ -213,7 +213,7 @@ not ok 20 - traces-in-t-throws › throwsAsync different error message: '' at: >- returnRejectedPromise - (~/test-tap/fixture/report/regular/traces-in-t-throws.cjs:8:24) + (~/test-tap/fixture/report/regular/traces-in-t-throws.js:8:24) ... ---tty-stream-chunk-separator ok 21 - uncaught-exception › passes @@ -224,10 +224,10 @@ not ok 22 - Error: Can’t catch me message: Can’t catch me at: >- Immediate. - (~/test-tap/fixture/report/regular/uncaught-exception.cjs:5:9) + (~/test-tap/fixture/report/regular/uncaught-exception.js:5:9) ... ---tty-stream-chunk-separator -not ok 23 - uncaught-exception.cjs exited with a non-zero exit code: 1 +not ok 23 - uncaught-exception.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator ok 24 - unhandled-rejection › passes ---tty-stream-chunk-separator @@ -237,7 +237,7 @@ not ok 26 - Error: Can’t catch me --- name: Error message: Can’t catch me - at: 'passes (~/test-tap/fixture/report/regular/unhandled-rejection.cjs:4:17)' + at: 'passes (~/test-tap/fixture/report/regular/unhandled-rejection.js:4:17)' ... ---tty-stream-chunk-separator not ok 27 - unhandled-rejection @@ -246,7 +246,7 @@ not ok 27 - unhandled-rejection formatted: 'null' ... ---tty-stream-chunk-separator -not ok 28 - unhandled-rejection.cjs exited with a non-zero exit code: 1 +not ok 28 - unhandled-rejection.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator 1..21 diff --git a/test-tap/reporters/tap.regular.v25.log b/test-tap/reporters/tap.regular.v25.log index f686271a1..2f7956df9 100644 --- a/test-tap/reporters/tap.regular.v25.log +++ b/test-tap/reporters/tap.regular.v25.log @@ -4,10 +4,10 @@ not ok 1 - TypeError: test.serial.test is not a function --- name: TypeError message: test.serial.test is not a function - at: 'Object. (~/test-tap/fixture/report/regular/bad-test-chain.cjs:3:13)' + at: '/test-tap/fixture/report/regular/bad-test-chain.js:3:13' ... ---tty-stream-chunk-separator -not ok 2 - bad-test-chain.cjs exited with a non-zero exit code: 1 +not ok 2 - bad-test-chain.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator not ok 3 - nested-objects › format with max depth 4 --- @@ -158,7 +158,7 @@ not ok 16 - traces-in-t-throws › throws } 'Expected instance of:': 'Function TypeError {}' message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8)' + at: 'throwError (/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 17 - traces-in-t-throws › notThrows @@ -171,7 +171,7 @@ not ok 17 - traces-in-t-throws › notThrows message: 'uh-oh', } message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8)' + at: 'throwError (/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 18 - traces-in-t-throws › notThrowsAsync @@ -184,7 +184,7 @@ not ok 18 - traces-in-t-throws › notThrowsAsync message: 'uh-oh', } message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8)' + at: 'throwError (/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 19 - traces-in-t-throws › throwsAsync @@ -197,7 +197,7 @@ not ok 19 - traces-in-t-throws › throwsAsync message: 'uh-oh', } message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.cjs:4:8)' + at: 'throwError (/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 20 - traces-in-t-throws › throwsAsync different error @@ -213,7 +213,7 @@ not ok 20 - traces-in-t-throws › throwsAsync different error message: '' at: >- returnRejectedPromise - (~/test-tap/fixture/report/regular/traces-in-t-throws.cjs:8:24) + (/test-tap/fixture/report/regular/traces-in-t-throws.js:8:24) ... ---tty-stream-chunk-separator ok 21 - uncaught-exception › passes @@ -224,10 +224,10 @@ not ok 22 - Error: Can’t catch me message: Can’t catch me at: >- Immediate. - (~/test-tap/fixture/report/regular/uncaught-exception.cjs:5:9) + (/test-tap/fixture/report/regular/uncaught-exception.js:5:9) ... ---tty-stream-chunk-separator -not ok 23 - uncaught-exception.cjs exited with a non-zero exit code: 1 +not ok 23 - uncaught-exception.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator ok 24 - unhandled-rejection › passes ---tty-stream-chunk-separator @@ -237,7 +237,7 @@ not ok 26 - Error: Can’t catch me --- name: Error message: Can’t catch me - at: 'passes (~/test-tap/fixture/report/regular/unhandled-rejection.cjs:4:17)' + at: 'passes (/test-tap/fixture/report/regular/unhandled-rejection.js:4:17)' ... ---tty-stream-chunk-separator not ok 27 - unhandled-rejection @@ -246,7 +246,7 @@ not ok 27 - unhandled-rejection formatted: 'null' ... ---tty-stream-chunk-separator -not ok 28 - unhandled-rejection.cjs exited with a non-zero exit code: 1 +not ok 28 - unhandled-rejection.js exited with a non-zero exit code: 1 ---tty-stream-chunk-separator 1..21 diff --git a/test-tap/runner.js b/test-tap/runner.js index c36458915..72d03832c 100644 --- a/test-tap/runner.js +++ b/test-tap/runner.js @@ -3,7 +3,7 @@ import {setTimeout as delay} from 'node:timers/promises'; import {test} from 'tap'; import Runner from '../lib/runner.js'; -import {set as setOptions} from '../lib/worker/options.cjs'; +import {set as setOptions} from '../lib/worker/options.js'; setOptions({}); diff --git a/test-tap/test-try-commit.js b/test-tap/test-try-commit.js index 0bda4db78..145f74ee7 100644 --- a/test-tap/test-try-commit.js +++ b/test-tap/test-try-commit.js @@ -3,7 +3,7 @@ import {setTimeout as delay} from 'node:timers/promises'; import {test} from 'tap'; import ContextRef from '../lib/context-ref.js'; -import {set as setOptions} from '../lib/worker/options.cjs'; +import {set as setOptions} from '../lib/worker/options.js'; import {newAva} from './helper/ava-test.js'; diff --git a/test-tap/test.js b/test-tap/test.js index 860290282..929d4f08d 100644 --- a/test-tap/test.js +++ b/test-tap/test.js @@ -9,7 +9,7 @@ import {test} from 'tap'; import './helper/chalk0.js'; // eslint-disable-line import-x/no-unassigned-import import * as snapshotManager from '../lib/snapshot-manager.js'; import Test from '../lib/test.js'; -import {set as setOptions} from '../lib/worker/options.cjs'; +import {set as setOptions} from '../lib/worker/options.js'; import {ava} from './helper/ava-test.js'; @@ -472,7 +472,7 @@ test('assertions are bound', t => test('snapshot assertion can be skipped', t => { const projectDir = fileURLToPath(new URL('fixture', import.meta.url)); const manager = snapshotManager.load({ - file: path.join(projectDir, 'assert.cjs'), + file: path.join(projectDir, 'assert.js'), projectDir, fixedLocation: null, recordNewSnapshots: true, @@ -498,7 +498,7 @@ test('snapshot assertion can be skipped', t => { test('snapshot assertions call options.skipSnapshot when skipped', async t => { const projectDir = fileURLToPath(new URL('fixture', import.meta.url)); const manager = snapshotManager.load({ - file: path.join(projectDir, 'assert.cjs'), + file: path.join(projectDir, 'assert.js'), projectDir, fixedLocation: null, updating: false, diff --git a/test-tap/try-snapshot.js b/test-tap/try-snapshot.js index e5fca1d77..b2a2d9657 100644 --- a/test-tap/try-snapshot.js +++ b/test-tap/try-snapshot.js @@ -7,7 +7,7 @@ import './helper/chalk0.js'; // eslint-disable-line import-x/no-unassigned-impor import ContextRef from '../lib/context-ref.js'; import * as snapshotManager from '../lib/snapshot-manager.js'; import Test from '../lib/test.js'; -import {set as setOptions} from '../lib/worker/options.cjs'; +import {set as setOptions} from '../lib/worker/options.js'; setOptions({}); @@ -33,7 +33,7 @@ test(async t => { const projectDir = fileURLToPath(new URL('fixture', import.meta.url)); const manager = snapshotManager.load({ - file: path.join(projectDir, 'try-snapshot.cjs'), + file: path.join(projectDir, 'try-snapshot.js'), projectDir, fixedLocation: null, updating, diff --git a/test-types/import-in-cts/assertions-as-type-guards.cts b/test-types/import-in-cts/assertions-as-type-guards.cts deleted file mode 100644 index fd9a8615c..000000000 --- a/test-types/import-in-cts/assertions-as-type-guards.cts +++ /dev/null @@ -1,62 +0,0 @@ -import test from '../../entrypoints/main.cjs'; -import {expectType} from 'tsd'; - -type Expected = {foo: 'bar'}; -const expected: Expected = {foo: 'bar'}; - -test('assert', t => { - const actual = expected as Expected | undefined; - if (t.assert(actual)) { - expectType(actual); - } -}); - -test('deepEqual', t => { - const actual: unknown = {}; - if (t.deepEqual(actual, expected)) { - expectType(actual); - } -}); - -test('like', t => { - const actual: unknown = {}; - if (t.like(actual, expected)) { - expectType(actual); - } -}); - -test('is', t => { - const actual: unknown = 2; - if (t.is(actual, 3 as const)) { - expectType<3>(actual); - } -}); - -test('false', t => { - const actual: unknown = true; - if (t.false(actual)) { - expectType(actual); - } -}); - -test('falsy', t => { - type Actual = Expected | undefined | false | 0 | '' | 0n; - const actual = undefined as Actual; - if (t.falsy(actual)) { - expectType>(actual); - } -}); - -test('true', t => { - const actual: unknown = false; - if (t.true(actual)) { - expectType(actual); - } -}); - -test('truthy', t => { - const actual = expected as Expected | undefined; - if (t.truthy(actual)) { - expectType(actual); - } -}); diff --git a/test-types/import-in-cts/conditional-chains.cts b/test-types/import-in-cts/conditional-chains.cts deleted file mode 100644 index 58bef317e..000000000 --- a/test-types/import-in-cts/conditional-chains.cts +++ /dev/null @@ -1,14 +0,0 @@ -/* eslint-disable @typescript-eslint/no-empty-function */ -import anyTest from '../../entrypoints/main.cjs'; - -anyTest.skipIf(true).beforeEach(() => {}); -anyTest.runIf(false).afterEach(() => {}); -anyTest.skipIf(true).serial.before(() => {}); -anyTest.serial.runIf(true).after(() => {}); - -anyTest.skipIf(true).todo('skipIf todo should be allowed'); -anyTest.runIf(false).todo('runIf todo should be allowed'); -anyTest.skipIf(true).serial.todo('skipIf serial todo should be allowed'); -anyTest.runIf(false).serial.todo('runIf serial todo should be allowed'); -anyTest.serial.skipIf(true).todo('serial skipIf todo should be allowed'); -anyTest.serial.runIf(false).todo('serial runIf todo should be allowed'); diff --git a/test-types/import-in-cts/context.cts b/test-types/import-in-cts/context.cts deleted file mode 100644 index f0423f1bb..000000000 --- a/test-types/import-in-cts/context.cts +++ /dev/null @@ -1,33 +0,0 @@ -/* eslint-disable @typescript-eslint/no-empty-function */ -import anyTest, {ExecutionContext, TestFn} from '../../entrypoints/main.cjs'; -import {expectError, expectType} from 'tsd'; - -interface Context { - foo: string; -} - -const test = anyTest as TestFn; - -const macro = test.macro((t, _expected: number) => { - expectType(t.context.foo); -}); - -test.beforeEach(t => { - expectType(t.context); -}); - -// @ts-expect-error TS2769 -expectError(test('foo is bar', macro, 'bar')); // eslint-disable-line @typescript-eslint/no-confusing-void-expression - -anyTest('default context is unknown', t => { - expectType(t.context); -}); - -// See https://github.com/avajs/ava/issues/2253 -interface Covariant extends Context { - bar: number; -} - -const test2 = anyTest as TestFn; -const hook = (_t: ExecutionContext) => {}; -test2.beforeEach(hook); diff --git a/test-types/import-in-cts/deep-equal.cts b/test-types/import-in-cts/deep-equal.cts deleted file mode 100644 index 2e9369243..000000000 --- a/test-types/import-in-cts/deep-equal.cts +++ /dev/null @@ -1,29 +0,0 @@ -import test from '../../entrypoints/main.cjs'; -import {expectType} from 'tsd'; - -test('actual extends expected', t => { - type Expected = {foo: [1, 2, 3]}; - const expected: Expected = {foo: [1, 2, 3]}; - const actual = {foo: [1, 2, 3]}; - if (t.deepEqual(actual, expected)) { - expectType(actual); - } -}); - -test('expected extends actual', t => { - type Expected = {foo: Array}; - type Actual = {foo: number[]}; - const expected: Expected = {foo: [1, 2, 3]}; - const actual: Actual = {foo: [1, 2, 3]}; - if (t.deepEqual(actual, expected)) { - expectType(expected); - } -}); - -test('neither extends the each other', t => { - type Expected = {readonly foo: readonly [1, 2, 3]}; - type Actual = {foo: number[]}; - const expected: Expected = {foo: [1, 2, 3]}; - const actual: Actual = {foo: [1, 2, 3]}; - t.deepEqual(actual, expected); -}); diff --git a/test-types/import-in-cts/implementation-result.cts b/test-types/import-in-cts/implementation-result.cts deleted file mode 100644 index 064eb8384..000000000 --- a/test-types/import-in-cts/implementation-result.cts +++ /dev/null @@ -1,20 +0,0 @@ -/* eslint-disable @typescript-eslint/no-empty-function */ -import test from '../../entrypoints/main.cjs'; - -test.after('return anything else', _t => ({ - foo: 'bar', - subscribe() {}, - then() {}, // eslint-disable-line unicorn/no-thenable -})); - -test('return a promise-like', _t => ({ - then(resolve) { // eslint-disable-line unicorn/no-thenable - resolve?.(); // eslint-disable-line @typescript-eslint/no-floating-promises - }, -})); - -test('return a subscribable', _t => ({ - subscribe({complete}) { - complete(); - }, -})); diff --git a/test-types/import-in-cts/like.cts b/test-types/import-in-cts/like.cts deleted file mode 100644 index c3962bec1..000000000 --- a/test-types/import-in-cts/like.cts +++ /dev/null @@ -1,25 +0,0 @@ -import test from '../../entrypoints/main.cjs'; - -test('like', t => { - t.like({ - map: new Map([['foo', 'bar']]), - nested: { - baz: 'thud', - qux: 'quux', - }, - }, { - map: new Map([['foo', 'bar']]), - nested: { - baz: 'thud', - }, - }); - - type Foo = { - foo?: 'foo'; - bar?: 'bar'; - }; - - const foo: Foo = {bar: 'bar'}; - const {foo: _, ...expected} = foo; - t.like(expected, {bar: 'bar'}); -}); diff --git a/test-types/import-in-cts/macros.cts b/test-types/import-in-cts/macros.cts deleted file mode 100644 index 949bdbf61..000000000 --- a/test-types/import-in-cts/macros.cts +++ /dev/null @@ -1,126 +0,0 @@ -/* eslint-disable no-lone-blocks */ -import test, {ExecutionContext} from '../../entrypoints/main.cjs'; -import {expectType} from 'tsd'; - -// Typed arguments through generics. -{ - const hasLength = test.macro<[string, number]>((t, input, expected) => { - expectType(input); - expectType(expected); - // @ts-expect-error TS2345 - t.is(input, expected); - }); - - test('bar has length 3', hasLength, 'bar', 3); -} - -{ - const hasLength = test.macro<[string, number]>({ - exec(t, input, expected) { - expectType(input); - expectType(expected); - // @ts-expect-error TS2345 - t.is(input, expected); - }, - title(_providedTitle, input, expected) { - expectType(input); - expectType(expected); - return 'title'; - }, - }); - - test('bar has length 3', hasLength, 'bar', 3); -} - -// Typed arguments in execution function. -{ - const hasLength = test.macro((t, input: string, expected: number) => { - // @ts-expect-error TS2345 - t.is(input, expected); - }); - - test('bar has length 3', hasLength, 'bar', 3); -} - -{ - const hasLength = test.macro({ - exec(t, input: string, expected: number) { - // @ts-expect-error TS2345 - t.is(input, expected); - }, - title(_providedTitle, input: string, expected: number) { - expectType(input); - expectType(expected); - return 'title'; - }, - }); - - test('bar has length 3', hasLength, 'bar', 3); -} - -// Untyped arguments -{ - const hasLength = test.macro((t, input, expected) => { - expectType(input); - expectType(expected); - t.is(input, expected); - }); - - test('bar has length 3', hasLength, 'bar', 3); -} - -// Usable without title, even if the macro lacks a title function. -{ - const hasLength = test.macro<[string, number]>((t, input, expected) => { - // @ts-expect-error TS2345 - t.is(input, expected); - }); - - test(hasLength, 'bar', 3); -} - -// No arguments -{ - const pass = test.macro<[]>({ // eslint-disable-line @typescript-eslint/ban-types - exec(_t, ...args) { - expectType<[]>(args); // eslint-disable-line @typescript-eslint/ban-types - }, - title(providedTitle, ...args) { - expectType(providedTitle); - expectType<[]>(args); // eslint-disable-line @typescript-eslint/ban-types - return ''; - }, - }); - - test(pass); -} - -// Without test.macro() -{ - const hasLength = (t: ExecutionContext, input: string, expected: number) => { - t.is(input.length, expected); - }; - - test('bar has length 3', hasLength, 'bar', 3); -} - -// Inline function with explicit argument types. -test('has length 3', (t: ExecutionContext, input: string, expected: number) => { - // @ts-expect-error TS2345 - t.is(input, expected); -}, 'bar', 3); - -// Completely inferred arguments for inline functions. -test('has length 3', (t, input, expected) => { - expectType(input); - expectType(expected); - // @ts-expect-error TS2345 - t.is(input, expected); -}, 'foo', 3); - -test.skip('skip', (t, input, expected) => { - expectType(input); - expectType(expected); - // @ts-expect-error TS2345 - t.is(input, expected); -}, 'foo', 3); diff --git a/test-types/import-in-cts/plugin.cts b/test-types/import-in-cts/plugin.cts deleted file mode 100644 index f6ad0f19b..000000000 --- a/test-types/import-in-cts/plugin.cts +++ /dev/null @@ -1,18 +0,0 @@ -import plugin from 'ava/plugin'; -import {expectType} from 'tsd'; - -expectType(plugin.registerSharedWorker({filename: '', supportedProtocols: ['ava-4']})); - -const factory: plugin.SharedWorker.Factory = ({negotiateProtocol}) => { - const protocol = negotiateProtocol(['ava-4']); - expectType(protocol); - - (async () => { - for await (const w of protocol.testWorkers()) { - expectType<() => Promise>(w.teardown(() => {})); // eslint-disable-line @typescript-eslint/no-empty-function - expectType<() => Promise>(w.teardown(async () => {})); // eslint-disable-line @typescript-eslint/no-empty-function - } - })(); -}; - -export default factory; diff --git a/test-types/import-in-cts/snapshot.cts b/test-types/import-in-cts/snapshot.cts deleted file mode 100644 index 7bfd5681c..000000000 --- a/test-types/import-in-cts/snapshot.cts +++ /dev/null @@ -1,16 +0,0 @@ -import test from '../../entrypoints/main.cjs'; -import {expectError} from 'tsd'; - -test('snapshot', t => { - t.snapshot({foo: 'bar'}); - t.snapshot(null, 'a snapshot with a message'); - // @ts-expect-error TS2345 - expectError(t.snapshot('hello world', null)); // eslint-disable-line @typescript-eslint/no-confusing-void-expression -}); - -test('snapshot.skip', t => { - t.snapshot.skip({foo: 'bar'}); - t.snapshot.skip(null, 'a snapshot with a message'); - // @ts-expect-error TS2345 - expectError(t.snapshot.skip('hello world', null)); // eslint-disable-line @typescript-eslint/no-confusing-void-expression -}); diff --git a/test-types/import-in-cts/teardown.cts b/test-types/import-in-cts/teardown.cts deleted file mode 100644 index 16ba129b5..000000000 --- a/test-types/import-in-cts/teardown.cts +++ /dev/null @@ -1,6 +0,0 @@ -import test from '../../entrypoints/main.cjs'; - -test('test', t => { - t.teardown(() => {}); // eslint-disable-line @typescript-eslint/no-empty-function - t.teardown(async () => {}); // eslint-disable-line @typescript-eslint/no-empty-function -}); diff --git a/test-types/import-in-cts/throws.cts b/test-types/import-in-cts/throws.cts deleted file mode 100644 index 3cc8623cc..000000000 --- a/test-types/import-in-cts/throws.cts +++ /dev/null @@ -1,49 +0,0 @@ -/* eslint-disable @typescript-eslint/no-empty-function */ -import test from '../../entrypoints/main.cjs'; -import {expectError, expectType} from 'tsd'; - -class CustomError extends Error { - foo: string; - - constructor() { - super(); - this.foo = 'foo'; - } -} - -test('throws', t => { - const error1 = t.throws(() => {}); - expectType(error1); - const error2: CustomError = t.throws(() => {}); - expectType(error2); - expectType(t.throws(() => {})); - const error3 = t.throws(() => {}, {instanceOf: CustomError}); - expectType(error3); - const error4 = t.throws(() => {}, {is: new CustomError()}); - expectType(error4); - const error5 = t.throws(() => {}, {instanceOf: CustomError, is: new CustomError()}); - expectType(error5); - const error6 = t.throws(() => { throw 'foo' }, {any: true}); - expectType(error6); - // @ts-expect-error TS2769 - expectError(t.throws(() => { throw 'foo' }, {instanceOf: String, is: 'foo'})); -}); - -test('throwsAsync', async t => { - const error1 = await t.throwsAsync(async () => {}); - expectType(error1); - expectType(await t.throwsAsync(async () => {})); - const error2 = await t.throwsAsync(Promise.reject()); - expectType(error2); - expectType(await t.throwsAsync(Promise.reject())); - const error3 = await t.throwsAsync(async () => {}, {instanceOf: CustomError}); - expectType(error3); - const error4 = await t.throwsAsync(async () => {}, {is: new CustomError()}); - expectType(error4); - const error5 = await t.throwsAsync(async () => {}, {instanceOf: CustomError, is: new CustomError()}); - expectType(error5); - const error6 = await t.throwsAsync(async () => { throw 'foo' }, {any: true}); - expectType(error6); - // @ts-expect-error TS2769 - expectError(t.throwsAsync(async () => { throw 'foo' }, {instanceOf: String, is: 'foo'})); -}); diff --git a/test-types/import-in-cts/timeout.cts b/test-types/import-in-cts/timeout.cts deleted file mode 100644 index 40770e9dc..000000000 --- a/test-types/import-in-cts/timeout.cts +++ /dev/null @@ -1,6 +0,0 @@ -import test from '../../entrypoints/main.cjs'; - -test('test', t => { - t.timeout(100); - t.timeout.clear(); -}); diff --git a/test-types/import-in-cts/try-commit.cts b/test-types/import-in-cts/try-commit.cts deleted file mode 100644 index 869df0101..000000000 --- a/test-types/import-in-cts/try-commit.cts +++ /dev/null @@ -1,67 +0,0 @@ -import test, {ExecutionContext} from '../../entrypoints/main.cjs'; -import {expectType} from 'tsd'; - -test('attempt', async t => { - const attempt = await t.try( - (u, a, b) => { - expectType(u); - expectType(a); - expectType(b); - }, - 'string', - 6, - ); - attempt.commit(); -}); - -test('attempt with title', async t => { - const attempt = await t.try( - 'attempt title', - (u, a, b) => { - expectType(u); - expectType(a); - expectType(b); - }, - 'string', - 6, - ); - attempt.commit(); -}); - -const lengthCheck = (t: ExecutionContext, a: string, b: number): void => { - t.is(a.length, b); -}; - -test('attempt with helper', async t => { - const attempt = await t.try(lengthCheck, 'string', 6); - attempt.commit(); -}); - -test('attempt with title', async t => { - const attempt = await t.try('title', lengthCheck, 'string', 6); - attempt.commit(); -}); - -test('all possible variants to pass to t.try', async t => { - // No params - void t.try(tt => tt.pass()); - - void t.try('test', tt => tt.pass()); - - // Some params - void t.try((tt, a, b) => tt.is(a.length, b), 'hello', 5); - - void t.try('test', (tt, a, b) => tt.is(a.length, b), 'hello', 5); - - // Macro with title - const macro1 = test.macro<[string, number]>({ - exec: (tt, a, b) => tt.is(a.length, b), - title: (title, a, b) => `${title ? `${String(title)} ` : ''}str: "${String(a)}" with len: "${String(b)}"`, - }); - const macro2 = test.macro<[string, number]>((tt, a, b) => tt.is(a.slice(b), '')); - - void t.try(macro1, 'hello', 5); - void t.try(macro2, 'hello', 5); - void t.try('title', macro1, 'hello', 5); - void t.try('title', macro2, 'hello', 5); -}); diff --git a/test-types/module/assertions-as-type-guards.ts b/test-types/module/assertions-as-type-guards.ts index 15b718d79..c35b0fc3a 100644 --- a/test-types/module/assertions-as-type-guards.ts +++ b/test-types/module/assertions-as-type-guards.ts @@ -1,6 +1,6 @@ import {expectType} from 'tsd'; -import test from '../../entrypoints/main.mjs'; +import test from '../../entrypoints/main.js'; type Expected = {foo: 'bar'}; const expected: Expected = {foo: 'bar'}; diff --git a/test-types/module/conditional-chains.ts b/test-types/module/conditional-chains.ts index 9f920d7ac..db6758933 100644 --- a/test-types/module/conditional-chains.ts +++ b/test-types/module/conditional-chains.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-empty-function */ -import anyTest from '../../entrypoints/main.mjs'; +import anyTest from '../../entrypoints/main.js'; anyTest.skipIf(true).beforeEach(() => {}); anyTest.runIf(false).afterEach(() => {}); diff --git a/test-types/module/context.ts b/test-types/module/context.ts index b0ffdf79b..ad9fc7c8b 100644 --- a/test-types/module/context.ts +++ b/test-types/module/context.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-empty-function */ import {expectError, expectType} from 'tsd'; -import type {ExecutionContext, TestFn} from '../../entrypoints/main.mjs'; -import anyTest from '../../entrypoints/main.mjs'; +import type {ExecutionContext, TestFn} from '../../entrypoints/main.js'; +import anyTest from '../../entrypoints/main.js'; type Context = { foo: string; diff --git a/test-types/module/deep-equal.ts b/test-types/module/deep-equal.ts index 69565fb9d..5eb65b5ad 100644 --- a/test-types/module/deep-equal.ts +++ b/test-types/module/deep-equal.ts @@ -1,6 +1,6 @@ import {expectType} from 'tsd'; -import test from '../../entrypoints/main.mjs'; +import test from '../../entrypoints/main.js'; test('actual extends expected', t => { type Expected = {foo: [1, 2, 3]}; diff --git a/test-types/module/implementation-result.ts b/test-types/module/implementation-result.ts index bae67ab88..bff363ecc 100644 --- a/test-types/module/implementation-result.ts +++ b/test-types/module/implementation-result.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-empty-function */ -import test from '../../entrypoints/main.mjs'; +import test from '../../entrypoints/main.js'; test.after('return anything else', _t => ({ foo: 'bar', diff --git a/test-types/module/like.ts b/test-types/module/like.ts index 971b8c75a..736985d69 100644 --- a/test-types/module/like.ts +++ b/test-types/module/like.ts @@ -1,4 +1,4 @@ -import test from '../../entrypoints/main.mjs'; +import test from '../../entrypoints/main.js'; test('like', t => { t.like({ diff --git a/test-types/module/macros.ts b/test-types/module/macros.ts index 5c27803fd..23795f7f1 100644 --- a/test-types/module/macros.ts +++ b/test-types/module/macros.ts @@ -1,7 +1,7 @@ import {expectType} from 'tsd'; -import type {ExecutionContext} from '../../entrypoints/main.mjs'; -import test from '../../entrypoints/main.mjs'; +import type {ExecutionContext} from '../../entrypoints/main.js'; +import test from '../../entrypoints/main.js'; // Typed arguments through generics. { diff --git a/test-types/module/snapshot.ts b/test-types/module/snapshot.ts index 0e678d51c..8a319e163 100644 --- a/test-types/module/snapshot.ts +++ b/test-types/module/snapshot.ts @@ -1,6 +1,6 @@ import {expectError} from 'tsd'; -import test from '../../entrypoints/main.mjs'; +import test from '../../entrypoints/main.js'; test('snapshot', t => { t.snapshot({foo: 'bar'}); diff --git a/test-types/module/teardown.ts b/test-types/module/teardown.ts index dd7fa1eb3..9e31aaed2 100644 --- a/test-types/module/teardown.ts +++ b/test-types/module/teardown.ts @@ -1,4 +1,4 @@ -import test from '../../entrypoints/main.mjs'; +import test from '../../entrypoints/main.js'; test('test', t => { t.teardown(() => {}); // eslint-disable-line @typescript-eslint/no-empty-function diff --git a/test-types/module/throws.ts b/test-types/module/throws.ts index dd3954e46..235079b7e 100644 --- a/test-types/module/throws.ts +++ b/test-types/module/throws.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-empty-function */ import {expectError, expectType} from 'tsd'; -import test from '../../entrypoints/main.mjs'; +import test from '../../entrypoints/main.js'; class CustomError extends Error { foo: string; diff --git a/test-types/module/timeout.ts b/test-types/module/timeout.ts index c96a5b647..bf9eae3fd 100644 --- a/test-types/module/timeout.ts +++ b/test-types/module/timeout.ts @@ -1,4 +1,4 @@ -import test from '../../entrypoints/main.mjs'; +import test from '../../entrypoints/main.js'; test('test', t => { t.timeout(100); diff --git a/test-types/module/try-commit.ts b/test-types/module/try-commit.ts index 8dd53cc16..8d69fdc97 100644 --- a/test-types/module/try-commit.ts +++ b/test-types/module/try-commit.ts @@ -1,7 +1,7 @@ import {expectType} from 'tsd'; -import type {ExecutionContext} from '../../entrypoints/main.mjs'; -import test from '../../entrypoints/main.mjs'; +import type {ExecutionContext} from '../../entrypoints/main.js'; +import test from '../../entrypoints/main.js'; test('attempt', async t => { const attempt = await t.try( diff --git a/test/cjs-default/fixtures/package.json b/test/cjs-default/fixtures/package.json deleted file mode 100644 index 82a861884..000000000 --- a/test/cjs-default/fixtures/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "ava": { - "files": [ - "*.cjs" - ] - } -} diff --git a/test/cjs-default/fixtures/test.cjs b/test/cjs-default/fixtures/test.cjs deleted file mode 100644 index 597f7d610..000000000 --- a/test/cjs-default/fixtures/test.cjs +++ /dev/null @@ -1,20 +0,0 @@ -const test = require('ava'); - -test.default('callable', t => { - t.pass(); -}); - -test('no recursion', t => { - t.throws(() => test.default.default, { - name: 'TypeError', - }); -}); - -test('not enumerable', t => { - t.false(Object.keys(test).includes('default')); -}); - -test('main export equals the ESM export', async t => { - const {default: exported} = await import('ava'); - t.is(test, exported); -}); diff --git a/test/cjs-default/test.js b/test/cjs-default/test.js deleted file mode 100644 index 24c9fec5b..000000000 --- a/test/cjs-default/test.js +++ /dev/null @@ -1,7 +0,0 @@ -import test from '@ava/test'; - -import {fixture} from '../helpers/exec.js'; - -test('ok', async t => { - await t.notThrowsAsync(fixture()); -}); diff --git a/test/config-require/fixtures/exports-default/package.json b/test/config-require/fixtures/exports-default/package.json index 62b13ac45..4f81b98d1 100644 --- a/test/config-require/fixtures/exports-default/package.json +++ b/test/config-require/fixtures/exports-default/package.json @@ -1,6 +1,6 @@ { "type": "module", "ava": { - "require": "./required.cjs" + "require": "./required.js" } } diff --git a/test/config-require/fixtures/exports-default/required.cjs b/test/config-require/fixtures/exports-default/required.cjs deleted file mode 100644 index 8ceb435bf..000000000 --- a/test/config-require/fixtures/exports-default/required.cjs +++ /dev/null @@ -1,5 +0,0 @@ -exports.called = false; - -exports.default = function () { - exports.called = true; -}; diff --git a/test/config-require/fixtures/exports-default/required.js b/test/config-require/fixtures/exports-default/required.js new file mode 100644 index 000000000..f3b00f3cb --- /dev/null +++ b/test/config-require/fixtures/exports-default/required.js @@ -0,0 +1,7 @@ +function required() { + required.called = true; +} + +required.called = false; + +export default required; diff --git a/test/config-require/fixtures/exports-default/test.js b/test/config-require/fixtures/exports-default/test.js index 3ea5bc6b9..c0825654e 100644 --- a/test/config-require/fixtures/exports-default/test.js +++ b/test/config-require/fixtures/exports-default/test.js @@ -1,7 +1,7 @@ import test from 'ava'; -import required from './required.cjs'; +import required from './required.js'; -test('exports.default is called', t => { +test('default export is called', t => { t.true(required.called); }); diff --git a/test/config-require/fixtures/non-json/ava.config.js b/test/config-require/fixtures/non-json/ava.config.js index 34aa3ff57..84d636d47 100644 --- a/test/config-require/fixtures/non-json/ava.config.js +++ b/test/config-require/fixtures/non-json/ava.config.js @@ -1,5 +1,5 @@ export default { require: [ - ['./required.mjs', new Map([['hello', 'world']])], + ['./required.js', new Map([['hello', 'world']])], ], }; diff --git a/test/config-require/fixtures/non-json/required.mjs b/test/config-require/fixtures/non-json/required.js similarity index 100% rename from test/config-require/fixtures/non-json/required.mjs rename to test/config-require/fixtures/non-json/required.js diff --git a/test/config-require/fixtures/non-json/test.js b/test/config-require/fixtures/non-json/test.js index c2607362e..61d430233 100644 --- a/test/config-require/fixtures/non-json/test.js +++ b/test/config-require/fixtures/non-json/test.js @@ -1,6 +1,6 @@ import test from 'ava'; -import {receivedArgs} from './required.mjs'; +import {receivedArgs} from './required.js'; test('non-JSON arguments can be provided', t => { t.deepEqual(receivedArgs, [new Map([['hello', 'world']])]); diff --git a/test/config-require/fixtures/with-arguments/ava.config.js b/test/config-require/fixtures/with-arguments/ava.config.js index b497f6dfd..fc70e0959 100644 --- a/test/config-require/fixtures/with-arguments/ava.config.js +++ b/test/config-require/fixtures/with-arguments/ava.config.js @@ -1,7 +1,7 @@ export default { require: [ - ['./required.mjs', 'hello', 'world'], - ['./required.cjs', 'goodbye'], + ['./required-esm.js', 'hello', 'world'], + ['./required.js', 'goodbye'], './side-effect.js', ], }; diff --git a/test/config-require/fixtures/with-arguments/required.mjs b/test/config-require/fixtures/with-arguments/required-esm.js similarity index 100% rename from test/config-require/fixtures/with-arguments/required.mjs rename to test/config-require/fixtures/with-arguments/required-esm.js diff --git a/test/config-require/fixtures/with-arguments/required.cjs b/test/config-require/fixtures/with-arguments/required.js similarity index 78% rename from test/config-require/fixtures/with-arguments/required.cjs rename to test/config-require/fixtures/with-arguments/required.js index ad5c055e6..2e6680956 100644 --- a/test/config-require/fixtures/with-arguments/required.cjs +++ b/test/config-require/fixtures/with-arguments/required.js @@ -4,4 +4,4 @@ function init(...args) { init.receivedArgs = null; -module.exports = init; +export default init; diff --git a/test/config-require/fixtures/with-arguments/test.js b/test/config-require/fixtures/with-arguments/test.js index 8c1e1b43f..df5962a9c 100644 --- a/test/config-require/fixtures/with-arguments/test.js +++ b/test/config-require/fixtures/with-arguments/test.js @@ -1,11 +1,11 @@ import test from 'ava'; -import cjs from './required.cjs'; -import {receivedArgs} from './required.mjs'; +import {receivedArgs} from './required-esm.js'; +import requiredModule from './required.js'; test('receives arguments from config', t => { t.deepEqual(receivedArgs, ['hello', 'world']); - t.deepEqual(cjs.receivedArgs, ['goodbye']); + t.deepEqual(requiredModule.receivedArgs, ['goodbye']); }); test('side-effects are execute when tests loaded, before test code', async t => { diff --git a/test/config-require/test.js b/test/config-require/test.js index f67844cdf..40d5923d9 100644 --- a/test/config-require/test.js +++ b/test/config-require/test.js @@ -22,7 +22,7 @@ test('loads required modules, not as an array', async t => { t.is(result.stats.passed.length, 1); }); -test('calls exports.default (CJS)', async t => { +test('calls default export', async t => { const result = await fixture([], {cwd: cwd('exports-default')}); t.is(result.stats.passed.length, 1); }); diff --git a/test/config/fixtures/file-yes-cjs-yes-mjs-yes/ava.config.cjs b/test/config/fixtures/file-yes-cjs-yes-mjs-yes/ava.config.cjs deleted file mode 100644 index f7426f1bb..000000000 --- a/test/config/fixtures/file-yes-cjs-yes-mjs-yes/ava.config.cjs +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - files: 'package-yes-files-yes-test-value', -}; diff --git a/test/config/fixtures/file-yes-cjs-yes-mjs-yes/ava.config.js b/test/config/fixtures/file-yes-cjs-yes-mjs-yes/ava.config.js deleted file mode 100644 index 473cedcab..000000000 --- a/test/config/fixtures/file-yes-cjs-yes-mjs-yes/ava.config.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - files: 'package-yes-files-yes-test-value', -}; diff --git a/test/config/fixtures/file-yes-cjs-yes-mjs-yes/package.json b/test/config/fixtures/file-yes-cjs-yes-mjs-yes/package.json deleted file mode 100644 index bedb411a9..000000000 --- a/test/config/fixtures/file-yes-cjs-yes-mjs-yes/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "module" -} diff --git a/test-tap/fixture/load-config/file-yes-cjs-yes/ava.config.js b/test/config/fixtures/file-yes-js-yes-mjs-yes/ava.config.js similarity index 100% rename from test-tap/fixture/load-config/file-yes-cjs-yes/ava.config.js rename to test/config/fixtures/file-yes-js-yes-mjs-yes/ava.config.js diff --git a/test/config/fixtures/file-yes-cjs-yes-mjs-yes/ava.config.mjs b/test/config/fixtures/file-yes-js-yes-mjs-yes/ava.config.mjs similarity index 100% rename from test/config/fixtures/file-yes-cjs-yes-mjs-yes/ava.config.mjs rename to test/config/fixtures/file-yes-js-yes-mjs-yes/ava.config.mjs diff --git a/test-tap/fixture/load-config/file-yes-cjs-yes/package.json b/test/config/fixtures/file-yes-js-yes-mjs-yes/package.json similarity index 100% rename from test-tap/fixture/load-config/file-yes-cjs-yes/package.json rename to test/config/fixtures/file-yes-js-yes-mjs-yes/package.json diff --git a/test/config/fixtures/js-as-cjs/ava.config.js b/test/config/fixtures/js-as-cjs/ava.config.js deleted file mode 100644 index 5e41ecd92..000000000 --- a/test/config/fixtures/js-as-cjs/ava.config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { // eslint-disable-line unicorn/prefer-module - failFast: true, -}; diff --git a/test/config/fixtures/js-as-cjs/package.json b/test/config/fixtures/js-as-cjs/package.json deleted file mode 100644 index 0967ef424..000000000 --- a/test/config/fixtures/js-as-cjs/package.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/test/config/fixtures/mjs-with-tests/ava.config.mjs b/test/config/fixtures/js-with-tests/ava.config.js similarity index 100% rename from test/config/fixtures/mjs-with-tests/ava.config.mjs rename to test/config/fixtures/js-with-tests/ava.config.js diff --git a/test/config/fixtures/mjs-with-tests/dir-a-wrapper/dir-a/dir-a-wrapper-4.js b/test/config/fixtures/js-with-tests/dir-a-wrapper/dir-a/dir-a-wrapper-3.js similarity index 100% rename from test/config/fixtures/mjs-with-tests/dir-a-wrapper/dir-a/dir-a-wrapper-4.js rename to test/config/fixtures/js-with-tests/dir-a-wrapper/dir-a/dir-a-wrapper-3.js diff --git a/test/config/fixtures/mjs-with-tests/dir-a/dir-a-base-1.js b/test/config/fixtures/js-with-tests/dir-a-wrapper/dir-a/dir-a-wrapper-4.js similarity index 100% rename from test/config/fixtures/mjs-with-tests/dir-a/dir-a-base-1.js rename to test/config/fixtures/js-with-tests/dir-a-wrapper/dir-a/dir-a-wrapper-4.js diff --git a/test/config/fixtures/mjs-with-tests/dir-a/dir-a-base-2.js b/test/config/fixtures/js-with-tests/dir-a/dir-a-base-1.js similarity index 100% rename from test/config/fixtures/mjs-with-tests/dir-a/dir-a-base-2.js rename to test/config/fixtures/js-with-tests/dir-a/dir-a-base-1.js diff --git a/test-tap/fixture/ava-paths/target/test.cjs b/test/config/fixtures/js-with-tests/dir-a/dir-a-base-2.js similarity index 55% rename from test-tap/fixture/ava-paths/target/test.cjs rename to test/config/fixtures/js-with-tests/dir-a/dir-a-base-2.js index 5ca41efa1..5950a2850 100644 --- a/test-tap/fixture/ava-paths/target/test.cjs +++ b/test/config/fixtures/js-with-tests/dir-a/dir-a-base-2.js @@ -1,4 +1,4 @@ -const test = require('ava'); +import test from 'ava'; test('test', t => { t.pass(); diff --git a/test/config/fixtures/mjs-with-tests/package.json b/test/config/fixtures/js-with-tests/package.json similarity index 100% rename from test/config/fixtures/mjs-with-tests/package.json rename to test/config/fixtures/js-with-tests/package.json diff --git a/test/config/integration.js b/test/config/integration.js index 13f18ad30..6b14282c3 100644 --- a/test/config/integration.js +++ b/test/config/integration.js @@ -43,9 +43,9 @@ test('resolves tests from the package.json dir if none are specified on cli', as t.snapshot(result.stats.passed, 'resolves test files from configuration'); }); -test('resolves tests from an .mjs config file', async t => { +test('resolves tests from a .js config file', async t => { const options = { - cwd: cwd('mjs-with-tests/dir-a-wrapper'), + cwd: cwd('js-with-tests/dir-a-wrapper'), }; const result = await fixture([], options); @@ -67,7 +67,7 @@ test('use current working directory if `package.json` is not found', async t => const cwd = temporaryDirectory(); const testFilePath = path.join(cwd, 'test.js'); - fs.writeFileSync(testFilePath, 'const test = require(process.env.TEST_AVA_REQUIRE_FROM);\ntest(\'test name\', t => { t.pass(); });'); + fs.writeFileSync(testFilePath, 'const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM);\ntest(\'test name\', t => { t.pass(); });'); const options = { cwd, diff --git a/test/config/loader.js b/test/config/loader.js index af25c248d..a1949842b 100644 --- a/test/config/loader.js +++ b/test/config/loader.js @@ -97,10 +97,6 @@ test.serial('loads config from factory function', ok('package-no-file-yes-factor t.assert(conf.files.startsWith(FIXTURE_ROOT)); }); -test.serial('does not support require() inside config.js files', notOk('require'), (t, error) => { - t.true(error.message.startsWith('Error loading ava.config.js: require is not defined')); -}); - test.serial('throws an error if a config factory does not return a plain object', notOk('factory-no-plain-return')); test.serial('throws an error if a config does not export a plain object', notOk('no-plain-config')); @@ -122,9 +118,3 @@ test.serial('throws an error if a config file contains a non-function `filterNod test.serial('throws an error if a config file contains a non-object `nonSemVerExperiments` property', notOk('non-object-experiments')); test.serial('throws an error if a config file enables an unsupported experiment', notOk('unsupported-experiments')); - -test.serial('loads .cjs config', ok('cjs'), (t, conf) => { - t.assert(conf.files.startsWith(FIXTURE_ROOT)); -}); - -test.serial('throws an error if both .js and .cjs configs are present', notOk('file-yes-cjs-yes')); diff --git a/test/config/next-gen.js b/test/config/next-gen.js index cfa117367..673e243e7 100644 --- a/test/config/next-gen.js +++ b/test/config/next-gen.js @@ -67,10 +67,6 @@ test.serial('fails when .mjs config does not have a default export', notOk({ configFile: 'no-default-export.mjs', })); -test.serial('loads .js config as CommonJS', ok('js-as-cjs'), (t, conf) => { - t.true(conf.failFast); -}); - test.serial('loads .js config as ESM', ok('js-as-esm'), (t, conf) => { t.true(conf.failFast); }); @@ -99,7 +95,7 @@ test.serial('fails when .js config does not have a default export', notOk({ configFile: 'no-default-export.js', })); -test.serial('throws an error if .js, .cjs and .mjs configs are present', notOk('file-yes-cjs-yes-mjs-yes')); +test.serial('throws an error if .js and .mjs configs are present', notOk('file-yes-js-yes-mjs-yes')); test.serial('config factory returns a promise', ok('factory-promise-return'), (t, conf) => { t.true(conf.failFast); @@ -108,4 +104,3 @@ test.serial('config factory returns a promise', ok('factory-promise-return'), (t test.serial('config exports a promise', ok('promise-config'), (t, conf) => { t.true(conf.failFast); }); - diff --git a/test/config/snapshots/integration.js.md b/test/config/snapshots/integration.js.md index 4605a09d9..0a821e63e 100644 --- a/test/config/snapshots/integration.js.md +++ b/test/config/snapshots/integration.js.md @@ -34,7 +34,7 @@ Generated by [AVA](https://avajs.dev). }, ] -## resolves tests from an .mjs config file +## resolves tests from a .js config file > resolves test files from configuration diff --git a/test/config/snapshots/integration.js.snap b/test/config/snapshots/integration.js.snap index 0b5a36191e52e9ba2a417b37682f7ed51d6ab51f..f88f498f1d815fd2d595c395f63147fd268e231d 100644 GIT binary patch literal 563 zcmV-30?hqERzV|B~TA=;KYFw5{OGT z_Bh$b*@<@7O?u?edwGQR(la++1&KF7LX4dzBqdT!# z_>8>vDUF^E+4dYNhcp^cU}CwCzDqbzQBQTKb>P@wtgYzS9%*OPz;)TX z_h)geym||-!(cVYFIa={k>p*8XA*aywhq9Emg6w1Nj)GdI98j%Yyu+9P&4jtO(#I*Mxkx)!JGb z=Y_?WiTd6m)Cy(A3w=@HKgxdq2dlFKY7|G7fXq890zg7##=S?T?zi} zX_Ba*UgOIM)*(M|1EU83unz!F0AL$yTUdSSoH|CFuIlwV;B~+X;3nepN#iEsQGUfD z;{*Uc0>IfcqxPcR<2Ybtwrn&SMd{Z`7wqAM(rB^tM)ATrY-8mnMu62VT+=4y>CLUg zxTe}E&ds*++-uaiiOF8+0W1cfB^u!FA-S=u%<=Ia79|=a{(WyW@XaLGs8;rzTi zB;(0SAT60qe#Z9suVMReMQrQ&=a+H2Rxq+^z~}VtEu%Lwp(|Nf1o$0%vIHaw2mk;r CM;bx^ diff --git a/test/config/snapshots/loader.js.md b/test/config/snapshots/loader.js.md index 92afafe60..c257524ae 100644 --- a/test/config/snapshots/loader.js.md +++ b/test/config/snapshots/loader.js.md @@ -14,7 +14,7 @@ Generated by [AVA](https://avajs.dev). > error message - 'Could not load config file; it should have .js, .cjs or .mjs extension' + 'Could not load config file; it should have .js or .mjs extension' ## throws an error if a config factory does not return a plain object @@ -57,9 +57,3 @@ Generated by [AVA](https://avajs.dev). > error message 'nonSemVerExperiments.unsupported from ava.config.js is not a supported experiment' - -## throws an error if both .js and .cjs configs are present - -> error message - - 'Conflicting configuration in ava.config.js and ava.config.cjs' diff --git a/test/config/snapshots/loader.js.snap b/test/config/snapshots/loader.js.snap index a0fa8e36baddb38f976c467aaa2f15a276f694bf..5ef3aa8322135a6880f699532e9274dadc6aeb52 100644 GIT binary patch literal 608 zcmV-m0-yasRzVli6jARA;;q0%`9k_@0a>y z?R?YW0w0SA00000000A(l)-M(KoEvoA;g(Cm^&h8XgB~-g36&%Rn&4LWA8ZLX1!zW zuG{1WM;?JAeKekgS;vX$W^qCeiJjHV|NZ~Y?(ZTqoG<;)2MRhETD=OT<9iQift+Ip zx`2#B2|3$BFJ!?H)Q&vapuNS~mmK_$2c|(L z7&KeZ7Vr*7n?FalQBOgQ`4Sf-uWZR+MyA>@ROG!ZY#HBljDoglFw=&B>$Y==Eqr5r zQ`hVQDWFv#>t%5t_@W2=e!`7WU^#$cR9$x{r2QCl04a^@CEgK4Xh9oQ^1BllqW+jj z7IzYu2X<>vOup536dETXL2XdN;_R04MBtY_{>iLsQ&A{68t)Rw)=%QD8vhTCAq!_i z7Ix?x)r07td+6^He91;J^le&2WAktz_B3iQw`aBpeTO(VNT3E5aT}QK_r2df}vavYc2FfyDYY>;HAz4fb4~uc*2vH(iMx-Qo?I`_wb{HdQ|8 u=9nWtd}~EBWHB?8xOBG=2WK$_K6>0MVM1^28ibT$%Fti0IyKAc1^@uwYbbsI literal 638 zcmV-^0)hQORzVUnhm@&VU%CFnG7+S6`{mi)xCa7Y5D zJT7~O5g&^P00000000A(mBDV)KoEvoA;g(Cm^r zh{flS2xn&I0F|Ipa>U*^#>(a5-Oq?}Jm2+(2Yj$;2 ziF!(bZalFw!kfV7J>bbmYMTO!2P>F%)gd#Mj=^|vdHX-dIYCso*AOLz15t>|!u^vO zV*eEAFRp|z@uIho3b~d-$=Aw&P+2q#5*L&N+J4$|F`9H`O7gih_PajBw@;d0*6u$V zLl%yPEUeHMs$0>&^w8f2_=1I+rZ2md)tvY(Z4Way8f!Cdv%>-@Wmwy#@+R|Hk9j<9 z3pRmia^7=r6l!=IAAF*+OWwnoX}}X-okdALEQq$rMnfu%` z_b#-3(9JGKe)!gE%n)O2DRA{JA+}~Q1Rkx|3Yaj9y9OboxbKl_pSk5*)ZXkny?I}I YHa_h6=B=$Hg$p770e_CEU!w;A0QZA8 error message - 'Conflicting configuration in ava.config.js and ava.config.cjs & ava.config.mjs' + 'Conflicting configuration in ava.config.js and ava.config.mjs' diff --git a/test/config/snapshots/next-gen.js.snap b/test/config/snapshots/next-gen.js.snap index ec5e33e21c54753ddce7f529e6d00a0016d8fde4..424e7a760f3cebe5ff7c4b472cda4ff91f4c224b 100644 GIT binary patch literal 359 zcmV-t0hslFdrPKoo^jL|nU9xH~~fH|j=kC0&WDBDlTH+$7UZ?u5CM zwp$m1ui#4T6Z#0|r`3eUD$Vl1$^Fj9e8dxDqnW&{$ZKzCd6pt8LjvTSbpnf&7>q@w zIe}p|6^JayI?=+IOKQD5uarWMPZtNlQBZw@!{B&uI;#5L&H8Uu{RTeY-(Jb!giKba zkdX)`v>~{TQJeMQ)T*oNzV*z_B=-Wak% ze!049N4V4E&n^@gjUTr8&pZ4leLnxA^Qx_Lf1B8$8UJOoU*_H}FMaClLIAm04mz&K zl!n`HqzoKE?nsDxHr#hM+}@QPqa$A}X!?aiuPuXSz&Q?^aC4`Xlo$JGzW^Bc;xkPH F004%Ctylm6 literal 367 zcmV-#0g(PdRzVk}*%iFc5`PA;ioM(oG-%$pizes3R;D5(CRMJ|_;29r>KL zD+3aLfeF!H$WK6S0wiiEs2-p6{NDF;?{cbb`pC~q^2%#k9Or0+CI)iOI)-^p2DC+? zOa@6=Fr?NB-YvkEh_8$dY`n{=dRz!*tqq_jlbzOC_`EE zFR7b2;*CrGa3RBZa { - const result = await fixture(['*.js', '*.cjs']); - const files = new Set(result.stats.passed.map(({file}) => file)); - t.is(files.size, 2); - t.true(files.has('test.cjs')); - t.true(files.has('test.js')); -}); - -test('load js and cjs (using an extensions array)', async t => { - const result = await fixture(['*.js', '*.cjs', '--config', 'array-extensions.config.js']); - const files = new Set(result.stats.passed.map(({file}) => file)); - t.is(files.size, 2); - t.true(files.has('test.cjs')); - t.true(files.has('test.js')); -}); - -test('load js and cjs (using an extensions object)', async t => { - const result = await fixture(['*.js', '*.cjs', '--config', 'object-extensions.config.js']); - const files = new Set(result.stats.passed.map(({file}) => file)); - t.is(files.size, 2); - t.true(files.has('test.cjs')); - t.true(files.has('test.js')); -}); diff --git a/test/configurable-module-format/custom.js b/test/configurable-module-format/custom.js deleted file mode 100644 index aa99fff81..000000000 --- a/test/configurable-module-format/custom.js +++ /dev/null @@ -1,17 +0,0 @@ -import test from '@ava/test'; - -import {fixture} from '../helpers/exec.js'; - -test('load cts as commonjs (using an extensions array)', async t => { - const result = await fixture(['*.cts', '--config', 'array-custom.config.js']); - const files = new Set(result.stats.passed.map(({file}) => file)); - t.is(files.size, 1); - t.true(files.has('test.cts')); -}); - -test('load cts as commonjs (using an extensions object)', async t => { - const result = await fixture(['*.cts', '--config', 'object-custom.config.js']); - const files = new Set(result.stats.passed.map(({file}) => file)); - t.is(files.size, 1); - t.true(files.has('test.cts')); -}); diff --git a/test/configurable-module-format/fixtures/array-custom.config.js b/test/configurable-module-format/fixtures/array-custom.config.js deleted file mode 100644 index 2e2a5fd57..000000000 --- a/test/configurable-module-format/fixtures/array-custom.config.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - extensions: ['js', 'cts'], -}; diff --git a/test/configurable-module-format/fixtures/array-extensions.config.js b/test/configurable-module-format/fixtures/array-extensions.config.js index 114b06aa6..1d9c0d23a 100644 --- a/test/configurable-module-format/fixtures/array-extensions.config.js +++ b/test/configurable-module-format/fixtures/array-extensions.config.js @@ -1,3 +1,3 @@ export default { - extensions: ['js', 'cjs', 'mjs'], + extensions: ['js', 'mjs'], }; diff --git a/test/configurable-module-format/fixtures/bad-custom-type.config.js b/test/configurable-module-format/fixtures/bad-custom-type.config.js index 7310e1748..0821a3b9c 100644 --- a/test/configurable-module-format/fixtures/bad-custom-type.config.js +++ b/test/configurable-module-format/fixtures/bad-custom-type.config.js @@ -1,6 +1,6 @@ export default { extensions: { js: true, - ts: 'cjs', + ts: 'script', }, }; diff --git a/test/configurable-module-format/fixtures/change-cjs-loading.config.js b/test/configurable-module-format/fixtures/change-cjs-loading.config.js deleted file mode 100644 index efe50f56d..000000000 --- a/test/configurable-module-format/fixtures/change-cjs-loading.config.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - extensions: { - cjs: 'module', - }, -}; diff --git a/test/configurable-module-format/fixtures/change-mjs-loading.config.js b/test/configurable-module-format/fixtures/change-mjs-loading.config.js index d3956eb09..2db2a1698 100644 --- a/test/configurable-module-format/fixtures/change-mjs-loading.config.js +++ b/test/configurable-module-format/fixtures/change-mjs-loading.config.js @@ -1,5 +1,5 @@ export default { extensions: { - mjs: 'commonjs', + mjs: 'module', }, }; diff --git a/test/configurable-module-format/fixtures/object-custom.config.js b/test/configurable-module-format/fixtures/object-custom.config.js deleted file mode 100644 index a859b9d69..000000000 --- a/test/configurable-module-format/fixtures/object-custom.config.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - extensions: { - js: true, - cts: 'commonjs', - }, -}; diff --git a/test/configurable-module-format/fixtures/object-extensions.config.js b/test/configurable-module-format/fixtures/object-extensions.config.js index c7bd8597b..b95e15e54 100644 --- a/test/configurable-module-format/fixtures/object-extensions.config.js +++ b/test/configurable-module-format/fixtures/object-extensions.config.js @@ -1,7 +1,6 @@ export default { extensions: { js: true, - cjs: true, mjs: true, }, }; diff --git a/test/configurable-module-format/fixtures/test.cjs b/test/configurable-module-format/fixtures/test.cjs deleted file mode 100644 index d7dd4fe69..000000000 --- a/test/configurable-module-format/fixtures/test.cjs +++ /dev/null @@ -1,5 +0,0 @@ -const test = require('ava'); - -test('always passing test', t => { - t.pass(); -}); diff --git a/test/configurable-module-format/fixtures/test.cts b/test/configurable-module-format/fixtures/test.cts deleted file mode 100644 index 48229d52f..000000000 --- a/test/configurable-module-format/fixtures/test.cts +++ /dev/null @@ -1,8 +0,0 @@ -const test = require('ava'); // eslint-disable-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-require-imports, unicorn/prefer-module - -// @ts-expect-error TS2345 -test('always passing test', t => { // eslint-disable-line @typescript-eslint/no-unsafe-call - const numberWithTypes = 0; - - t.is(numberWithTypes, 0); // eslint-disable-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access -}); diff --git a/test/configurable-module-format/invalid-configurations.js b/test/configurable-module-format/invalid-configurations.js index 8b543caeb..3dd04d541 100644 --- a/test/configurable-module-format/invalid-configurations.js +++ b/test/configurable-module-format/invalid-configurations.js @@ -7,17 +7,12 @@ test('cannot configure how js extensions should be loaded', async t => { t.snapshot(cleanOutput(result.stderr)); }); -test('cannot configure how cjs extensions should be loaded', async t => { - const result = await t.throwsAsync(fixture(['--config', 'change-cjs-loading.config.js'])); - t.snapshot(cleanOutput(result.stderr)); -}); - test('cannot configure how mjs extensions should be loaded', async t => { const result = await t.throwsAsync(fixture(['--config', 'change-mjs-loading.config.js'])); t.snapshot(cleanOutput(result.stderr)); }); -test('custom extensions must be either commonjs or module', async t => { +test('custom extensions must be modules', async t => { const result = await t.throwsAsync(fixture(['--config', 'bad-custom-type.config.js'])); t.snapshot(cleanOutput(result.stderr)); }); diff --git a/test/configurable-module-format/snapshots/invalid-configurations.js.md b/test/configurable-module-format/snapshots/invalid-configurations.js.md index 66ed27328..e7c9fbd3b 100644 --- a/test/configurable-module-format/snapshots/invalid-configurations.js.md +++ b/test/configurable-module-format/snapshots/invalid-configurations.js.md @@ -8,22 +8,16 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 - 'When specifying module types, use `true` for ’cjs’, ’mjs’ and ’js’ extensions' - -## cannot configure how cjs extensions should be loaded - -> Snapshot 1 - - 'When specifying module types, use `true` for ’cjs’, ’mjs’ and ’js’ extensions' + 'When specifying module types, use `true` for ‘js’ extensions' ## cannot configure how mjs extensions should be loaded > Snapshot 1 - 'When specifying module types, use `true` for ’cjs’, ’mjs’ and ’js’ extensions' + 'When specifying module types, use `true` for ‘mjs’ extensions' -## custom extensions must be either commonjs or module +## custom extensions must be modules > Snapshot 1 - 'Module type for ’ts’ must be ’commonjs’ or ’module’' + 'Module type for ‘ts’ must be ‘module’' diff --git a/test/configurable-module-format/snapshots/invalid-configurations.js.snap b/test/configurable-module-format/snapshots/invalid-configurations.js.snap index 63194cb71b307744074a400b2756b6a006b63b75..25a5bb7339a99132411311bc005b5cdecf403e88 100644 GIT binary patch literal 273 zcmV+s0q*`mRzVHAD|F=&Uj`WIu{!y$rT)$}*0tsjesm)@EkkdCT8E`Ea*ivBN zoT4+ZKyaiC8p}Zy^(egC8>2*heLf^lN%IDe$@5@5%P{~KsBOBjAp=h)It1Ai$gdC? zVJ>CFIiyrVwf$Xkwf#FQcDT`1oWEB$?dd-5)%jbz7adv1pJRNzG?e2_zO=meEW^pE X-Q}dMb%&aM`==fcgc@&xy#W9Kr6qj^ literal 293 zcmV+=0owjSRzVLI&zoN?^4g58 z_3MR{Wgm+O00000000Bk&cRN@FboFZP6%=44g3JRZFinvXW+IhahsGRu3|^qZbjNl z^f(@^PlB?p8VDW$e6lU;_jj&$p7a}^K2V%^Jgl^ekpwiw+BG>LSlUC&fCs_Ijv@nF z%HF^Z!ILs*97ol$CE@q8F-p`+b5}i7r55+q|p+F8}A~BE80z^>i|YkNxlo2w?Wo$pQcXKqZX7 diff --git a/test/create-chain/test.js b/test/create-chain/test.js index 2acd55d39..0196c43c1 100644 --- a/test/create-chain/test.js +++ b/test/create-chain/test.js @@ -171,15 +171,6 @@ test('skip state is irreversible: runIf(true) cannot undo a prior skipIf(true)', t.is(calls[0].metadata.skipped, true); }); -test('accessing .default on a skipped proxy does not throw (proxy invariant)', t => { - const {chain} = createTestChain(); - - t.notThrows(() => { - // eslint-disable-next-line no-unused-expressions - chain.skipIf(true).default; - }); -}); - test('accessing non-configurable accessor without getter on conditional chains returns undefined (proxy invariant)', t => { const {chain} = createTestChain(); diff --git a/test/helpers/exec.js b/test/helpers/exec.js index 41396a692..2b4e77744 100644 --- a/test/helpers/exec.js +++ b/test/helpers/exec.js @@ -6,11 +6,10 @@ import {fileURLToPath, pathToFileURL} from 'node:url'; import test from '@ava/test'; import {execaNode} from 'execa'; -const cliPath = fileURLToPath(new URL('../../entrypoints/cli.mjs', import.meta.url)); -const ttySimulator = fileURLToPath(new URL('simulate-tty.cjs', import.meta.url)); +const cliPath = fileURLToPath(new URL('../../entrypoints/cli.js', import.meta.url)); +const ttySimulator = fileURLToPath(new URL('simulate-tty.js', import.meta.url)); -const TEST_AVA_IMPORT_FROM = pathToFileURL(path.join(process.cwd(), 'entrypoints/main.mjs')); -const TEST_AVA_REQUIRE_FROM = path.join(process.cwd(), 'entrypoints/main.cjs'); +const TEST_AVA_IMPORT_FROM = pathToFileURL(path.join(process.cwd(), 'entrypoints/main.js')); const normalizePosixPath = string => string.replaceAll('\\', '/'); const normalizePath = (root, file) => normalizePosixPath(path.posix.normalize(path.relative(root, file))); @@ -87,10 +86,9 @@ export async function * exec(args, options) { ...options.env, TEST_AVA: 'true', TEST_AVA_IMPORT_FROM, - TEST_AVA_REQUIRE_FROM, }, cwd: workingDir, - nodeOptions: ['--require', ttySimulator], + nodeOptions: ['--import', pathToFileURL(ttySimulator).toString()], stdout: ['pipe', new Writable({ write(chunk, encoding, callback) { stdout += chunk; diff --git a/test/helpers/simulate-tty.cjs b/test/helpers/simulate-tty.js similarity index 96% rename from test/helpers/simulate-tty.cjs rename to test/helpers/simulate-tty.js index 14efb04f0..3814b9251 100644 --- a/test/helpers/simulate-tty.cjs +++ b/test/helpers/simulate-tty.js @@ -1,5 +1,4 @@ -'use strict'; -const tty = require('node:tty'); +import tty from 'node:tty'; // Call original method to ensure the correct errors are thrown. const assertHasColorsArguments = count => { diff --git a/test/idle-timeouts/test.js b/test/idle-timeouts/test.js index 635ad86ae..8b6affba0 100644 --- a/test/idle-timeouts/test.js +++ b/test/idle-timeouts/test.js @@ -5,5 +5,10 @@ import {fixture} from '../helpers/exec.js'; test('idle timeouts are not blocked by console output', async t => { const result = await t.throwsAsync(fixture(['console-output.js'])); const error = result.stats.getError(result.stats.failed[0]); - t.is(error.message, 'timeout despite console output'); + if (error) { + t.is(error.message, 'timeout despite console output'); + return; + } + + t.true(result.stdout.includes('Timed out while running tests')); }); diff --git a/test/meta/fixtures/meta.cjs b/test/meta/fixtures/meta.js similarity index 61% rename from test/meta/fixtures/meta.cjs rename to test/meta/fixtures/meta.js index 88233647c..3e826dcc2 100644 --- a/test/meta/fixtures/meta.cjs +++ b/test/meta/fixtures/meta.js @@ -1,9 +1,7 @@ -const url = require('node:url'); - -const test = require('ava'); +import test from 'ava'; test('meta.file', t => { - t.is(test.meta.file, url.pathToFileURL(__filename).toString()); + t.is(test.meta.file, import.meta.url); }); test('meta.snapshotDirectory', t => { @@ -11,4 +9,3 @@ test('meta.snapshotDirectory', t => { t.true(meta.snapshotDirectory.startsWith('file://')); t.regex(meta.snapshotDirectory, /snapshot-fixture/); }); - diff --git a/test/meta/test.js b/test/meta/test.js index 56c0dae86..79b9e7505 100644 --- a/test/meta/test.js +++ b/test/meta/test.js @@ -2,8 +2,8 @@ import test from '@ava/test'; import {fixture} from '../helpers/exec.js'; -test('with CJS files', async t => { - const result = await fixture(['meta.cjs']); +test('with JS files', async t => { + const result = await fixture(['meta.js']); t.is(result.stats.passed.length, 2); }); diff --git a/test/node-arguments/fixtures/node-arguments-from-config/node-arguments-from-config.js b/test/node-arguments/fixtures/node-arguments-from-config/node-arguments-from-config.js index 68fb6e4c3..64a11e85e 100644 --- a/test/node-arguments/fixtures/node-arguments-from-config/node-arguments-from-config.js +++ b/test/node-arguments/fixtures/node-arguments-from-config/node-arguments-from-config.js @@ -3,5 +3,5 @@ import test from 'ava'; test('works', t => { t.plan(2); t.truthy(globalThis.SETUP_CALLED, 'setup variable set'); - t.truthy(process.execArgv.some(argv => argv.startsWith('--require')), 'require passed'); + t.truthy(process.execArgv.some(argv => argv.startsWith('--import')), 'import passed'); }); diff --git a/test/node-arguments/fixtures/node-arguments-from-config/package.json b/test/node-arguments/fixtures/node-arguments-from-config/package.json index 848d376fd..904ab0b29 100644 --- a/test/node-arguments/fixtures/node-arguments-from-config/package.json +++ b/test/node-arguments/fixtures/node-arguments-from-config/package.json @@ -5,8 +5,8 @@ "*.js" ], "nodeArguments": [ - "--require", - "./setup.cjs" + "--import", + "./setup.js" ] } } diff --git a/test/node-arguments/fixtures/node-arguments-from-config/setup.cjs b/test/node-arguments/fixtures/node-arguments-from-config/setup.js similarity index 100% rename from test/node-arguments/fixtures/node-arguments-from-config/setup.cjs rename to test/node-arguments/fixtures/node-arguments-from-config/setup.js diff --git a/test/node-arguments/fixtures/thread-arguments-filter/thread-arguments-filter.config.mjs b/test/node-arguments/fixtures/thread-arguments-filter/thread-arguments-filter.config.js similarity index 100% rename from test/node-arguments/fixtures/thread-arguments-filter/thread-arguments-filter.config.mjs rename to test/node-arguments/fixtures/thread-arguments-filter/thread-arguments-filter.config.js diff --git a/test/node-arguments/snapshots/test.js.snap b/test/node-arguments/snapshots/test.js.snap index 932e64bd3037540c652002b6f5cf9d2629a5a8e3..973af1edd5a80d13af5439db37a4a06620abb164 100644 GIT binary patch literal 560 zcmV-00?++HRzVd@YAcWs2P8`zAw6*BvO?mv%LQpU){Q5r zTgQ$(4&9aZ!ht7XZ=Bc*uY%w;co3YVsk$ks5^W?aw(J@I^UZj^rBiK_1%19jue`W?4|*@d|5X@|;AjNV ziF4u-pq&i{0|v(ofWZTR*R4@M3;#TfudU(HyXhPg554ttI2UgbsJg3g-s1CASy}%1hHiA?p(WOM!$f#x4Qeq(J@-iA zV8y5fc0LITJi4=R^-1gMt##)$uJ<#CLehjM)}$&cUG0oFCbV&PYTb%3_qEM7=N|{- z{AEwh_Zx}3_&(|IZK6i`PnKu@!%}6&2B(_@3uhCgzm)2)gCV@$6XEen<1U6zI}A&+ zlj3uUKFFx++2(}~t5DImpT;(tt2LU4jljIIrLMYw53U^{pL9J;_(!2j9P?ALKu)C# z?Luo#-YJt+m5n^nwrVB9NIn&z$!I|{Y_`g3Be5<#FRw4hO)M@IN)ulyKjV2|BQjjK yr8@Q9u9P~Puc~1?pq~fJ_4hq<{p>cmxRM<=vUjCFsw$ecQvC;#bNIox1pole`V3J3 literal 556 zcmV+{0@M9LRzVVpcV_?j=J$L{C)TSuf4QM(qNNMW zB{OMsUK7fY6$^5aF?wA3FsHzVoy>XaBY(cpT1NTdcNgwLxx_uuc>w?~0pLU&4Mp!X z1bHb$v+MW!AdW!@5D$cS)dY1j09XLPbrX2>ZZabkMQ6Po3B4H-K&ahPS5Fr)JBoUDO+e_Op-Vaewk>>11TAecVy*+>?{&T zt{64I&c~^-k;0kRblRkP-{v4)I3JzU23u-RLQUo;f;T%KCB31tYWq~|2P=u zuX}R7UrXG@_i>AFT{Y={vON1AmL_vPklrMi2d{|#V%1*zTmG$K)kxt`8sySQ9Q>w3u@ { } catch {} try { - await fixture(['--concurrency=1', '--config', 'disabled-cache.cjs', '1pass.js', '2fail.js'], options); + await fixture(['--concurrency=1', '--config', 'disabled-cache.js', '1pass.js', '2fail.js'], options); } catch (error) { const timestamps = getTimestamps(error.stats); t.true(timestamps.passed < timestamps.failed); @@ -54,7 +54,7 @@ test.serial('scheduler disabled in CI', async t => { } catch {} try { - await fixture(['--concurrency=1', '--config', 'disabled-cache.cjs', '1pass.js', '2fail.js'], options); + await fixture(['--concurrency=1', '--config', 'disabled-cache.js', '1pass.js', '2fail.js'], options); } catch (error) { const timestamps = getTimestamps(error.stats); t.true(timestamps.passed < timestamps.failed); diff --git a/test/snapshot-regenerate-report/test.js b/test/snapshot-regenerate-report/test.js index 2d0a4ca39..4f670d5af 100644 --- a/test/snapshot-regenerate-report/test.js +++ b/test/snapshot-regenerate-report/test.js @@ -5,7 +5,7 @@ import test from '@ava/test'; import {set as setChalk} from '../../lib/chalk.js'; import {load} from '../../lib/snapshot-manager.js'; -import {set as setOptions} from '../../lib/worker/options.cjs'; +import {set as setOptions} from '../../lib/worker/options.js'; import {cwd, fixture} from '../helpers/exec.js'; setChalk({level: 0}); diff --git a/test/snapshot-removal/fixtures/fixed-snapshot-dir/test.js b/test/snapshot-removal/fixtures/fixed-snapshot-dir/test.js index 2f1562c68..320d0c02a 100644 --- a/test/snapshot-removal/fixtures/fixed-snapshot-dir/test.js +++ b/test/snapshot-removal/fixtures/fixed-snapshot-dir/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. if (process.env.TEMPLATE) { test('some snapshots', t => { diff --git a/test/snapshot-removal/fixtures/no-snapshots/test.js b/test/snapshot-removal/fixtures/no-snapshots/test.js index 8f3c1586a..af4a7ba19 100644 --- a/test/snapshot-removal/fixtures/no-snapshots/test.js +++ b/test/snapshot-removal/fixtures/no-snapshots/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. test('without snapshots', t => { t.pass(); diff --git a/test/snapshot-removal/fixtures/only-test/test.js b/test/snapshot-removal/fixtures/only-test/test.js index 271351342..99162e5f8 100644 --- a/test/snapshot-removal/fixtures/only-test/test.js +++ b/test/snapshot-removal/fixtures/only-test/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. if (process.env.TEMPLATE) { test('some snapshots', t => { diff --git a/test/snapshot-removal/fixtures/removal/test.js b/test/snapshot-removal/fixtures/removal/test.js index 2f1562c68..320d0c02a 100644 --- a/test/snapshot-removal/fixtures/removal/test.js +++ b/test/snapshot-removal/fixtures/removal/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. if (process.env.TEMPLATE) { test('some snapshots', t => { diff --git a/test/snapshot-removal/fixtures/skipped-snapshots-in-try/test.js b/test/snapshot-removal/fixtures/skipped-snapshots-in-try/test.js index dca74c7ea..ae6cd03cb 100644 --- a/test/snapshot-removal/fixtures/skipped-snapshots-in-try/test.js +++ b/test/snapshot-removal/fixtures/skipped-snapshots-in-try/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. if (process.env.TEMPLATE) { test('skipped snapshots in try', async t => { diff --git a/test/snapshot-removal/fixtures/skipped-snapshots/test.js b/test/snapshot-removal/fixtures/skipped-snapshots/test.js index d437185f3..559869a79 100644 --- a/test/snapshot-removal/fixtures/skipped-snapshots/test.js +++ b/test/snapshot-removal/fixtures/skipped-snapshots/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. if (process.env.TEMPLATE) { test('some snapshots', t => { diff --git a/test/snapshot-removal/fixtures/skipped-tests/test.js b/test/snapshot-removal/fixtures/skipped-tests/test.js index 50cd928af..885f1bc66 100644 --- a/test/snapshot-removal/fixtures/skipped-tests/test.js +++ b/test/snapshot-removal/fixtures/skipped-tests/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. if (process.env.TEMPLATE) { test('some snapshots', t => { diff --git a/test/snapshot-removal/fixtures/snapshot-dir/test/test.js b/test/snapshot-removal/fixtures/snapshot-dir/test/test.js index 2f1562c68..320d0c02a 100644 --- a/test/snapshot-removal/fixtures/snapshot-dir/test/test.js +++ b/test/snapshot-removal/fixtures/snapshot-dir/test/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. if (process.env.TEMPLATE) { test('some snapshots', t => { diff --git a/test/snapshot-removal/fixtures/try/test.js b/test/snapshot-removal/fixtures/try/test.js index 5b939d892..ae765fe06 100644 --- a/test/snapshot-removal/fixtures/try/test.js +++ b/test/snapshot-removal/fixtures/try/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. if (process.env.TEMPLATE) { test('snapshots in try', async t => { diff --git a/test/snapshot-tests/fixtures/corrupt/test.js b/test/snapshot-tests/fixtures/corrupt/test.js index 78eb6ceff..20131945d 100644 --- a/test/snapshot-tests/fixtures/corrupt/test.js +++ b/test/snapshot-tests/fixtures/corrupt/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); test('a snapshot', t => { t.snapshot('foo'); diff --git a/test/snapshot-tests/fixtures/large/test.js b/test/snapshot-tests/fixtures/large/test.js index 3a2a2c4c8..410e75777 100644 --- a/test/snapshot-tests/fixtures/large/test.js +++ b/test/snapshot-tests/fixtures/large/test.js @@ -1,6 +1,6 @@ -const {Buffer} = require('node:buffer'); +import {Buffer} from 'node:buffer'; -const test = require(process.env.TEST_AVA_REQUIRE_FROM); +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); for (let i = 0; i < 2; i++) { test(`large snapshot ${i}`, t => { diff --git a/test/snapshot-tests/fixtures/multiline-snapshot-label/test.js b/test/snapshot-tests/fixtures/multiline-snapshot-label/test.js index 65fc825ee..dc86abc47 100644 --- a/test/snapshot-tests/fixtures/multiline-snapshot-label/test.js +++ b/test/snapshot-tests/fixtures/multiline-snapshot-label/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); const f = () => [ 'Hello', diff --git a/test/snapshot-tests/fixtures/normalized-title-in-snapshots/test.js b/test/snapshot-tests/fixtures/normalized-title-in-snapshots/test.js index 636338f4e..5a5e9c514 100644 --- a/test/snapshot-tests/fixtures/normalized-title-in-snapshots/test.js +++ b/test/snapshot-tests/fixtures/normalized-title-in-snapshots/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); test('test\r\n\ttitle', t => { t.snapshot('Hello, World!'); @@ -9,4 +9,3 @@ test('test\r\n\ttitle', Object.assign(t => { }, { title: title => `macro\n${title}`, })); - diff --git a/test/snapshot-tests/fixtures/normalized-title-in-stdout/test.js b/test/snapshot-tests/fixtures/normalized-title-in-stdout/test.js index fd70ee505..bae145fe0 100644 --- a/test/snapshot-tests/fixtures/normalized-title-in-stdout/test.js +++ b/test/snapshot-tests/fixtures/normalized-title-in-stdout/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); test(`a rather wordy test title that is wrapped to meet line length requirements in diff --git a/test/snapshot-workflow/fixtures/adding-skipped-snapshots/test.js b/test/snapshot-workflow/fixtures/adding-skipped-snapshots/test.js index 4f9201b48..f21eda6b9 100644 --- a/test/snapshot-workflow/fixtures/adding-skipped-snapshots/test.js +++ b/test/snapshot-workflow/fixtures/adding-skipped-snapshots/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. test('foo', t => { t.snapshot({foo: 'one'}); diff --git a/test/snapshot-workflow/fixtures/adding-snapshots/test.js b/test/snapshot-workflow/fixtures/adding-snapshots/test.js index f6fef3a98..6b1f6d990 100644 --- a/test/snapshot-workflow/fixtures/adding-snapshots/test.js +++ b/test/snapshot-workflow/fixtures/adding-snapshots/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. test('foo', t => { t.snapshot({foo: 'one'}); diff --git a/test/snapshot-workflow/fixtures/adding-test/test.js b/test/snapshot-workflow/fixtures/adding-test/test.js index 72ed25883..e3c8d8c56 100644 --- a/test/snapshot-workflow/fixtures/adding-test/test.js +++ b/test/snapshot-workflow/fixtures/adding-test/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. test('foo', t => { t.snapshot({foo: 'one'}); diff --git a/test/snapshot-workflow/fixtures/changing-label/test.js b/test/snapshot-workflow/fixtures/changing-label/test.js index 0ff131aca..ea594ecf9 100644 --- a/test/snapshot-workflow/fixtures/changing-label/test.js +++ b/test/snapshot-workflow/fixtures/changing-label/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. test('foo', t => { t.snapshot({foo: 'one'}, process.env.TEMPLATE ? undefined : 'a new message'); diff --git a/test/snapshot-workflow/fixtures/changing-title/test.js b/test/snapshot-workflow/fixtures/changing-title/test.js index b3936d512..c258cfc36 100644 --- a/test/snapshot-workflow/fixtures/changing-title/test.js +++ b/test/snapshot-workflow/fixtures/changing-title/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. test(`a ${process.env.TEMPLATE ? '' : 'new '}title`, t => { t.snapshot({foo: 'one'}); diff --git a/test/snapshot-workflow/fixtures/commit-skip/test.js b/test/snapshot-workflow/fixtures/commit-skip/test.js index cdc9c20d4..f086b8a3b 100644 --- a/test/snapshot-workflow/fixtures/commit-skip/test.js +++ b/test/snapshot-workflow/fixtures/commit-skip/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. test('commit a skipped snapshot', async t => { t.snapshot(1); diff --git a/test/snapshot-workflow/fixtures/discard-skip/test.js b/test/snapshot-workflow/fixtures/discard-skip/test.js index d86aa2cc1..05cebb5ff 100644 --- a/test/snapshot-workflow/fixtures/discard-skip/test.js +++ b/test/snapshot-workflow/fixtures/discard-skip/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. test('discard a skipped snapshot', async t => { t.snapshot(1); diff --git a/test/snapshot-workflow/fixtures/filling-in-blanks/test.js b/test/snapshot-workflow/fixtures/filling-in-blanks/test.js index e80d187b8..6b7681ae1 100644 --- a/test/snapshot-workflow/fixtures/filling-in-blanks/test.js +++ b/test/snapshot-workflow/fixtures/filling-in-blanks/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. test('foo', t => { t.snapshot({foo: 'one'}); diff --git a/test/snapshot-workflow/fixtures/first-run/test.js b/test/snapshot-workflow/fixtures/first-run/test.js index 6113ba97a..c2e5d244f 100644 --- a/test/snapshot-workflow/fixtures/first-run/test.js +++ b/test/snapshot-workflow/fixtures/first-run/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. test('foo', t => { t.snapshot({foo: 'one'}); diff --git a/test/snapshot-workflow/fixtures/invalid-snapfile/test.js b/test/snapshot-workflow/fixtures/invalid-snapfile/test.js index 6a7ba3544..0d250d66c 100644 --- a/test/snapshot-workflow/fixtures/invalid-snapfile/test.js +++ b/test/snapshot-workflow/fixtures/invalid-snapfile/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. test('foo', t => { t.snapshot.skip({foo: 'one'}); diff --git a/test/snapshot-workflow/fixtures/removing-all-snapshots/test.js b/test/snapshot-workflow/fixtures/removing-all-snapshots/test.js index 27279c875..cd9a2bf13 100644 --- a/test/snapshot-workflow/fixtures/removing-all-snapshots/test.js +++ b/test/snapshot-workflow/fixtures/removing-all-snapshots/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. test('foo', t => { if (process.env.TEMPLATE) { diff --git a/test/snapshot-workflow/fixtures/removing-snapshots/test.js b/test/snapshot-workflow/fixtures/removing-snapshots/test.js index 0392e5ba3..7461df7f8 100644 --- a/test/snapshot-workflow/fixtures/removing-snapshots/test.js +++ b/test/snapshot-workflow/fixtures/removing-snapshots/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. test('foo', t => { t.snapshot({foo: 'one'}); diff --git a/test/snapshot-workflow/fixtures/removing-test/test.js b/test/snapshot-workflow/fixtures/removing-test/test.js index c812bfcfe..eb45cf810 100644 --- a/test/snapshot-workflow/fixtures/removing-test/test.js +++ b/test/snapshot-workflow/fixtures/removing-test/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. test('foo', t => { t.snapshot({foo: 'one'}); diff --git a/test/snapshot-workflow/fixtures/reorder/test.js b/test/snapshot-workflow/fixtures/reorder/test.js index 7d0405f2c..585c64701 100644 --- a/test/snapshot-workflow/fixtures/reorder/test.js +++ b/test/snapshot-workflow/fixtures/reorder/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. if (process.env.TEMPLATE) { test('first test', t => { diff --git a/test/snapshot-workflow/fixtures/select-test-update/test.js b/test/snapshot-workflow/fixtures/select-test-update/test.js index 10b2bc7b1..834ea005e 100644 --- a/test/snapshot-workflow/fixtures/select-test-update/test.js +++ b/test/snapshot-workflow/fixtures/select-test-update/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. test('foo', t => { t.snapshot(process.env.TEMPLATE ? {foo: 'one'} : {foo: 'new'}); diff --git a/test/snapshot-workflow/fixtures/skipping-snapshot-update/test.js b/test/snapshot-workflow/fixtures/skipping-snapshot-update/test.js index 74bdcc4e8..791188e09 100644 --- a/test/snapshot-workflow/fixtures/skipping-snapshot-update/test.js +++ b/test/snapshot-workflow/fixtures/skipping-snapshot-update/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. test('foo', t => { if (process.env.TEMPLATE) { diff --git a/test/snapshot-workflow/fixtures/skipping-snapshot/test.js b/test/snapshot-workflow/fixtures/skipping-snapshot/test.js index d6fa229e6..fbfd2ab05 100644 --- a/test/snapshot-workflow/fixtures/skipping-snapshot/test.js +++ b/test/snapshot-workflow/fixtures/skipping-snapshot/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. test('foo', t => { (process.env.TEMPLATE ? t.snapshot : t.snapshot.skip)({foo: 'one'}); diff --git a/test/snapshot-workflow/fixtures/skipping-test-update/test.js b/test/snapshot-workflow/fixtures/skipping-test-update/test.js index 80c39dbf4..e1a885023 100644 --- a/test/snapshot-workflow/fixtures/skipping-test-update/test.js +++ b/test/snapshot-workflow/fixtures/skipping-test-update/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. (process.env.TEMPLATE ? test : test.skip)('foo', t => { t.snapshot(process.env.TEMPLATE ? {foo: 'one'} : ['something new']); diff --git a/test/snapshot-workflow/fixtures/skipping-test/test.js b/test/snapshot-workflow/fixtures/skipping-test/test.js index 1ea62eb93..276b9d8fd 100644 --- a/test/snapshot-workflow/fixtures/skipping-test/test.js +++ b/test/snapshot-workflow/fixtures/skipping-test/test.js @@ -1,4 +1,4 @@ -const test = require(process.env.TEST_AVA_REQUIRE_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. +const {default: test} = await import(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so import AVA through its configured path. (process.env.TEMPLATE ? test : test.skip)('foo', t => { t.snapshot({foo: 'one'}); diff --git a/test/worker-threads/fixtures/child-process.config.mjs b/test/worker-threads/fixtures/child-process.config.js similarity index 100% rename from test/worker-threads/fixtures/child-process.config.mjs rename to test/worker-threads/fixtures/child-process.config.js diff --git a/test/worker-threads/test.js b/test/worker-threads/test.js index d600b0fce..32b1704ae 100644 --- a/test/worker-threads/test.js +++ b/test/worker-threads/test.js @@ -13,6 +13,6 @@ test('--no-worker-threads causes tests to run in a child process', async t => { }); test('`workerThreads: false` configuration causes tests to run in a child process', async t => { - const result = await t.throwsAsync(fixture(['--config=child-process.config.mjs'])); + const result = await t.throwsAsync(fixture(['--config=child-process.config.js'])); t.is(result.stats.failed.length, 1); }); diff --git a/types/assertions.d.cts b/types/assertions.d.ts similarity index 100% rename from types/assertions.d.cts rename to types/assertions.d.ts diff --git a/types/shared-worker.d.cts b/types/shared-worker.d.ts similarity index 100% rename from types/shared-worker.d.cts rename to types/shared-worker.d.ts diff --git a/types/state-change-events.d.cts b/types/state-change-events.d.ts similarity index 100% rename from types/state-change-events.d.cts rename to types/state-change-events.d.ts diff --git a/types/subscribable.d.cts b/types/subscribable.d.ts similarity index 100% rename from types/subscribable.d.cts rename to types/subscribable.d.ts diff --git a/types/test-fn.d.cts b/types/test-fn.d.ts similarity index 98% rename from types/test-fn.d.cts rename to types/test-fn.d.ts index 367a389c1..427017d0a 100644 --- a/types/test-fn.d.cts +++ b/types/test-fn.d.ts @@ -1,6 +1,6 @@ -import type {Assertions} from './assertions.cjs'; -import type {Subscribable} from './subscribable.cjs'; -import type {TryFn} from './try-fn.cjs'; +import type {Assertions} from './assertions.js'; +import type {Subscribable} from './subscribable.js'; +import type {TryFn} from './try-fn.js'; /** The `t` value passed to test & hook implementations. */ export type ExecutionContext = { diff --git a/types/try-fn.d.cts b/types/try-fn.d.ts similarity index 96% rename from types/try-fn.d.cts rename to types/try-fn.d.ts index 802c834db..dae3aa23e 100644 --- a/types/try-fn.d.cts +++ b/types/try-fn.d.ts @@ -1,4 +1,4 @@ -import type {Implementation} from './test-fn.cjs'; +import type {Implementation} from './test-fn.js'; export type CommitDiscardOptions = { /** @@ -55,4 +55,3 @@ export type TryFn = { */ (fn: Implementation, ...args: Args): Promise; }; - diff --git a/xo.config.mjs b/xo.config.js similarity index 97% rename from xo.config.mjs rename to xo.config.js index bbdee968b..53cc05504 100644 --- a/xo.config.mjs +++ b/xo.config.js @@ -10,7 +10,7 @@ const xoConfig = [ ignores: [ 'test/line-numbers/fixtures/line-numbers.js', 'test-tap/fixture/snapshots/test-sourcemaps/build/**', - 'test-tap/fixture/report/edgecases/ast-syntax-error.cjs', + 'test-tap/fixture/report/edgecases/ast-syntax-error.js', 'test-tap/fixture/**/*.ts', 'test-types', 'examples/typescript-*/**/*.ts', From e1791972f75afef18163179c7bab0349ed5676cf Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 9 Apr 2026 22:30:02 +0700 Subject: [PATCH 02/12] Fix CI --- test-tap/helper/report.js | 1 + test-tap/reporters/default.edgecases.v22.log | 6 +-- test-tap/reporters/default.edgecases.v24.log | 6 +-- test-tap/reporters/default.failfast.v22.log | 2 +- test-tap/reporters/default.failfast.v24.log | 2 +- test-tap/reporters/default.failfast2.v22.log | 2 +- test-tap/reporters/default.failfast2.v24.log | 2 +- test-tap/reporters/default.js | 1 + test-tap/reporters/default.regular.v22.log | 46 ++++++++++---------- test-tap/reporters/default.regular.v24.log | 46 ++++++++++---------- test-tap/reporters/tap.edgecases.v22.log | 8 ++-- test-tap/reporters/tap.edgecases.v24.log | 8 ++-- test-tap/reporters/tap.js | 10 ++++- test-tap/reporters/tap.regular.v22.log | 16 +++---- test-tap/reporters/tap.regular.v24.log | 16 +++---- test/watch-mode/availability.js | 2 + test/watch-mode/helpers/watch.js | 2 +- test/watch-mode/scenarios.js | 20 ++++----- 18 files changed, 98 insertions(+), 98 deletions(-) diff --git a/test-tap/helper/report.js b/test-tap/helper/report.js index b22e591eb..de9850d3a 100644 --- a/test-tap/helper/report.js +++ b/test-tap/helper/report.js @@ -43,6 +43,7 @@ const cwdFileUrlPrefix = pathToFileURL(process.cwd()); exports.sanitizers = { acorn: string => string.split('\n').filter(line => !/node_modules.acorn/.test(line)).join('\n'), cwd: string => string.replaceAll(cwdFileUrlPrefix, '').replaceAll(process.cwd(), '~'), + esmLoader: string => string.split('\n').filter(line => !line.includes('› async node:internal/modules/esm/loader:')).join('\n'), experimentalWarning: string => string.replaceAll(/^\(node:\d+\) ExperimentalWarning.+\n/g, ''), lineEndings: string => string.replaceAll('\r\n', '\n'), // The following are invjected by tap@18. diff --git a/test-tap/reporters/default.edgecases.v22.log b/test-tap/reporters/default.edgecases.v22.log index f6970e4d3..848a8a1b7 100644 --- a/test-tap/reporters/default.edgecases.v22.log +++ b/test-tap/reporters/default.edgecases.v22.log @@ -7,10 +7,6 @@ ---tty-stream-chunk-separator Uncaught exception in ast-syntax-error.js - ~/test-tap/fixture/report/edgecases/ast-syntax-error.js:3 - const fn = do { - ^^ - SyntaxError: Unexpected token 'do' ---tty-stream-chunk-separator @@ -29,7 +25,7 @@ TypeError: test is not a function - › Object. (test-tap/fixture/report/edgecases/import-and-use-test-member.js:3:1) + › file://test-tap/fixture/report/edgecases/import-and-use-test-member.js:3:1 ---tty-stream-chunk-separator ✘ import-and-use-test-member.js exited with a non-zero exit code: 1 diff --git a/test-tap/reporters/default.edgecases.v24.log b/test-tap/reporters/default.edgecases.v24.log index f6970e4d3..848a8a1b7 100644 --- a/test-tap/reporters/default.edgecases.v24.log +++ b/test-tap/reporters/default.edgecases.v24.log @@ -7,10 +7,6 @@ ---tty-stream-chunk-separator Uncaught exception in ast-syntax-error.js - ~/test-tap/fixture/report/edgecases/ast-syntax-error.js:3 - const fn = do { - ^^ - SyntaxError: Unexpected token 'do' ---tty-stream-chunk-separator @@ -29,7 +25,7 @@ TypeError: test is not a function - › Object. (test-tap/fixture/report/edgecases/import-and-use-test-member.js:3:1) + › file://test-tap/fixture/report/edgecases/import-and-use-test-member.js:3:1 ---tty-stream-chunk-separator ✘ import-and-use-test-member.js exited with a non-zero exit code: 1 diff --git a/test-tap/reporters/default.failfast.v22.log b/test-tap/reporters/default.failfast.v22.log index 50c902ba6..0fc2a3426 100644 --- a/test-tap/reporters/default.failfast.v22.log +++ b/test-tap/reporters/default.failfast.v22.log @@ -14,7 +14,7 @@ Test failed via `t.fail()` - › test-tap/fixture/report/failfast/a.js:3:22 + › file://test-tap/fixture/report/failfast/a.js:3:22 ─ diff --git a/test-tap/reporters/default.failfast.v24.log b/test-tap/reporters/default.failfast.v24.log index 50c902ba6..0fc2a3426 100644 --- a/test-tap/reporters/default.failfast.v24.log +++ b/test-tap/reporters/default.failfast.v24.log @@ -14,7 +14,7 @@ Test failed via `t.fail()` - › test-tap/fixture/report/failfast/a.js:3:22 + › file://test-tap/fixture/report/failfast/a.js:3:22 ─ diff --git a/test-tap/reporters/default.failfast2.v22.log b/test-tap/reporters/default.failfast2.v22.log index e3e69c25b..da6ebaa58 100644 --- a/test-tap/reporters/default.failfast2.v22.log +++ b/test-tap/reporters/default.failfast2.v22.log @@ -14,7 +14,7 @@ Test failed via `t.fail()` - › test-tap/fixture/report/failfast2/a.js:3:22 + › file://test-tap/fixture/report/failfast2/a.js:3:22 ─ diff --git a/test-tap/reporters/default.failfast2.v24.log b/test-tap/reporters/default.failfast2.v24.log index e3e69c25b..da6ebaa58 100644 --- a/test-tap/reporters/default.failfast2.v24.log +++ b/test-tap/reporters/default.failfast2.v24.log @@ -14,7 +14,7 @@ Test failed via `t.fail()` - › test-tap/fixture/report/failfast2/a.js:3:22 + › file://test-tap/fixture/report/failfast2/a.js:3:22 ─ diff --git a/test-tap/reporters/default.js b/test-tap/reporters/default.js index b786d9126..f04b5945e 100644 --- a/test-tap/reporters/default.js +++ b/test-tap/reporters/default.js @@ -21,6 +21,7 @@ test(async t => { sanitizers: [ ...sanitizers, report.sanitizers.cwd, + report.sanitizers.esmLoader, report.sanitizers.experimentalWarning, report.sanitizers.posix, report.sanitizers.tapLoaders, diff --git a/test-tap/reporters/default.regular.v22.log b/test-tap/reporters/default.regular.v22.log index 53b6fd344..6a784054f 100644 --- a/test-tap/reporters/default.regular.v22.log +++ b/test-tap/reporters/default.regular.v22.log @@ -10,7 +10,7 @@ TypeError: test.serial.test is not a function - › Object. (test-tap/fixture/report/regular/bad-test-chain.js:3:13) + › file://test-tap/fixture/report/regular/bad-test-chain.js:3:13 ---tty-stream-chunk-separator ✘ bad-test-chain.js exited with a non-zero exit code: 1 @@ -87,7 +87,7 @@ Error: Can’t catch me - › Immediate. (test-tap/fixture/report/regular/uncaught-exception.js:5:9) + › Immediate. (file://test-tap/fixture/report/regular/uncaught-exception.js:5:9) ---tty-stream-chunk-separator ✘ uncaught-exception.js exited with a non-zero exit code: 1 @@ -107,7 +107,7 @@ Error: Can’t catch me - › passes (test-tap/fixture/report/regular/unhandled-rejection.js:4:17) + › passes (file://test-tap/fixture/report/regular/unhandled-rejection.js:4:17) ---tty-stream-chunk-separator Unhandled rejection in unhandled-rejection.js @@ -144,7 +144,7 @@ + }, } - › test-tap/fixture/report/regular/nested-objects.js:29:4 + › file://test-tap/fixture/report/regular/nested-objects.js:29:4 @@ -167,7 +167,7 @@ }, } - › test-tap/fixture/report/regular/nested-objects.js:55:4 + › file://test-tap/fixture/report/regular/nested-objects.js:55:4 @@ -181,7 +181,7 @@ Test failed via `t.fail()` - › test-tap/fixture/report/regular/output-in-hook.js:34:4 + › file://test-tap/fixture/report/regular/output-in-hook.js:34:4 @@ -195,7 +195,7 @@ Test failed via `t.fail()` - › test-tap/fixture/report/regular/test.js:9:22 + › file://test-tap/fixture/report/regular/test.js:9:22 @@ -214,7 +214,7 @@ Test failed via `t.fail()` - › test-tap/fixture/report/regular/test.js:18:4 + › file://test-tap/fixture/report/regular/test.js:18:4 @@ -231,7 +231,7 @@ - 'foo' + 'bar' - › test-tap/fixture/report/regular/test.js:22:4 + › file://test-tap/fixture/report/regular/test.js:22:4 @@ -261,9 +261,9 @@ Function TypeError {} - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) - › t.throws.instanceOf (test-tap/fixture/report/regular/traces-in-t-throws.js:12:17) - › test-tap/fixture/report/regular/traces-in-t-throws.js:12:4 + › throwError (file://test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › t.throws.instanceOf (file://test-tap/fixture/report/regular/traces-in-t-throws.js:12:17) + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:12:4 @@ -281,9 +281,9 @@ message: 'uh-oh', } - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) - › test-tap/fixture/report/regular/traces-in-t-throws.js:16:20 - › test-tap/fixture/report/regular/traces-in-t-throws.js:16:4 + › throwError (file://test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:16:20 + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:16:4 @@ -301,9 +301,9 @@ message: 'uh-oh', } - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) - › test-tap/fixture/report/regular/traces-in-t-throws.js:20:31 - › test-tap/fixture/report/regular/traces-in-t-throws.js:20:10 + › throwError (file://test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:20:31 + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:20:10 @@ -321,9 +321,9 @@ message: 'uh-oh', } - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) - › t.throwsAsync.instanceOf (test-tap/fixture/report/regular/traces-in-t-throws.js:24:28) - › test-tap/fixture/report/regular/traces-in-t-throws.js:24:10 + › throwError (file://test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › t.throwsAsync.instanceOf (file://test-tap/fixture/report/regular/traces-in-t-throws.js:24:28) + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:24:10 @@ -345,8 +345,8 @@ Function TypeError {} - › returnRejectedPromise (test-tap/fixture/report/regular/traces-in-t-throws.js:8:24) - › test-tap/fixture/report/regular/traces-in-t-throws.js:28:10 + › returnRejectedPromise (file://test-tap/fixture/report/regular/traces-in-t-throws.js:8:24) + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:28:10 ─ diff --git a/test-tap/reporters/default.regular.v24.log b/test-tap/reporters/default.regular.v24.log index 53b6fd344..6a784054f 100644 --- a/test-tap/reporters/default.regular.v24.log +++ b/test-tap/reporters/default.regular.v24.log @@ -10,7 +10,7 @@ TypeError: test.serial.test is not a function - › Object. (test-tap/fixture/report/regular/bad-test-chain.js:3:13) + › file://test-tap/fixture/report/regular/bad-test-chain.js:3:13 ---tty-stream-chunk-separator ✘ bad-test-chain.js exited with a non-zero exit code: 1 @@ -87,7 +87,7 @@ Error: Can’t catch me - › Immediate. (test-tap/fixture/report/regular/uncaught-exception.js:5:9) + › Immediate. (file://test-tap/fixture/report/regular/uncaught-exception.js:5:9) ---tty-stream-chunk-separator ✘ uncaught-exception.js exited with a non-zero exit code: 1 @@ -107,7 +107,7 @@ Error: Can’t catch me - › passes (test-tap/fixture/report/regular/unhandled-rejection.js:4:17) + › passes (file://test-tap/fixture/report/regular/unhandled-rejection.js:4:17) ---tty-stream-chunk-separator Unhandled rejection in unhandled-rejection.js @@ -144,7 +144,7 @@ + }, } - › test-tap/fixture/report/regular/nested-objects.js:29:4 + › file://test-tap/fixture/report/regular/nested-objects.js:29:4 @@ -167,7 +167,7 @@ }, } - › test-tap/fixture/report/regular/nested-objects.js:55:4 + › file://test-tap/fixture/report/regular/nested-objects.js:55:4 @@ -181,7 +181,7 @@ Test failed via `t.fail()` - › test-tap/fixture/report/regular/output-in-hook.js:34:4 + › file://test-tap/fixture/report/regular/output-in-hook.js:34:4 @@ -195,7 +195,7 @@ Test failed via `t.fail()` - › test-tap/fixture/report/regular/test.js:9:22 + › file://test-tap/fixture/report/regular/test.js:9:22 @@ -214,7 +214,7 @@ Test failed via `t.fail()` - › test-tap/fixture/report/regular/test.js:18:4 + › file://test-tap/fixture/report/regular/test.js:18:4 @@ -231,7 +231,7 @@ - 'foo' + 'bar' - › test-tap/fixture/report/regular/test.js:22:4 + › file://test-tap/fixture/report/regular/test.js:22:4 @@ -261,9 +261,9 @@ Function TypeError {} - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) - › t.throws.instanceOf (test-tap/fixture/report/regular/traces-in-t-throws.js:12:17) - › test-tap/fixture/report/regular/traces-in-t-throws.js:12:4 + › throwError (file://test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › t.throws.instanceOf (file://test-tap/fixture/report/regular/traces-in-t-throws.js:12:17) + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:12:4 @@ -281,9 +281,9 @@ message: 'uh-oh', } - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) - › test-tap/fixture/report/regular/traces-in-t-throws.js:16:20 - › test-tap/fixture/report/regular/traces-in-t-throws.js:16:4 + › throwError (file://test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:16:20 + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:16:4 @@ -301,9 +301,9 @@ message: 'uh-oh', } - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) - › test-tap/fixture/report/regular/traces-in-t-throws.js:20:31 - › test-tap/fixture/report/regular/traces-in-t-throws.js:20:10 + › throwError (file://test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:20:31 + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:20:10 @@ -321,9 +321,9 @@ message: 'uh-oh', } - › throwError (test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) - › t.throwsAsync.instanceOf (test-tap/fixture/report/regular/traces-in-t-throws.js:24:28) - › test-tap/fixture/report/regular/traces-in-t-throws.js:24:10 + › throwError (file://test-tap/fixture/report/regular/traces-in-t-throws.js:4:8) + › t.throwsAsync.instanceOf (file://test-tap/fixture/report/regular/traces-in-t-throws.js:24:28) + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:24:10 @@ -345,8 +345,8 @@ Function TypeError {} - › returnRejectedPromise (test-tap/fixture/report/regular/traces-in-t-throws.js:8:24) - › test-tap/fixture/report/regular/traces-in-t-throws.js:28:10 + › returnRejectedPromise (file://test-tap/fixture/report/regular/traces-in-t-throws.js:8:24) + › file://test-tap/fixture/report/regular/traces-in-t-throws.js:28:10 ─ diff --git a/test-tap/reporters/tap.edgecases.v22.log b/test-tap/reporters/tap.edgecases.v22.log index c0d50ec38..fc14a9e48 100644 --- a/test-tap/reporters/tap.edgecases.v22.log +++ b/test-tap/reporters/tap.edgecases.v22.log @@ -1,10 +1,10 @@ TAP version 13 ---tty-stream-chunk-separator -not ok 1 - ~/test-tap/fixture/report/edgecases/ast-syntax-error.js:3 +not ok 1 - SyntaxError: Unexpected token 'do' --- name: SyntaxError message: Unexpected token 'do' - at: 'const fn = do {' + at: 'compileSourceTextModule (node:internal/modules/esm/utils:346:16)' ... ---tty-stream-chunk-separator not ok 2 - ast-syntax-error.js exited with a non-zero exit code: 1 @@ -15,9 +15,7 @@ not ok 4 - TypeError: test is not a function --- name: TypeError message: test is not a function - at: >- - Object. - (~/test-tap/fixture/report/edgecases/import-and-use-test-member.js:3:1) + at: '/test-tap/fixture/report/edgecases/import-and-use-test-member.js:3:1' ... ---tty-stream-chunk-separator not ok 5 - import-and-use-test-member.js exited with a non-zero exit code: 1 diff --git a/test-tap/reporters/tap.edgecases.v24.log b/test-tap/reporters/tap.edgecases.v24.log index c0d50ec38..8e86fe155 100644 --- a/test-tap/reporters/tap.edgecases.v24.log +++ b/test-tap/reporters/tap.edgecases.v24.log @@ -1,10 +1,10 @@ TAP version 13 ---tty-stream-chunk-separator -not ok 1 - ~/test-tap/fixture/report/edgecases/ast-syntax-error.js:3 +not ok 1 - SyntaxError: Unexpected token 'do' --- name: SyntaxError message: Unexpected token 'do' - at: 'const fn = do {' + at: 'compileSourceTextModule (node:internal/modules/esm/utils:318:16)' ... ---tty-stream-chunk-separator not ok 2 - ast-syntax-error.js exited with a non-zero exit code: 1 @@ -15,9 +15,7 @@ not ok 4 - TypeError: test is not a function --- name: TypeError message: test is not a function - at: >- - Object. - (~/test-tap/fixture/report/edgecases/import-and-use-test-member.js:3:1) + at: '/test-tap/fixture/report/edgecases/import-and-use-test-member.js:3:1' ... ---tty-stream-chunk-separator not ok 5 - import-and-use-test-member.js exited with a non-zero exit code: 1 diff --git a/test-tap/reporters/tap.js b/test-tap/reporters/tap.js index 9494121db..d2aad9d1d 100644 --- a/test-tap/reporters/tap.js +++ b/test-tap/reporters/tap.js @@ -18,7 +18,15 @@ test(async t => { const tty = new TTYStream({ columns: 200, - sanitizers: [...sanitizers, report.sanitizers.cwd, report.sanitizers.experimentalWarning, report.sanitizers.posix, report.sanitizers.tapLoaders, report.sanitizers.timers], + sanitizers: [ + ...sanitizers, + report.sanitizers.cwd, + report.sanitizers.esmLoader, + report.sanitizers.experimentalWarning, + report.sanitizers.posix, + report.sanitizers.tapLoaders, + report.sanitizers.timers, + ], }); const reporter = new TapReporter({ extensions: ['js'], diff --git a/test-tap/reporters/tap.regular.v22.log b/test-tap/reporters/tap.regular.v22.log index e573737e3..2f7956df9 100644 --- a/test-tap/reporters/tap.regular.v22.log +++ b/test-tap/reporters/tap.regular.v22.log @@ -4,7 +4,7 @@ not ok 1 - TypeError: test.serial.test is not a function --- name: TypeError message: test.serial.test is not a function - at: 'Object. (~/test-tap/fixture/report/regular/bad-test-chain.js:3:13)' + at: '/test-tap/fixture/report/regular/bad-test-chain.js:3:13' ... ---tty-stream-chunk-separator not ok 2 - bad-test-chain.js exited with a non-zero exit code: 1 @@ -158,7 +158,7 @@ not ok 16 - traces-in-t-throws › throws } 'Expected instance of:': 'Function TypeError {}' message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' + at: 'throwError (/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 17 - traces-in-t-throws › notThrows @@ -171,7 +171,7 @@ not ok 17 - traces-in-t-throws › notThrows message: 'uh-oh', } message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' + at: 'throwError (/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 18 - traces-in-t-throws › notThrowsAsync @@ -184,7 +184,7 @@ not ok 18 - traces-in-t-throws › notThrowsAsync message: 'uh-oh', } message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' + at: 'throwError (/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 19 - traces-in-t-throws › throwsAsync @@ -197,7 +197,7 @@ not ok 19 - traces-in-t-throws › throwsAsync message: 'uh-oh', } message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' + at: 'throwError (/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 20 - traces-in-t-throws › throwsAsync different error @@ -213,7 +213,7 @@ not ok 20 - traces-in-t-throws › throwsAsync different error message: '' at: >- returnRejectedPromise - (~/test-tap/fixture/report/regular/traces-in-t-throws.js:8:24) + (/test-tap/fixture/report/regular/traces-in-t-throws.js:8:24) ... ---tty-stream-chunk-separator ok 21 - uncaught-exception › passes @@ -224,7 +224,7 @@ not ok 22 - Error: Can’t catch me message: Can’t catch me at: >- Immediate. - (~/test-tap/fixture/report/regular/uncaught-exception.js:5:9) + (/test-tap/fixture/report/regular/uncaught-exception.js:5:9) ... ---tty-stream-chunk-separator not ok 23 - uncaught-exception.js exited with a non-zero exit code: 1 @@ -237,7 +237,7 @@ not ok 26 - Error: Can’t catch me --- name: Error message: Can’t catch me - at: 'passes (~/test-tap/fixture/report/regular/unhandled-rejection.js:4:17)' + at: 'passes (/test-tap/fixture/report/regular/unhandled-rejection.js:4:17)' ... ---tty-stream-chunk-separator not ok 27 - unhandled-rejection diff --git a/test-tap/reporters/tap.regular.v24.log b/test-tap/reporters/tap.regular.v24.log index e573737e3..2f7956df9 100644 --- a/test-tap/reporters/tap.regular.v24.log +++ b/test-tap/reporters/tap.regular.v24.log @@ -4,7 +4,7 @@ not ok 1 - TypeError: test.serial.test is not a function --- name: TypeError message: test.serial.test is not a function - at: 'Object. (~/test-tap/fixture/report/regular/bad-test-chain.js:3:13)' + at: '/test-tap/fixture/report/regular/bad-test-chain.js:3:13' ... ---tty-stream-chunk-separator not ok 2 - bad-test-chain.js exited with a non-zero exit code: 1 @@ -158,7 +158,7 @@ not ok 16 - traces-in-t-throws › throws } 'Expected instance of:': 'Function TypeError {}' message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' + at: 'throwError (/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 17 - traces-in-t-throws › notThrows @@ -171,7 +171,7 @@ not ok 17 - traces-in-t-throws › notThrows message: 'uh-oh', } message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' + at: 'throwError (/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 18 - traces-in-t-throws › notThrowsAsync @@ -184,7 +184,7 @@ not ok 18 - traces-in-t-throws › notThrowsAsync message: 'uh-oh', } message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' + at: 'throwError (/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 19 - traces-in-t-throws › throwsAsync @@ -197,7 +197,7 @@ not ok 19 - traces-in-t-throws › throwsAsync message: 'uh-oh', } message: '' - at: 'throwError (~/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' + at: 'throwError (/test-tap/fixture/report/regular/traces-in-t-throws.js:4:8)' ... ---tty-stream-chunk-separator not ok 20 - traces-in-t-throws › throwsAsync different error @@ -213,7 +213,7 @@ not ok 20 - traces-in-t-throws › throwsAsync different error message: '' at: >- returnRejectedPromise - (~/test-tap/fixture/report/regular/traces-in-t-throws.js:8:24) + (/test-tap/fixture/report/regular/traces-in-t-throws.js:8:24) ... ---tty-stream-chunk-separator ok 21 - uncaught-exception › passes @@ -224,7 +224,7 @@ not ok 22 - Error: Can’t catch me message: Can’t catch me at: >- Immediate. - (~/test-tap/fixture/report/regular/uncaught-exception.js:5:9) + (/test-tap/fixture/report/regular/uncaught-exception.js:5:9) ... ---tty-stream-chunk-separator not ok 23 - uncaught-exception.js exited with a non-zero exit code: 1 @@ -237,7 +237,7 @@ not ok 26 - Error: Can’t catch me --- name: Error message: Can’t catch me - at: 'passes (~/test-tap/fixture/report/regular/unhandled-rejection.js:4:17)' + at: 'passes (/test-tap/fixture/report/regular/unhandled-rejection.js:4:17)' ... ---tty-stream-chunk-separator not ok 27 - unhandled-rejection diff --git a/test/watch-mode/availability.js b/test/watch-mode/availability.js index b33deb2bc..4e4651c37 100644 --- a/test/watch-mode/availability.js +++ b/test/watch-mode/availability.js @@ -8,6 +8,8 @@ import {withFixture} from './helpers/watch.js'; if (available(fileURLToPath(import.meta.url))) { test('when available, watch mode works', withFixture('basic'), async (t, fixture) => { + t.timeout(30_000); + await fixture.watch({ async 1(result) { t.true(result.stats.passed.length > 0); diff --git a/test/watch-mode/helpers/watch.js b/test/watch-mode/helpers/watch.js index 54d3e2843..44706c9ca 100644 --- a/test/watch-mode/helpers/watch.js +++ b/test/watch-mode/helpers/watch.js @@ -129,7 +129,7 @@ export const withFixture = fixture => async (t, task) => { // but there seem to be // other isues. setTimeout(() => { - process.kill('SIGKILL'); + process?.kill('SIGKILL'); }, 1000).unref(); try { diff --git a/test/watch-mode/scenarios.js b/test/watch-mode/scenarios.js index 59ca14117..585301770 100644 --- a/test/watch-mode/scenarios.js +++ b/test/watch-mode/scenarios.js @@ -1,6 +1,6 @@ -import {test, withFixture} from './helpers/watch.js'; +import {serial, withFixture} from './helpers/watch.js'; -test('waits for changes', withFixture('basic'), async (t, fixture) => { +serial('waits for changes', withFixture('basic'), async (t, fixture) => { await fixture.watch({ async 1() { await this.assertIdle(); @@ -9,7 +9,7 @@ test('waits for changes', withFixture('basic'), async (t, fixture) => { }); }); -test('watcher can be configured to ignore files', withFixture('basic'), async (t, fixture) => { +serial('watcher can be configured to ignore files', withFixture('basic'), async (t, fixture) => { await fixture.watch({ async 1() { await this.assertIdle(async () => { @@ -20,7 +20,7 @@ test('watcher can be configured to ignore files', withFixture('basic'), async (t }); }); -test('new, empty directories are ignored', withFixture('basic'), async (t, fixture) => { +serial('new, empty directories are ignored', withFixture('basic'), async (t, fixture) => { await fixture.watch({ async 1() { await this.assertIdle(async () => { @@ -31,7 +31,7 @@ test('new, empty directories are ignored', withFixture('basic'), async (t, fixtu }); }); -test('runs test files that depend on the changed file', withFixture('basic'), async (t, fixture) => { +serial('runs test files that depend on the changed file', withFixture('basic'), async (t, fixture) => { await fixture.watch({ async 1() { await this.touch('source.js'); @@ -43,7 +43,7 @@ test('runs test files that depend on the changed file', withFixture('basic'), as }); }); -test('runs all test files if a file is changed that is not depended on', withFixture('basic'), async (t, fixture) => { +serial('runs all test files if a file is changed that is not depended on', withFixture('basic'), async (t, fixture) => { await fixture.watch({ async 1({stats}) { await this.touch('not-depended-on.js'); @@ -56,7 +56,7 @@ test('runs all test files if a file is changed that is not depended on', withFix }); }); -test('runs all test files if a new file is added', withFixture('basic'), async (t, fixture) => { +serial('runs all test files if a new file is added', withFixture('basic'), async (t, fixture) => { await fixture.watch({ async 1({stats}) { await this.write('new-file.js'); @@ -69,7 +69,7 @@ test('runs all test files if a new file is added', withFixture('basic'), async ( }); }); -test('does not run deleted test file, even if source it previously depended on is changed', withFixture('basic'), async (t, fixture) => { +serial('does not run deleted test file, even if source it previously depended on is changed', withFixture('basic'), async (t, fixture) => { await fixture.watch({ async 1() { await this.assertIdle(async () => { @@ -81,7 +81,7 @@ test('does not run deleted test file, even if source it previously depended on i }); }); -test('runs test file when source it depends on is deleted', withFixture('basic'), async (t, fixture) => { +serial('runs test file when source it depends on is deleted', withFixture('basic'), async (t, fixture) => { await fixture.watch({ async 1() { await this.rm('source.js'); @@ -95,7 +95,7 @@ test('runs test file when source it depends on is deleted', withFixture('basic') }); }); -test('filters test files', withFixture('basic'), async (t, fixture) => { +serial('filters test files', withFixture('basic'), async (t, fixture) => { await fixture.watch({ async 1({stats}) { t.false(stats.passed.some(({file}) => file === 'test.js')); From d44ae7b3681dbb4bbb80590586c36f57c8b1097d Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Sat, 11 Apr 2026 20:18:11 +0200 Subject: [PATCH 03/12] ava/plugin isn't meant to have a default export --- entrypoints/plugin.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/entrypoints/plugin.js b/entrypoints/plugin.js index 26442d45c..72e996f45 100644 --- a/entrypoints/plugin.js +++ b/entrypoints/plugin.js @@ -1,8 +1 @@ -import {registerSharedWorker} from '../lib/worker/plugin.js'; - -const plugin = { - registerSharedWorker, -}; - -export default plugin; export {registerSharedWorker} from '../lib/worker/plugin.js'; From 96968fc743295d9ac35caec701e5f13db292e86d Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Sat, 11 Apr 2026 20:28:38 +0200 Subject: [PATCH 04/12] Simplify require option initialization Loading is always done using import(), so we'll never get a function directly. --- lib/worker/base.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/worker/base.js b/lib/worker/base.js index 2a6d10904..3ad5c7b19 100644 --- a/lib/worker/base.js +++ b/lib/worker/base.js @@ -210,12 +210,8 @@ const run = async options => { try { for await (const [ref, ...args] of (options.require ?? [])) { - const loadedModule = await loadRequiredModule(ref); - - if (typeof loadedModule === 'function') { - await loadedModule(...args); - } else if (typeof loadedModule.default === 'function') { - const {default: fn} = loadedModule; + const {default: fn} = await loadRequiredModule(ref); + if (typeof fn === 'function') { await fn(...args); } } From 228ef944aae9a09fec55e7302d915d61c5b105e2 Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Sat, 11 Apr 2026 20:44:00 +0200 Subject: [PATCH 05/12] Break provider protocol --- lib/worker/base.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/worker/base.js b/lib/worker/base.js index 3ad5c7b19..7a5de284a 100644 --- a/lib/worker/base.js +++ b/lib/worker/base.js @@ -150,10 +150,6 @@ const run = async options => { // Store value to prevent required modules from modifying it. const testPath = options.file; - const extensionsToLoadAsModules = Object.entries(options.moduleTypes) - .filter(([, type]) => type === 'module') - .map(([extension]) => extension); - // Install before processing options.require, so if helpers are added to the // require configuration the *compiled* helper will be loaded. const {projectDir, providerStates = []} = options; @@ -161,14 +157,14 @@ const run = async options => { await Promise.all(providerStates.map(async ({type, state, protocol}) => { if (type === 'typescript') { const provider = await providerManager.typescript(projectDir, {protocol}); - providers.push(provider.worker({extensionsToLoadAsModules, state})); + providers.push(provider.worker({state})); } })); const load = async ref => { for (const provider of providers) { if (provider.canLoad(ref)) { - return provider.load(ref, {}); + return provider.load(ref); } } From 711ae8e44c16163293fb385889f1dbf1ea7c50ea Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Sat, 11 Apr 2026 20:44:36 +0200 Subject: [PATCH 06/12] Validate extensions configuration values during normalization, remove unused module type setup --- lib/api.js | 2 +- lib/cli.js | 11 --- lib/extensions.js | 23 +++++- lib/module-types.js | 74 ------------------ test-tap/api.js | 2 - test-tap/helper/report.js | 2 - .../snapshots/invalid-configurations.js.md | 6 +- .../snapshots/invalid-configurations.js.snap | Bin 273 -> 273 bytes 8 files changed, 26 insertions(+), 94 deletions(-) delete mode 100644 lib/module-types.js diff --git a/lib/api.js b/lib/api.js index 7c6403da2..8bcd47f9a 100644 --- a/lib/api.js +++ b/lib/api.js @@ -77,7 +77,7 @@ export default class Api extends Emittery { constructor(options) { super(); - this.options = {match: [], moduleTypes: {}, ...options}; + this.options = {match: [], ...options}; this.options.require = normalizeRequireOption(this.options.require); this._cacheDir = null; diff --git a/lib/cli.js b/lib/cli.js index a970e8a66..f62887755 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -17,7 +17,6 @@ import {normalizeGlobs, normalizePattern} from './globs.js'; import isCi from './is-ci.js'; import {splitPatternAndLineNumbers} from './line-numbers.js'; import {loadConfig} from './load-config.js'; -import normalizeModuleTypes from './module-types.js'; import normalizeNodeArguments from './node-arguments.js'; import pkg from './pkg.js'; @@ -334,8 +333,6 @@ export default async function loadCli() { // eslint-disable-line complexity console.log(chalk.magenta(` ${figures.warning} Experiments are enabled. These are unsupported and may change or be removed at any time.`)); } - const defaultModuleType = 'module'; - const providers = []; if (Object.hasOwn(conf, 'typescript')) { const {default: providerManager} = await import('./provider-manager.js'); @@ -366,13 +363,6 @@ export default async function loadCli() { // eslint-disable-line complexity exit(error.message); } - let moduleTypes; - try { - moduleTypes = normalizeModuleTypes(conf.extensions, defaultModuleType); - } catch (error) { - exit(error.message); - } - let globs; try { globs = normalizeGlobs({ @@ -427,7 +417,6 @@ export default async function loadCli() { // eslint-disable-line complexity failWithoutAssertions: combined.failWithoutAssertions !== false, globs, match, - moduleTypes, nodeArguments, parallelRuns, sortTestFiles: conf.sortTestFiles, diff --git a/lib/extensions.js b/lib/extensions.js index dd8b7dc2b..d246c8d2f 100644 --- a/lib/extensions.js +++ b/lib/extensions.js @@ -3,7 +3,28 @@ export default function resolveExtensions(configuredExtensions, providers = []) const duplicates = new Set(); const seen = new Set(); - const normalize = extensions => Array.isArray(extensions) ? extensions : Object.keys(extensions); + const normalize = extensions => { + if (Array.isArray(extensions)) { + return extensions; + } + + const keys = Object.keys(extensions); + for (const key of keys) { + if (key === 'js' || key === 'mjs') { + if (extensions[key] !== true) { + throw new TypeError(`When specifying extensions, use \`true\` for \u2018${key}\u2019 extensions`); + } + + continue; + } + + if (extensions[key] !== 'module') { + throw new TypeError(`When specifying extensions, the value for \u2018${key}\u2019 must be \u2018module\u2019`); + } + } + + return keys; + }; const combine = extensions => { for (const ext of normalize(extensions)) { diff --git a/lib/module-types.js b/lib/module-types.js deleted file mode 100644 index 577c59fb6..000000000 --- a/lib/module-types.js +++ /dev/null @@ -1,74 +0,0 @@ -const requireTrueValue = (value, extension) => { - if (value !== true) { - throw new TypeError(`When specifying module types, use \`true\` for \u2018${extension}\u2019 extensions`); - } -}; - -const normalize = (extension, type) => { - switch (extension) { - case 'mjs': { - requireTrueValue(type, extension); - return 'module'; - } - - case 'js': { - requireTrueValue(type, extension); - return 'module'; - } - - default: { - if (type !== 'module') { - throw new TypeError(`Module type for \u2018${extension}\u2019 must be \u2018module\u2019`); - } - - return type; - } - } -}; - -const deriveFromObject = extensionsObject => { - const moduleTypes = {}; - for (const [extension, type] of Object.entries(extensionsObject)) { - moduleTypes[extension] = normalize(extension, type); - } - - return moduleTypes; -}; - -const deriveFromArray = extensions => { - const moduleTypes = {}; - for (const extension of extensions) { - switch (extension) { - case 'mjs': { - moduleTypes.mjs = 'module'; - break; - } - - case 'js': { - moduleTypes.js = 'module'; - break; - } - - default: { - moduleTypes[extension] = 'module'; - } - } - } - - return moduleTypes; -}; - -export default function moduleTypes(configuredExtensions) { - if (configuredExtensions === undefined) { - return { - mjs: 'module', - js: 'module', - }; - } - - if (Array.isArray(configuredExtensions)) { - return deriveFromArray(configuredExtensions); - } - - return deriveFromObject(configuredExtensions); -} diff --git a/test-tap/api.js b/test-tap/api.js index e4cc34bf3..7b1f24849 100644 --- a/test-tap/api.js +++ b/test-tap/api.js @@ -8,7 +8,6 @@ import {test} from 'tap'; import Api from '../lib/api.js'; import normalizeExtensions from '../lib/extensions.js'; import {normalizeGlobs} from '../lib/globs.js'; -import normalizeModuleTypes from '../lib/module-types.js'; const __dirname = fileURLToPath(new URL('.', import.meta.url)); const ROOT_DIR = path.join(__dirname, '..'); @@ -21,7 +20,6 @@ async function apiCreator(options = {}) { options.concurrency = 2; options.experiments = {}; options.extensions = normalizeExtensions(options.extensions, providers); - options.moduleTypes ??= normalizeModuleTypes(options.extensions, 'module'); options.globs = normalizeGlobs({ files: options.files, ignoredByWatcher: options.watchMode?.ignoreChanges, extensions: options.extensions, providers, }); diff --git a/test-tap/helper/report.js b/test-tap/helper/report.js index de9850d3a..8370c31e3 100644 --- a/test-tap/helper/report.js +++ b/test-tap/helper/report.js @@ -7,7 +7,6 @@ import {globbySync} from 'globby'; import Api from '../../lib/api.js'; import {_testOnlyReplaceWorkerPath} from '../../lib/fork.js'; import {normalizeGlobs} from '../../lib/globs.js'; -import normalizeModuleTypes from '../../lib/module-types.js'; import pkg from '../../lib/pkg.js'; _testOnlyReplaceWorkerPath(new URL('report-worker.js', import.meta.url)); @@ -84,7 +83,6 @@ const run = async (type, reporter, {match = [], filter} = {}) => { }, }; - options.moduleTypes = normalizeModuleTypes(options.extensions, 'module'); options.globs = normalizeGlobs({extensions: options.extensions, files: ['*'], providers}); const api = new Api(options); diff --git a/test/configurable-module-format/snapshots/invalid-configurations.js.md b/test/configurable-module-format/snapshots/invalid-configurations.js.md index e7c9fbd3b..056c46e7f 100644 --- a/test/configurable-module-format/snapshots/invalid-configurations.js.md +++ b/test/configurable-module-format/snapshots/invalid-configurations.js.md @@ -8,16 +8,16 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 - 'When specifying module types, use `true` for ‘js’ extensions' + 'When specifying extensions, use `true` for ‘js’ extensions' ## cannot configure how mjs extensions should be loaded > Snapshot 1 - 'When specifying module types, use `true` for ‘mjs’ extensions' + 'When specifying extensions, use `true` for ‘mjs’ extensions' ## custom extensions must be modules > Snapshot 1 - 'Module type for ‘ts’ must be ‘module’' + 'When specifying extensions, the value for ‘ts’ must be ‘module’' diff --git a/test/configurable-module-format/snapshots/invalid-configurations.js.snap b/test/configurable-module-format/snapshots/invalid-configurations.js.snap index 25a5bb7339a99132411311bc005b5cdecf403e88..377cfc0355648e3d4ca4c74d3fb905dbea868714 100644 GIT binary patch literal 273 zcmV+s0q*`mRzVOr29ur+>QJT$WdtS0p2a4%XSFltr`sr( zfD(?jCy5qmrA2{Ay!z?A@0_nZ=`a4dpg8fkA8QpO322JBTc;Ai(hfEZxEGAfq}R`ey|=l=2wb3c`N73?XKMtB5tdRWTtZGI z)YWmrb#>}=TH53;Ej(+R-Poqj*}@~-t4=Hwx|EPu8b~0MJn~=3=Z)n3KZ#g`t?~(5 Xh+G}*MI*bu)Ya)1W3MBT(*Xbg(cO6V literal 273 zcmV+s0q*`mRzVHAD|F=&Uj`WIu{!y$rT)$}*0tsjesm)@EkkdCT8E`Ea*ivBN zoT4+ZKyaiC8p}Zy^(egC8>2*heLf^lN%IDe$@5@5%P{~KsBOBjAp=h)It1Ai$gdC? zVJ>CFIiyrVwf$Xkwf#FQcDT`1oWEB$?dd-5)%jbz7adv1pJRNzG?e2_zO=meEW^pE X-Q}dMb%&aM`==fcgc@&xy#W9Kr6qj^ From 232b0b8c3c8a43f40fc8668eea3bdc48cad8160c Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Sat, 11 Apr 2026 20:47:06 +0200 Subject: [PATCH 07/12] Allow AVA to be configured to import .cjs files In object form, this needs to be specified as cjs: true. --- lib/extensions.js | 2 +- .../fixtures/change-cjs-loading.config.js | 5 +++++ .../invalid-configurations.js | 5 +++++ .../snapshots/invalid-configurations.js.md | 6 ++++++ .../snapshots/invalid-configurations.js.snap | Bin 273 -> 280 bytes 5 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 test/configurable-module-format/fixtures/change-cjs-loading.config.js diff --git a/lib/extensions.js b/lib/extensions.js index d246c8d2f..ce3c743bb 100644 --- a/lib/extensions.js +++ b/lib/extensions.js @@ -10,7 +10,7 @@ export default function resolveExtensions(configuredExtensions, providers = []) const keys = Object.keys(extensions); for (const key of keys) { - if (key === 'js' || key === 'mjs') { + if (key === 'js' || key === 'cjs' || key === 'mjs') { if (extensions[key] !== true) { throw new TypeError(`When specifying extensions, use \`true\` for \u2018${key}\u2019 extensions`); } diff --git a/test/configurable-module-format/fixtures/change-cjs-loading.config.js b/test/configurable-module-format/fixtures/change-cjs-loading.config.js new file mode 100644 index 000000000..efe50f56d --- /dev/null +++ b/test/configurable-module-format/fixtures/change-cjs-loading.config.js @@ -0,0 +1,5 @@ +export default { + extensions: { + cjs: 'module', + }, +}; diff --git a/test/configurable-module-format/invalid-configurations.js b/test/configurable-module-format/invalid-configurations.js index 3dd04d541..42a7e5d85 100644 --- a/test/configurable-module-format/invalid-configurations.js +++ b/test/configurable-module-format/invalid-configurations.js @@ -7,6 +7,11 @@ test('cannot configure how js extensions should be loaded', async t => { t.snapshot(cleanOutput(result.stderr)); }); +test('cannot configure how cjs extensions should be loaded', async t => { + const result = await t.throwsAsync(fixture(['--config', 'change-cjs-loading.config.js'])); + t.snapshot(cleanOutput(result.stderr)); +}); + test('cannot configure how mjs extensions should be loaded', async t => { const result = await t.throwsAsync(fixture(['--config', 'change-mjs-loading.config.js'])); t.snapshot(cleanOutput(result.stderr)); diff --git a/test/configurable-module-format/snapshots/invalid-configurations.js.md b/test/configurable-module-format/snapshots/invalid-configurations.js.md index 056c46e7f..3674418f3 100644 --- a/test/configurable-module-format/snapshots/invalid-configurations.js.md +++ b/test/configurable-module-format/snapshots/invalid-configurations.js.md @@ -10,6 +10,12 @@ Generated by [AVA](https://avajs.dev). 'When specifying extensions, use `true` for ‘js’ extensions' +## cannot configure how cjs extensions should be loaded + +> Snapshot 1 + + 'When specifying extensions, use `true` for ‘cjs’ extensions' + ## cannot configure how mjs extensions should be loaded > Snapshot 1 diff --git a/test/configurable-module-format/snapshots/invalid-configurations.js.snap b/test/configurable-module-format/snapshots/invalid-configurations.js.snap index 377cfc0355648e3d4ca4c74d3fb905dbea868714..f8883f32f290b5fe9974c3ebd0e648d5db647f1b 100644 GIT binary patch literal 280 zcmV+z0q6cfRzV&OdpE~00000000BM&OL4dF%SjdMG;EP4TheM)S*n1ln6?UJ&O&t2kngc={8ah z0VN!5PZBNCN{f;pZIf3&z4u-6r6;}NuPcfZkB6~VF_M6$n7dUf5G?Is&435N$c`cd zTT0%*62X%)XdFkiWlO@J7h{yD`TJA$oYm>|vqA55W-$V9QM>%;;;OYZg2V_5DH1Lq zrvj?-wC1Wjw>k~&cn-UUB4GCnDNB$|9-bvmb eNyH-Tluy_|Or29ur+>QJT$WdtS0p2a4%XSFltr`sr( zfD(?jCy5qmrA2{Ay!z?A@0_nZ=`a4dpg8fkA8QpO322JBTc;Ai(hfEZxEGAfq}R`ey|=l=2wb3c`N73?XKMtB5tdRWTtZGI z)YWmrb#>}=TH53;Ej(+R-Poqj*}@~-t4=Hwx|EPu8b~0MJn~=3=Z)n3KZ#g`t?~(5 Xh+G}*MI*bu)Ya)1W3MBT(*Xbg(cO6V From 7054c810c62879de1cd0fecc4c18ccfb723b1ded Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Sat, 11 Apr 2026 20:53:40 +0200 Subject: [PATCH 08/12] Install ESM-only slash via dependency --- lib/glob-helpers.js | 3 +-- lib/slash.js | 33 --------------------------------- lib/snapshot-manager.js | 2 +- package-lock.json | 1 + package.json | 1 + 5 files changed, 4 insertions(+), 36 deletions(-) delete mode 100644 lib/slash.js diff --git a/lib/glob-helpers.js b/lib/glob-helpers.js index a2248408d..1b87b5be0 100644 --- a/lib/glob-helpers.js +++ b/lib/glob-helpers.js @@ -3,8 +3,7 @@ import process from 'node:process'; import ignoreByDefault from 'ignore-by-default'; import picomatch from 'picomatch'; - -import slash from './slash.js'; +import slash from 'slash'; const defaultIgnorePatterns = [...ignoreByDefault.directories(), '**/node_modules']; export {defaultIgnorePatterns}; diff --git a/lib/slash.js b/lib/slash.js deleted file mode 100644 index d483b3e56..000000000 --- a/lib/slash.js +++ /dev/null @@ -1,33 +0,0 @@ -/* -Inlined from -. - -Copyright 2023 Sindre Sorhus - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -export default function slash(path) { - const isExtendedLengthPath = path.startsWith('\\\\?\\'); - - if (isExtendedLengthPath) { - return path; - } - - return path.replaceAll('\\', '/'); -} diff --git a/lib/snapshot-manager.js b/lib/snapshot-manager.js index 7c3524fa4..647f7fcfd 100644 --- a/lib/snapshot-manager.js +++ b/lib/snapshot-manager.js @@ -10,10 +10,10 @@ import cbor from 'cbor'; import concordance from 'concordance'; import indentString from 'indent-string'; import memoize from 'memoize'; +import slash from 'slash'; import writeFileAtomic from 'write-file-atomic'; import {snapshotManager as concordanceOptions} from './concordance-options.js'; -import slash from './slash.js'; // Increment if encoding layout or Concordance serialization versions change. Previous AVA versions will not be able to // decode buffers generated by a newer version, so changing this value will require a major version bump of AVA itself. diff --git a/package-lock.json b/package-lock.json index 68e51985b..940181082 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,6 +43,7 @@ "plur": "^6.0.0", "pretty-ms": "^9.3.0", "resolve-cwd": "^3.0.0", + "slash": "^5.1.0", "stack-utils": "^2.0.6", "supertap": "^3.0.1", "temp-dir": "^3.0.0", diff --git a/package.json b/package.json index 87e7c2c87..31b1390af 100644 --- a/package.json +++ b/package.json @@ -108,6 +108,7 @@ "plur": "^6.0.0", "pretty-ms": "^9.3.0", "resolve-cwd": "^3.0.0", + "slash": "^5.1.0", "stack-utils": "^2.0.6", "supertap": "^3.0.1", "temp-dir": "^3.0.0", From 41abaa2d3bc138a261700e43bb123bf4c3e68c34 Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Sat, 11 Apr 2026 21:09:35 +0200 Subject: [PATCH 09/12] Mark @ava/typescript-dependent tests as failing --- test/globs/test.js | 2 +- test/watch-mode/typescript.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/globs/test.js b/test/globs/test.js index dae4d621c..ce0fbb2e4 100644 --- a/test/globs/test.js +++ b/test/globs/test.js @@ -31,7 +31,7 @@ test('files can be filtered by directory', async t => { t.snapshot(result.stats.passed); }); -test('additional files can be provided', async t => { +test.failing('additional files can be provided', async t => { const options = { cwd: cwd('treat-patterns-as-files'), }; diff --git a/test/watch-mode/typescript.js b/test/watch-mode/typescript.js index fd3d96e11..20578953f 100644 --- a/test/watch-mode/typescript.js +++ b/test/watch-mode/typescript.js @@ -3,7 +3,7 @@ import path from 'node:path'; import {test, withFixture} from './helpers/watch.js'; -test('waits for external compiler before re-running typescript test files', withFixture('typescript-precompiled'), async (t, fixture) => { +test.failing('waits for external compiler before re-running typescript test files', withFixture('typescript-precompiled'), async (t, fixture) => { await fixture.watch({ async 1({stats}) { t.true(stats.passed.length > 0); @@ -55,7 +55,7 @@ test('handles deletion of precompiled and source files (single possible source f }, [], {env: {JUST_TS_EXTENSION: 'true'}}); }); -test('handles inline compilation', withFixture('typescript-inline'), async (t, fixture) => { +test.failing('handles inline compilation', withFixture('typescript-inline'), async (t, fixture) => { await fs.symlink(new URL('../../node_modules', import.meta.url), path.join(fixture.dir, 'node_modules'), 'junction'); await fixture.watch({ async 1({stats}) { @@ -70,7 +70,7 @@ test('handles inline compilation', withFixture('typescript-inline'), async (t, f }); }); -test('ignores changes to compiled files with inline compilation', withFixture('typescript-inline'), async (t, fixture) => { +test.failing('ignores changes to compiled files with inline compilation', withFixture('typescript-inline'), async (t, fixture) => { await fs.symlink(new URL('../../node_modules', import.meta.url), path.join(fixture.dir, 'node_modules'), 'junction'); await fixture.watch({ async 1({stats}) { From 3cce96fad027ea5f37884fcd42ae34cb4510a60b Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Sun, 12 Apr 2026 21:18:25 +0200 Subject: [PATCH 10/12] Disallow extension config in object form --- docs/06-configuration.md | 18 +---------- lib/extensions.js | 29 +++--------------- .../fixtures/array-extensions.config.js | 3 -- .../fixtures/bad-custom-type.config.js | 6 ---- .../fixtures/change-cjs-loading.config.js | 5 --- .../fixtures/change-js-loading.config.js | 5 --- .../fixtures/change-mjs-loading.config.js | 5 --- .../fixtures/object-extensions.config.js | 6 ---- .../fixtures/package.json | 3 -- .../fixtures/test.js | 5 --- .../fixtures/test.mjs | 5 --- .../invalid-configurations.js | 23 -------------- test/configurable-module-format/module.js | 24 --------------- .../snapshots/invalid-configurations.js.md | 29 ------------------ .../snapshots/invalid-configurations.js.snap | Bin 280 -> 0 bytes .../fixtures/object-form/package.json | 7 +++++ test/extensions/snapshots/test.js.md | 6 ++++ test/extensions/snapshots/test.js.snap | Bin 253 -> 290 bytes test/extensions/test.js | 7 +++++ 19 files changed, 26 insertions(+), 160 deletions(-) delete mode 100644 test/configurable-module-format/fixtures/array-extensions.config.js delete mode 100644 test/configurable-module-format/fixtures/bad-custom-type.config.js delete mode 100644 test/configurable-module-format/fixtures/change-cjs-loading.config.js delete mode 100644 test/configurable-module-format/fixtures/change-js-loading.config.js delete mode 100644 test/configurable-module-format/fixtures/change-mjs-loading.config.js delete mode 100644 test/configurable-module-format/fixtures/object-extensions.config.js delete mode 100644 test/configurable-module-format/fixtures/package.json delete mode 100644 test/configurable-module-format/fixtures/test.js delete mode 100644 test/configurable-module-format/fixtures/test.mjs delete mode 100644 test/configurable-module-format/invalid-configurations.js delete mode 100644 test/configurable-module-format/module.js delete mode 100644 test/configurable-module-format/snapshots/invalid-configurations.js.md delete mode 100644 test/configurable-module-format/snapshots/invalid-configurations.js.snap create mode 100644 test/extensions/fixtures/object-form/package.json diff --git a/docs/06-configuration.md b/docs/06-configuration.md index cdced2713..c1c769b3c 100644 --- a/docs/06-configuration.md +++ b/docs/06-configuration.md @@ -55,7 +55,7 @@ Arguments passed to the CLI will always take precedence over the CLI options con - `tap`: if `true`, enables the [TAP reporter](./05-command-line.md#tap-reporter) - `verbose`: if `true`, enables verbose output (though there currently non-verbose output is not supported) - `snapshotDir`: specifies a fixed location for storing snapshot files. Use this if your snapshots are ending up in the wrong location -- `extensions`: extensions of test files. Setting this overrides the default `["mjs", "js"]` value, so make sure to include those extensions in the list. [Experimentally you can configure how files are loaded](#configuring-module-formats) +- `extensions`: extensions of test files. Setting this overrides the default `["mjs", "js"]` value, so make sure to include those extensions in the list. - `require`: [extra modules to load before test files](#requiring-extra-modules) - `timeout`: Timeouts in AVA behave differently than in other test frameworks. AVA resets a timer after each test, forcing tests to quit if no new test results were received within the specified timeout. This can be used to handle stalled tests. See our [timeout documentation](./07-test-timeouts.md) for more options. - `nodeArguments`: Configure Node.js arguments used to launch worker processes. @@ -209,22 +209,6 @@ export default { }; ``` -## Configuring module formats - -Node.js can only load non-standard extension as ES Modules when using [experimental loaders](https://nodejs.org/docs/latest/api/esm.html#esm_experimental_loaders). To use this you'll also have to configure AVA to `import()` your test file. - -As with the array form, you need to explicitly list `js` and `mjs` extensions. These **must** be set using the `true` value; other extensions are configurable using `'module'`: - -`ava.config.js`: -```js -export default { - extensions: { - js: true, - ts: 'module' - } -}; -``` - ## Requiring extra modules Use the `require` configuration to load extra modules before test files are loaded. Relative paths are resolved against the project directory and can be loaded through `@ava/typescript`. Otherwise, modules are loaded from within the `node_modules` directory inside the project. diff --git a/lib/extensions.js b/lib/extensions.js index ce3c743bb..cf340ba97 100644 --- a/lib/extensions.js +++ b/lib/extensions.js @@ -3,31 +3,8 @@ export default function resolveExtensions(configuredExtensions, providers = []) const duplicates = new Set(); const seen = new Set(); - const normalize = extensions => { - if (Array.isArray(extensions)) { - return extensions; - } - - const keys = Object.keys(extensions); - for (const key of keys) { - if (key === 'js' || key === 'cjs' || key === 'mjs') { - if (extensions[key] !== true) { - throw new TypeError(`When specifying extensions, use \`true\` for \u2018${key}\u2019 extensions`); - } - - continue; - } - - if (extensions[key] !== 'module') { - throw new TypeError(`When specifying extensions, the value for \u2018${key}\u2019 must be \u2018module\u2019`); - } - } - - return keys; - }; - const combine = extensions => { - for (const ext of normalize(extensions)) { + for (const ext of extensions) { if (seen.has(ext)) { duplicates.add(ext); } else { @@ -37,6 +14,10 @@ export default function resolveExtensions(configuredExtensions, providers = []) }; if (configuredExtensions !== undefined) { + if (!Array.isArray(configuredExtensions)) { + throw new TypeError('The extensions option must be an array'); + } + combine(configuredExtensions); } diff --git a/test/configurable-module-format/fixtures/array-extensions.config.js b/test/configurable-module-format/fixtures/array-extensions.config.js deleted file mode 100644 index 1d9c0d23a..000000000 --- a/test/configurable-module-format/fixtures/array-extensions.config.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - extensions: ['js', 'mjs'], -}; diff --git a/test/configurable-module-format/fixtures/bad-custom-type.config.js b/test/configurable-module-format/fixtures/bad-custom-type.config.js deleted file mode 100644 index 0821a3b9c..000000000 --- a/test/configurable-module-format/fixtures/bad-custom-type.config.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - extensions: { - js: true, - ts: 'script', - }, -}; diff --git a/test/configurable-module-format/fixtures/change-cjs-loading.config.js b/test/configurable-module-format/fixtures/change-cjs-loading.config.js deleted file mode 100644 index efe50f56d..000000000 --- a/test/configurable-module-format/fixtures/change-cjs-loading.config.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - extensions: { - cjs: 'module', - }, -}; diff --git a/test/configurable-module-format/fixtures/change-js-loading.config.js b/test/configurable-module-format/fixtures/change-js-loading.config.js deleted file mode 100644 index 016c4b27c..000000000 --- a/test/configurable-module-format/fixtures/change-js-loading.config.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - extensions: { - js: 'module', - }, -}; diff --git a/test/configurable-module-format/fixtures/change-mjs-loading.config.js b/test/configurable-module-format/fixtures/change-mjs-loading.config.js deleted file mode 100644 index 2db2a1698..000000000 --- a/test/configurable-module-format/fixtures/change-mjs-loading.config.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - extensions: { - mjs: 'module', - }, -}; diff --git a/test/configurable-module-format/fixtures/object-extensions.config.js b/test/configurable-module-format/fixtures/object-extensions.config.js deleted file mode 100644 index b95e15e54..000000000 --- a/test/configurable-module-format/fixtures/object-extensions.config.js +++ /dev/null @@ -1,6 +0,0 @@ -export default { - extensions: { - js: true, - mjs: true, - }, -}; diff --git a/test/configurable-module-format/fixtures/package.json b/test/configurable-module-format/fixtures/package.json deleted file mode 100644 index bedb411a9..000000000 --- a/test/configurable-module-format/fixtures/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "module" -} diff --git a/test/configurable-module-format/fixtures/test.js b/test/configurable-module-format/fixtures/test.js deleted file mode 100644 index b9c488ebb..000000000 --- a/test/configurable-module-format/fixtures/test.js +++ /dev/null @@ -1,5 +0,0 @@ -import test from 'ava'; - -test('always passing test', t => { - t.pass(); -}); diff --git a/test/configurable-module-format/fixtures/test.mjs b/test/configurable-module-format/fixtures/test.mjs deleted file mode 100644 index b9c488ebb..000000000 --- a/test/configurable-module-format/fixtures/test.mjs +++ /dev/null @@ -1,5 +0,0 @@ -import test from 'ava'; - -test('always passing test', t => { - t.pass(); -}); diff --git a/test/configurable-module-format/invalid-configurations.js b/test/configurable-module-format/invalid-configurations.js deleted file mode 100644 index 42a7e5d85..000000000 --- a/test/configurable-module-format/invalid-configurations.js +++ /dev/null @@ -1,23 +0,0 @@ -import test from '@ava/test'; - -import {cleanOutput, fixture} from '../helpers/exec.js'; - -test('cannot configure how js extensions should be loaded', async t => { - const result = await t.throwsAsync(fixture(['--config', 'change-js-loading.config.js'])); - t.snapshot(cleanOutput(result.stderr)); -}); - -test('cannot configure how cjs extensions should be loaded', async t => { - const result = await t.throwsAsync(fixture(['--config', 'change-cjs-loading.config.js'])); - t.snapshot(cleanOutput(result.stderr)); -}); - -test('cannot configure how mjs extensions should be loaded', async t => { - const result = await t.throwsAsync(fixture(['--config', 'change-mjs-loading.config.js'])); - t.snapshot(cleanOutput(result.stderr)); -}); - -test('custom extensions must be modules', async t => { - const result = await t.throwsAsync(fixture(['--config', 'bad-custom-type.config.js'])); - t.snapshot(cleanOutput(result.stderr)); -}); diff --git a/test/configurable-module-format/module.js b/test/configurable-module-format/module.js deleted file mode 100644 index 110c57d23..000000000 --- a/test/configurable-module-format/module.js +++ /dev/null @@ -1,24 +0,0 @@ -import test from '@ava/test'; - -import {fixture} from '../helpers/exec.js'; - -test('load mjs as module (default configuration)', async t => { - const result = await fixture(['*.mjs']); - const files = new Set(result.stats.passed.map(({file}) => file)); - t.is(files.size, 1); - t.true(files.has('test.mjs')); -}); - -test('load mjs as module (using an extensions array)', async t => { - const result = await fixture(['*.mjs', '--config', 'array-extensions.config.js']); - const files = new Set(result.stats.passed.map(({file}) => file)); - t.is(files.size, 1); - t.true(files.has('test.mjs')); -}); - -test('load mjs as module (using an extensions object)', async t => { - const result = await fixture(['*.mjs', '--config', 'object-extensions.config.js']); - const files = new Set(result.stats.passed.map(({file}) => file)); - t.is(files.size, 1); - t.true(files.has('test.mjs')); -}); diff --git a/test/configurable-module-format/snapshots/invalid-configurations.js.md b/test/configurable-module-format/snapshots/invalid-configurations.js.md deleted file mode 100644 index 3674418f3..000000000 --- a/test/configurable-module-format/snapshots/invalid-configurations.js.md +++ /dev/null @@ -1,29 +0,0 @@ -# Snapshot report for `test/configurable-module-format/invalid-configurations.js` - -The actual snapshot is saved in `invalid-configurations.js.snap`. - -Generated by [AVA](https://avajs.dev). - -## cannot configure how js extensions should be loaded - -> Snapshot 1 - - 'When specifying extensions, use `true` for ‘js’ extensions' - -## cannot configure how cjs extensions should be loaded - -> Snapshot 1 - - 'When specifying extensions, use `true` for ‘cjs’ extensions' - -## cannot configure how mjs extensions should be loaded - -> Snapshot 1 - - 'When specifying extensions, use `true` for ‘mjs’ extensions' - -## custom extensions must be modules - -> Snapshot 1 - - 'When specifying extensions, the value for ‘ts’ must be ‘module’' diff --git a/test/configurable-module-format/snapshots/invalid-configurations.js.snap b/test/configurable-module-format/snapshots/invalid-configurations.js.snap deleted file mode 100644 index f8883f32f290b5fe9974c3ebd0e648d5db647f1b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 280 zcmV+z0q6cfRzV&OdpE~00000000BM&OL4dF%SjdMG;EP4TheM)S*n1ln6?UJ&O&t2kngc={8ah z0VN!5PZBNCN{f;pZIf3&z4u-6r6;}NuPcfZkB6~VF_M6$n7dUf5G?Is&435N$c`cd zTT0%*62X%)XdFkiWlO@J7h{yD`TJA$oYm>|vqA55W-$V9QM>%;;;OYZg2V_5DH1Lq zrvj?-wC1Wjw>k~&cn-UUB4GCnDNB$|9-bvmb eNyH-Tluy_| fails with message 'Unexpected duplicate extensions in options: ’tsx’.' + +## errors if extensions is not an array + +> fails with message + + 'The extensions option must be an array' diff --git a/test/extensions/snapshots/test.js.snap b/test/extensions/snapshots/test.js.snap index 350025324424952c4c049f6fc0f3a486814f70fd..086c454b39a96895ab229e050a8ae662997f23b3 100644 GIT binary patch literal 290 zcmV+-0p0#VRzVG1OUgNB1+KtinhCv-0JTOzIR*s| zP8v_(nK0E16{UH||9 literal 253 zcmVq}jr5}q300000000A(kFjb3K@>$-L{jGu-Up~)lOmOcb-IA7I1Y5OHXLI^@Yywz>)<(zZ9lH@=2bb+x6ni)z-MTu*&lqZ56gwPnGa*9eEy=((0 zY_qU;24#&d>pGbpFCjQ{%eP_mR9!O|RnLR@dqk7r4dHKfdr2wVwZ2l{b{p;6Zv4}l zzU`(Ew}O<~u_*1?*7OBc_kmyL`G3qV2C_qj`oh^BRao38ygaC2cfh{^+T0 { + const result = await t.throwsAsync(fixture([], { + cwd: cwd('object-form'), + })); + t.snapshot(cleanOutput(result.stderr), 'fails with message'); +}); From 18cd65c133058d53f0480acac6ab5fd3b50e97c5 Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Thu, 16 Apr 2026 21:56:27 +0200 Subject: [PATCH 11/12] Upgrade provider protocol to ava-8 --- lib/provider-manager.js | 9 +++++---- lib/watcher.js | 2 -- package-lock.json | 12 ++++++------ package.json | 2 +- test/globs/test.js | 2 +- test/watch-mode/typescript.js | 6 +++--- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/lib/provider-manager.js b/lib/provider-manager.js index 0acc345f5..762b224be 100644 --- a/lib/provider-manager.js +++ b/lib/provider-manager.js @@ -1,14 +1,15 @@ import * as globs from './globs.js'; import pkg from './pkg.js'; +// Provides an integer representation of the protocol level. This is internal to a particular AVA installation, and +// allows other parts of AVA to assert minimum protocol levels for certain features without having to hardcode +// identifier strings. Integer values can be reused across protocols when older identifiers are removed. export const levels = { - // As the protocol changes, comparing levels by integer allows AVA to be - // compatible with different versions. - ava6: 1, + ava8: 1, }; const levelsByProtocol = Object.assign(Object.create(null), { - 'ava-6': levels.ava6, + 'ava-8': levels.ava8, }); async function load(providerModule, projectDir, selectProtocol = () => true) { diff --git a/lib/watcher.js b/lib/watcher.js index f4fb67ec0..f4912fae5 100644 --- a/lib/watcher.js +++ b/lib/watcher.js @@ -12,7 +12,6 @@ import { applyTestFileFilter, classify, buildIgnoreMatcher, findTests, normalizePattern, } from './globs.js'; -import {levels as providerLevels} from './provider-manager.js'; const debug = createDebug('ava:watcher'); @@ -158,7 +157,6 @@ const promptForMatchPattern = async (reporter, lineReader, currentPattern) => { }; export async function start({api, filter, globs, projectDir, providers, reporter, stdin, signal}) { - providers = providers.filter(({level}) => level >= providerLevels.ava6); for await (const {files, testFileSelector, ...runtimeOptions} of plan({ api, filter, diff --git a/package-lock.json b/package-lock.json index 940181082..94947b79e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -55,7 +55,7 @@ }, "devDependencies": { "@ava/test": "github:avajs/test", - "@ava/typescript": "^6.0.0", + "@ava/typescript": "^7.0.0", "@sindresorhus/tsconfig": "^8.1.0", "@types/node": "^24.12.2", "ansi-escapes": "^7.3.0", @@ -122,17 +122,17 @@ } }, "node_modules/@ava/typescript": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@ava/typescript/-/typescript-6.0.0.tgz", - "integrity": "sha512-+8oDYc4J5cCaWZh1VUbyc+cegGplJO9FqHpqR4LVAVx8fRLVRaYlC4yyA6cqHJ1vWP23Ff/ECS5U68Zz6OLZlg==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@ava/typescript/-/typescript-7.0.0.tgz", + "integrity": "sha512-0ktzq4/9ya2QoAuVWzl3McpLV9W//Tj+oMonQ4ucgm5l6tQ46aaju/rJL9kzeY5MkG6wzXvFt/MmaLqf9uNC9w==", "dev": true, "license": "MIT", "dependencies": { "escape-string-regexp": "^5.0.0", - "execa": "^9.6.0" + "execa": "^9.6.1" }, "engines": { - "node": "^20.8 || ^22 || >=24" + "node": "^22.20 || ^24.12 || >=25" } }, "node_modules/@ava/v7": { diff --git a/package.json b/package.json index 31b1390af..02ee24a8b 100644 --- a/package.json +++ b/package.json @@ -117,7 +117,7 @@ }, "devDependencies": { "@ava/test": "github:avajs/test", - "@ava/typescript": "^6.0.0", + "@ava/typescript": "^7.0.0", "@sindresorhus/tsconfig": "^8.1.0", "@types/node": "^24.12.2", "ansi-escapes": "^7.3.0", diff --git a/test/globs/test.js b/test/globs/test.js index ce0fbb2e4..dae4d621c 100644 --- a/test/globs/test.js +++ b/test/globs/test.js @@ -31,7 +31,7 @@ test('files can be filtered by directory', async t => { t.snapshot(result.stats.passed); }); -test.failing('additional files can be provided', async t => { +test('additional files can be provided', async t => { const options = { cwd: cwd('treat-patterns-as-files'), }; diff --git a/test/watch-mode/typescript.js b/test/watch-mode/typescript.js index 20578953f..fd3d96e11 100644 --- a/test/watch-mode/typescript.js +++ b/test/watch-mode/typescript.js @@ -3,7 +3,7 @@ import path from 'node:path'; import {test, withFixture} from './helpers/watch.js'; -test.failing('waits for external compiler before re-running typescript test files', withFixture('typescript-precompiled'), async (t, fixture) => { +test('waits for external compiler before re-running typescript test files', withFixture('typescript-precompiled'), async (t, fixture) => { await fixture.watch({ async 1({stats}) { t.true(stats.passed.length > 0); @@ -55,7 +55,7 @@ test('handles deletion of precompiled and source files (single possible source f }, [], {env: {JUST_TS_EXTENSION: 'true'}}); }); -test.failing('handles inline compilation', withFixture('typescript-inline'), async (t, fixture) => { +test('handles inline compilation', withFixture('typescript-inline'), async (t, fixture) => { await fs.symlink(new URL('../../node_modules', import.meta.url), path.join(fixture.dir, 'node_modules'), 'junction'); await fixture.watch({ async 1({stats}) { @@ -70,7 +70,7 @@ test.failing('handles inline compilation', withFixture('typescript-inline'), asy }); }); -test.failing('ignores changes to compiled files with inline compilation', withFixture('typescript-inline'), async (t, fixture) => { +test('ignores changes to compiled files with inline compilation', withFixture('typescript-inline'), async (t, fixture) => { await fs.symlink(new URL('../../node_modules', import.meta.url), path.join(fixture.dir, 'node_modules'), 'junction'); await fixture.watch({ async 1({stats}) { From bcdcf1629d745dce161fef8d4d6a3774085bfa0f Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Sun, 26 Apr 2026 21:08:56 +0200 Subject: [PATCH 12/12] Update extensions in TypeScript recipe --- docs/recipes/typescript.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/recipes/typescript.md b/docs/recipes/typescript.md index 7d7dd69d5..0f335794e 100644 --- a/docs/recipes/typescript.md +++ b/docs/recipes/typescript.md @@ -37,9 +37,7 @@ There are two components to a setup like this: ```json "ava": { - "extensions": { - "ts": "module" - }, + "extensions": ["ts"], "nodeArguments": [ "--import=tsimp" ]