├── test ├── .fake-root ├── node_modules │ ├── ava │ └── .bin │ │ └── test-ava ├── config │ ├── fixtures │ │ ├── js-as-cjs │ │ │ ├── package.json │ │ │ └── ava.config.js │ │ ├── mjs │ │ │ ├── package.json │ │ │ ├── ava.config.mjs │ │ │ ├── no-default-export.mjs │ │ │ └── error.mjs │ │ ├── config-errors │ │ │ ├── ava.config.js │ │ │ ├── package.json │ │ │ └── test.js │ │ ├── js-as-esm │ │ │ ├── package.json │ │ │ ├── ava.config.js │ │ │ ├── no-default-export.js │ │ │ └── error.js │ │ ├── promise-config │ │ │ ├── package.json │ │ │ └── ava.config.js │ │ ├── monorepo │ │ │ ├── package │ │ │ │ ├── package.json │ │ │ │ └── foo.js │ │ │ └── ava.config.mjs │ │ ├── factory-promise-return │ │ │ ├── package.json │ │ │ └── ava.config.js │ │ ├── file-yes-cjs-yes-mjs-yes │ │ │ ├── package.json │ │ │ ├── ava.config.cjs │ │ │ ├── ava.config.js │ │ │ └── ava.config.mjs │ │ ├── mjs-with-tests │ │ │ ├── ava.config.mjs │ │ │ ├── dir-a │ │ │ │ ├── dir-a-base-1.js │ │ │ │ └── dir-a-base-2.js │ │ │ ├── package.json │ │ │ └── dir-a-wrapper │ │ │ │ └── dir-a │ │ │ │ ├── dir-a-wrapper-3.js │ │ │ │ └── dir-a-wrapper-4.js │ │ └── pkg-with-tests │ │ │ ├── dir-a │ │ │ ├── dir-a-base-1.js │ │ │ └── dir-a-base-2.js │ │ │ ├── dir-a-wrapper │ │ │ └── dir-a │ │ │ │ ├── dir-a-wrapper-3.js │ │ │ │ └── dir-a-wrapper-4.js │ │ │ └── package.json │ └── snapshots │ │ ├── loader.js.snap │ │ ├── next-gen.js.snap │ │ └── integration.js.snap ├── snapshot-removal │ ├── fixtures │ │ ├── removal │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ ├── test.js.md │ │ │ └── test.js │ │ ├── try │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ └── test.js.md │ │ ├── no-snapshots │ │ │ ├── package.json │ │ │ └── test.js │ │ ├── only-test │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ └── test.js.md │ │ ├── snapshot-dir │ │ │ ├── package.json │ │ │ └── test │ │ │ │ └── snapshots │ │ │ │ ├── test.js.snap │ │ │ │ └── test.js.md │ │ ├── skipped-snapshots │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ └── test.js.md │ │ ├── skipped-tests │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ └── test.js.md │ │ ├── skipped-snapshots-in-try │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ └── test.js.md │ │ └── fixed-snapshot-dir │ │ │ ├── package.json │ │ │ └── fixedSnapshotDir │ │ │ ├── test.js.snap │ │ │ └── test.js.md │ └── snapshots │ │ └── test.js.snap ├── snapshot-tests │ ├── fixtures │ │ ├── corrupt │ │ │ ├── package.json │ │ │ └── test.js │ │ ├── large │ │ │ ├── package.json │ │ │ └── test.js │ │ ├── multiline-snapshot-label │ │ │ ├── package.json │ │ │ └── test.js │ │ ├── normalized-title-in-snapshots │ │ │ ├── package.json │ │ │ └── test.js │ │ └── normalized-title-in-stdout │ │ │ └── package.json │ ├── snapshots │ │ ├── corrupt.js.snap │ │ ├── formatting.js.snap │ │ └── corrupt.js.md │ └── large.js ├── snapshot-workflow │ ├── fixtures │ │ ├── adding-test │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ ├── test.js.md │ │ │ └── test.js │ │ ├── commit-skip │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ ├── test.js.md │ │ │ └── test.js │ │ ├── first-run │ │ │ ├── package.json │ │ │ └── test.js │ │ ├── reorder │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ ├── test.js.md │ │ │ └── test.js │ │ ├── adding-snapshots │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ ├── test.js.md │ │ │ └── test.js │ │ ├── changing-label │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ ├── test.js.md │ │ │ └── test.js │ │ ├── changing-title │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ ├── test.js.md │ │ │ └── test.js │ │ ├── discard-skip │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ └── test.js.md │ │ ├── invalid-snapfile │ │ │ ├── package.json │ │ │ └── test.js │ │ ├── removing-test │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ ├── test.js.md │ │ │ └── test.js │ │ ├── skipping-test │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ ├── test.js │ │ │ └── test.js.md │ │ ├── filling-in-blanks │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ ├── test.js.md │ │ │ └── test.js │ │ ├── removing-snapshots │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ ├── test.js │ │ │ └── test.js.md │ │ ├── select-test-update │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ ├── test.js.md │ │ │ └── test.js │ │ ├── skipping-snapshot │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ ├── test.js │ │ │ └── test.js.md │ │ ├── skipping-test-update │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ ├── test.js.md │ │ │ └── test.js │ │ ├── adding-skipped-snapshots │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ ├── test.js.md │ │ │ └── test.js │ │ ├── removing-all-snapshots │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ ├── test.js.md │ │ │ └── test.js │ │ └── skipping-snapshot-update │ │ │ ├── package.json │ │ │ ├── test.js.snap │ │ │ ├── test.js.md │ │ │ └── test.js │ ├── snapshots │ │ ├── adding.js.snap │ │ ├── reorder.js.snap │ │ ├── selection.js.snap │ │ ├── try-skip.js.snap │ │ ├── changing-label.js.snap │ │ ├── removing-test.js.snap │ │ ├── invalid-snapfile.js.snap │ │ ├── removing-snapshots.js.snap │ │ └── removing-all-snapshots.js.snap │ ├── removing-test.js │ └── reorder.js ├── shared-workers │ ├── worker-startup-crashes │ │ ├── fixtures │ │ │ ├── _no-factory-function.js │ │ │ ├── _module.js │ │ │ ├── _factory-function.js │ │ │ ├── package.json │ │ │ ├── module.js │ │ │ ├── factory-function.js │ │ │ └── no-factory-function.js │ │ └── snapshots │ │ │ ├── test.js.snap │ │ │ └── test.js.md │ ├── worker-protocol │ │ ├── fixtures │ │ │ ├── package.json │ │ │ ├── other.test.js │ │ │ ├── _plugin.js │ │ │ └── test.js │ │ ├── snapshots │ │ │ └── test.js.snap │ │ └── test.js │ ├── worker-execution-crash │ │ ├── fixtures │ │ │ ├── package.json │ │ │ ├── _plugin.js │ │ │ ├── _worker.js │ │ │ └── test.js │ │ ├── snapshots │ │ │ ├── test.js.snap │ │ │ └── test.js.md │ │ └── test.js │ ├── cannot-publish-before-available │ │ ├── fixtures │ │ │ ├── package.json │ │ │ ├── _worker.js │ │ │ └── test.js │ │ ├── snapshots │ │ │ ├── test.js.snap │ │ │ └── test.js.md │ │ └── test.js │ ├── restricted-to-worker-threads │ │ ├── fixtures │ │ │ ├── package.json │ │ │ ├── _worker.js │ │ │ └── test.js │ │ └── test.js │ ├── lifecycle │ │ ├── fixtures │ │ │ ├── package.json │ │ │ ├── _worker.js │ │ │ └── available.js │ │ └── test.js │ ├── unsupported-protocol │ │ ├── fixtures │ │ │ ├── package.json │ │ │ ├── _worker.js │ │ │ ├── in-test-worker.js │ │ │ └── in-shared-worker.js │ │ └── snapshots │ │ │ └── test.js.snap │ └── workers-are-loaded-once │ │ ├── fixtures │ │ ├── package.json │ │ ├── test-1.js │ │ ├── test-2.js │ │ ├── _worker.js │ │ └── _plugin.js │ │ └── test.js ├── worker-threads │ └── fixtures │ │ ├── package.json │ │ ├── child-process.config.mjs │ │ └── test.js ├── configurable-module-format │ ├── fixtures │ │ ├── package.json │ │ ├── array-custom.config.js │ │ ├── array-extensions.config.js │ │ ├── change-js-loading.config.js │ │ ├── test.js │ │ ├── change-cjs-loading.config.js │ │ ├── change-mjs-loading.config.js │ │ ├── test.mjs │ │ ├── test.cjs │ │ ├── bad-custom-type.config.js │ │ ├── object-custom.config.js │ │ ├── object-extensions.config.js │ │ └── test.ts │ └── snapshots │ │ └── invalid-configurations.js.snap ├── snapshot-order │ ├── fixtures │ │ ├── randomness │ │ │ ├── package.json │ │ │ └── test.js.snap │ │ ├── intertest-order │ │ │ └── package.json │ │ └── report-declaration-order │ │ │ └── package.json │ ├── snapshots │ │ └── randomness.js.snap │ └── helpers │ │ └── get-snapshot-ids.js ├── snapshot-regenerate-report │ └── fixtures │ │ └── package.json ├── node-arguments │ ├── fixtures │ │ ├── node-arguments-from-config │ │ │ ├── setup.cjs │ │ │ ├── package.json │ │ │ └── node-arguments-from-config.js │ │ └── node-arguments │ │ │ ├── package.json │ │ │ └── node-arguments.js │ └── snapshots │ │ └── test.js.snap ├── multiple-implementations │ ├── fixtures │ │ ├── test.js │ │ ├── try.js │ │ └── package.json │ └── test.js ├── environment-variables │ ├── fixtures │ │ ├── environment-variables │ │ │ ├── package.json │ │ │ ├── ava.config.js │ │ │ └── environment-variables.js │ │ └── invalid-environment-variables │ │ │ └── package.json │ └── snapshots │ │ └── test.js.snap ├── cjs-default │ ├── fixtures │ │ ├── package.json │ │ └── test.cjs │ └── test.js ├── globs │ ├── fixtures │ │ ├── files │ │ │ └── package.json │ │ ├── filter-by-directory │ │ │ ├── test.js │ │ │ ├── directory │ │ │ │ └── test.js │ │ │ └── package.json │ │ ├── ignored-by-watcher │ │ │ └── package.json │ │ └── treat-patterns-as-files │ │ │ ├── test.js │ │ │ ├── foo.js │ │ │ ├── _helper.js │ │ │ ├── foo.ts │ │ │ ├── node_modules │ │ │ └── test.js │ │ │ └── package.json │ └── snapshots │ │ └── test.js.snap ├── assertions │ ├── snapshots │ │ └── test.js.snap │ ├── fixtures │ │ ├── happy-path.js.snap │ │ ├── package.json │ │ └── happy-path.js.md │ └── test.js ├── concurrency │ ├── fixtures │ │ ├── concurrency.js │ │ └── package.json │ └── snapshots │ │ └── test.js.snap ├── extensions │ ├── snapshots │ │ ├── test.js.snap │ │ └── test.js.md │ ├── fixtures │ │ ├── top-level │ │ │ └── package.json │ │ ├── top-level-duplicates │ │ │ └── package.json │ │ └── shared-duplicates │ │ │ └── package.json │ └── test.js ├── line-numbers │ ├── snapshots │ │ └── test.js.snap │ └── fixtures │ │ ├── package.json │ │ └── README.md ├── macros │ ├── fixtures │ │ ├── package.json │ │ └── macros.js │ └── test.js ├── scheduler │ └── fixtures │ │ ├── disabled-cache.cjs │ │ ├── package.json │ │ ├── 1pass.js │ │ └── 2fail.js ├── test-timeouts │ ├── snapshots │ │ ├── test.js.snap │ │ └── test.js.md │ └── fixtures │ │ ├── package.json │ │ ├── invalid-message.js │ │ └── custom-message.js ├── hook-restrictions │ ├── snapshots │ │ ├── test.js.snap │ │ └── test.js.md │ └── fixtures │ │ ├── package.json │ │ ├── invalid-snapshots-in-hooks.js │ │ └── invalid-t-try-in-hooks.js ├── builtin-nodejs-assert │ └── fixtures │ │ ├── package.json │ │ └── assert-failure.js ├── meta │ ├── fixtures │ │ ├── package.json │ │ ├── meta.mjs │ │ └── meta.cjs │ └── test.js ├── helpers │ └── with-temporary-fixture.js └── README.md ├── test-d ├── .gitignore ├── plugin.ts ├── like.ts ├── implementation-result.ts └── snapshot.ts ├── test-tap ├── fixture │ ├── .fake-root │ ├── symlink │ ├── ava-paths │ │ ├── cwd │ │ │ └── .gitkeep │ │ └── target │ │ │ └── test.cjs │ ├── with-dependencies │ │ ├── dep-1.js │ │ ├── dep-2.js │ │ ├── dep-3.custom │ │ ├── require-custom.cjs │ │ ├── no-tests.cjs │ │ ├── test.cjs │ │ ├── test-failure.cjs │ │ └── test-uncaught-exception.cjs │ ├── report │ │ ├── only │ │ │ ├── package.json │ │ │ ├── b.cjs │ │ │ └── a.cjs │ │ ├── edgecases │ │ │ ├── no-ava-import.cjs │ │ │ ├── throws.cjs │ │ │ ├── test.cjs │ │ │ ├── ava-import-no-test-declaration.cjs │ │ │ ├── import-and-use-test-member.cjs │ │ │ └── ast-syntax-error.cjs │ │ ├── failfast │ │ │ ├── package.json │ │ │ ├── a.cjs │ │ │ └── b.cjs │ │ ├── failfast2 │ │ │ ├── package.json │ │ │ ├── b.cjs │ │ │ └── a.cjs │ │ ├── regular │ │ │ ├── package.json │ │ │ ├── bad-test-chain.cjs │ │ │ ├── uncaught-exception.cjs │ │ │ └── unhandled-rejection.cjs │ │ ├── watch │ │ │ ├── package.json │ │ │ └── test.cjs │ │ ├── timeoutinsinglefile │ │ │ ├── package.json │ │ │ └── a.cjs │ │ ├── timeoutwithmatch │ │ │ ├── package.json │ │ │ └── a.cjs │ │ ├── timeoutinmultiplefiles │ │ │ ├── package.json │ │ │ ├── a.cjs │ │ │ └── b.cjs │ │ └── README.md │ ├── reset-cache │ │ ├── package.json │ │ └── test.cjs │ ├── snapshots │ │ ├── package.json │ │ ├── test-dir │ │ │ ├── package.json │ │ │ └── test │ │ │ │ └── test.cjs │ │ ├── __tests__-dir │ │ │ ├── package.json │ │ │ └── __tests__ │ │ │ │ └── test.cjs │ │ ├── watcher-rerun │ │ │ ├── package.json │ │ │ └── test.cjs │ │ ├── watcher-rerun-unlink │ │ │ ├── package.json │ │ │ └── test.cjs │ │ ├── .gitignore │ │ ├── tests-dir │ │ │ ├── package.json │ │ │ └── tests │ │ │ │ └── test.cjs │ │ ├── test-content │ │ │ ├── package.json │ │ │ ├── test.cjs.snap.expected │ │ │ ├── tests │ │ │ │ └── test.cjs │ │ │ └── test.cjs.md.expected │ │ ├── test-sourcemaps │ │ │ ├── package.json │ │ │ ├── tsconfig.json │ │ │ ├── build │ │ │ │ ├── test │ │ │ │ │ ├── test.cjs │ │ │ │ │ └── test.cjs.map │ │ │ │ ├── test.cjs │ │ │ │ ├── feature │ │ │ │ │ └── __tests__ │ │ │ │ │ │ ├── test.cjs │ │ │ │ │ │ └── test.cjs.map │ │ │ │ └── test.cjs.map │ │ │ └── src │ │ │ │ ├── test │ │ │ │ └── test.ts │ │ │ │ ├── test.ts │ │ │ │ └── feature │ │ │ │ └── __tests__ │ │ │ │ └── test.ts │ │ ├── test-snapshot-location │ │ │ ├── package.json │ │ │ └── src │ │ │ │ ├── test.cjs │ │ │ │ └── feature │ │ │ │ ├── test.cjs │ │ │ │ └── nested-feature │ │ │ │ └── test.cjs │ │ └── test.cjs │ ├── globs │ │ ├── custom-extension │ │ │ └── test │ │ │ │ ├── foo.jsx │ │ │ │ ├── helpers │ │ │ │ ├── a.jsx │ │ │ │ └── b.cjs │ │ │ │ ├── sub │ │ │ │ ├── bar.jsx │ │ │ │ └── _helper.jsx │ │ │ │ └── do-not-compile.cjs │ │ ├── no-files │ │ │ └── package.json │ │ ├── cwd │ │ │ ├── dir-a │ │ │ │ └── test │ │ │ │ │ ├── bar.cjs │ │ │ │ │ └── foo.cjs │ │ │ └── dir-b │ │ │ │ └── test │ │ │ │ └── baz.cjs │ │ └── default-patterns │ │ │ ├── test.cjs │ │ │ ├── test-foo.cjs │ │ │ ├── test-foo.ts │ │ │ ├── test │ │ │ ├── baz.cjs │ │ │ ├── _foo-help.cjs │ │ │ ├── deep │ │ │ │ └── deep.cjs │ │ │ ├── helpers │ │ │ │ └── test.cjs │ │ │ └── fixtures │ │ │ │ └── foo-fixt.cjs │ │ │ ├── tests │ │ │ ├── baz.cjs │ │ │ ├── _foo-help.cjs │ │ │ ├── deep │ │ │ │ └── deep.cjs │ │ │ ├── helpers │ │ │ │ └── test.cjs │ │ │ └── fixtures │ │ │ │ └── foo-fixt.cjs │ │ │ └── sub │ │ │ └── directory │ │ │ ├── bar.spec.cjs │ │ │ ├── bar.test.cjs │ │ │ └── __tests__ │ │ │ ├── _foo.cjs │ │ │ ├── foo.cjs │ │ │ ├── fixtures │ │ │ └── foo.cjs │ │ │ └── helpers │ │ │ ├── foo.cjs │ │ │ └── foo.ts │ ├── load-config │ │ ├── cjs │ │ │ ├── package.json │ │ │ └── ava.config.cjs │ │ ├── no-default-export │ │ │ ├── ava.config.js │ │ │ └── package.json │ │ ├── explicit-bad-extension │ │ │ ├── package.json │ │ │ └── explicit.txt │ │ ├── throws │ │ │ ├── ava.config.js │ │ │ └── package.json │ │ ├── require │ │ │ ├── package.json │ │ │ ├── cjs.cjs │ │ │ └── ava.config.js │ │ ├── file-yes-cjs-yes │ │ │ ├── package.json │ │ │ ├── ava.config.cjs │ │ │ └── ava.config.js │ │ ├── no-plain-config │ │ │ ├── package.json │ │ │ └── ava.config.js │ │ ├── contains-ava-property │ │ │ ├── package.json │ │ │ └── ava.config.js │ │ ├── non-object-experiments │ │ │ ├── package.json │ │ │ └── ava.config.js │ │ ├── package-no-file-yes │ │ │ ├── package.json │ │ │ └── ava.config.js │ │ ├── factory-no-plain-return │ │ │ ├── package.json │ │ │ └── ava.config.js │ │ ├── package-no-file-yes-factory │ │ │ ├── package.json │ │ │ └── ava.config.js │ │ ├── unsupported-experiments │ │ │ ├── package.json │ │ │ └── ava.config.js │ │ ├── package-only │ │ │ └── package.json │ │ ├── package-yes-file-yes │ │ │ ├── ava.config.js │ │ │ └── package.json │ │ └── package-yes-explicit-yes │ │ │ ├── explicit.js │ │ │ ├── nested │ │ │ └── explicit.js │ │ │ └── package.json │ ├── symlinkfile.cjs │ ├── watcher │ │ ├── ignored-files │ │ │ ├── ignore.cjs │ │ │ ├── ignored.cjs │ │ │ ├── source.cjs │ │ │ ├── test.cjs │ │ │ └── package.json │ │ ├── with-dependencies │ │ │ ├── source.cjs │ │ │ ├── test-2.cjs │ │ │ └── test-1.cjs │ │ ├── package.json │ │ ├── tap-in-conf │ │ │ ├── package.json │ │ │ └── test.cjs │ │ └── test.cjs │ ├── esm │ │ └── package.json │ ├── install-global.cjs │ ├── pkg-type-module │ │ ├── package.json │ │ └── test.js │ ├── eslint-plugin-helper │ │ ├── package.json │ │ ├── for-overriding │ │ │ ├── package.json │ │ │ └── ava.config.mjs │ │ └── ava.config.mjs │ ├── package.json │ ├── caching │ │ ├── package.json │ │ └── test.cjs │ ├── assert.cjs.snap │ ├── extensions │ │ ├── package.json │ │ └── test.foo.bar │ ├── no-tests.cjs │ ├── try-snapshot.cjs.snap │ ├── mjs.mjs │ ├── parallel-runs │ │ ├── no-files │ │ │ └── package.json │ │ ├── less-files-than-ci-total │ │ │ ├── package.json │ │ │ ├── 2.cjs │ │ │ └── 9.cjs │ │ └── more-files-than-ci-total │ │ │ ├── package.json │ │ │ ├── 10.cjs │ │ │ ├── 2.cjs │ │ │ ├── 2a.cjs │ │ │ ├── 9.cjs │ │ │ ├── a.cjs │ │ │ ├── b.cjs │ │ │ ├── c.cjs │ │ │ └── Ab.cjs │ ├── cjs.cjs │ ├── es2015.cjs │ ├── ignored-dirs │ │ ├── test.cjs │ │ └── helpers │ │ │ └── test.cjs │ ├── pkg-conf │ │ └── fail-without-assertions │ │ │ ├── package.json │ │ │ └── test.cjs │ ├── skip-only.cjs │ ├── target-symlink.cjs │ ├── fail-fast │ │ ├── without-error │ │ │ ├── a.cjs │ │ │ └── b.cjs │ │ ├── crash │ │ │ ├── passes.cjs │ │ │ └── crashes.cjs │ │ ├── timeout │ │ │ ├── passes.cjs │ │ │ ├── fails.cjs │ │ │ └── passes-slow.cjs │ │ ├── multiple-files │ │ │ ├── passes.cjs │ │ │ └── fails.cjs │ │ └── single-file │ │ │ └── test.cjs │ ├── symlinkdir │ │ └── symlink.cjs │ ├── validate-installed-global.cjs │ ├── formatting-color.cjs │ ├── process-cwd-pkgdir.cjs │ ├── stalled-tests │ │ ├── promise.cjs │ │ └── observable.cjs │ ├── node-env-foo.cjs │ ├── node-env-test.cjs │ ├── worker-argv.cjs │ ├── long-running.cjs │ ├── match-no-match.cjs │ ├── error-in-anonymous-function.cjs │ ├── infinity-stack-trace.cjs │ ├── test-count.cjs │ ├── test-count-2.cjs │ ├── match-no-match-2.cjs │ ├── test-count-3.cjs │ ├── matcher-skip.cjs │ ├── assert.cjs.md │ ├── process-cwd-default.cjs │ ├── serial.cjs │ └── hooks-skipped.cjs ├── helper │ ├── chalk0.js │ ├── report-worker.js │ └── replay-report.js ├── chalk.js ├── reporters │ ├── tap.only.v12.log │ ├── tap.only.v14.log │ ├── tap.only.v16.log │ ├── default.only.v12.log │ ├── default.only.v14.log │ ├── default.only.v16.log │ ├── tap.failfast.v12.log │ ├── tap.failfast.v14.log │ ├── tap.failfast.v16.log │ ├── default.timeoutwithmatch.v12.log │ ├── default.timeoutwithmatch.v14.log │ ├── default.timeoutwithmatch.v16.log │ ├── default.timeoutinsinglefile.v12.log │ ├── default.timeoutinsinglefile.v14.log │ ├── default.timeoutinsinglefile.v16.log │ ├── tap.failfast2.v12.log │ ├── tap.failfast2.v14.log │ ├── tap.failfast2.v16.log │ └── improper-usage-messages.js ├── integration │ ├── repl.js │ └── stack-traces.js └── node-arguments.js ├── .npmrc ├── examples ├── macros │ ├── index.js │ ├── package.json │ ├── readme.md │ └── test.js ├── typescript-context │ ├── source │ │ ├── index.ts │ │ └── test.ts │ ├── tsconfig.json │ ├── readme.md │ └── package.json ├── typescript-basic │ ├── source │ │ ├── index.ts │ │ └── test.ts │ ├── tsconfig.json │ ├── readme.md │ └── package.json ├── specific-line-numbers │ ├── test.js │ ├── package.json │ └── readme.md ├── timeouts │ ├── package.json │ └── readme.md ├── matching-titles │ ├── package.json │ ├── test.js │ └── readme.md ├── tap-reporter │ ├── package.json │ ├── test.js │ └── readme.md └── endpoint-testing │ ├── package.json │ ├── app.js │ └── readme.md ├── .gitattributes ├── entrypoints ├── main.mjs ├── cli.mjs ├── main.cjs ├── plugin.cjs └── plugin.mjs ├── media ├── logo.ai ├── header.png ├── header.psd ├── logo.png ├── pronunciation.m4a ├── tap-reporter.png ├── snapshot-testing.png ├── verbose-reporter.png ├── screenshot-fixtures │ ├── snapshot-testing.md │ ├── mini-reporter.md │ ├── magic-assert-exceptions.js │ ├── verbose-reporter.js │ ├── magic-assert-strings.js │ ├── magic-assert-buffers.js │ ├── package.json │ ├── magic-assert-objects.js │ └── tap-reporter.js └── magic-assert-combined.png ├── lib ├── pkg.cjs ├── now-and-timers.cjs ├── worker │ ├── state.cjs │ ├── utils.cjs │ ├── main.cjs │ └── options.cjs ├── is-ci.js ├── chalk.js ├── environment-variables.js ├── node-arguments.js └── reporters │ └── format-serialized-error.js ├── tsconfig.json ├── docs └── recipes │ ├── es-modules.md │ └── babel.md ├── types └── subscribable.ts ├── .gitignore ├── .c8rc.json ├── .taprc ├── .editorconfig ├── .github └── ISSUE_TEMPLATE │ ├── feature.md │ └── config.yml ├── ava.config.js └── index.d.ts /test/.fake-root: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-d/.gitignore: -------------------------------------------------------------------------------- 1 | *.js 2 | -------------------------------------------------------------------------------- /test-tap/fixture/.fake-root: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/node_modules/ava: -------------------------------------------------------------------------------- 1 | ../../ -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | lockfile-version=3 2 | -------------------------------------------------------------------------------- /test-tap/fixture/symlink: -------------------------------------------------------------------------------- 1 | ./symlinkdir -------------------------------------------------------------------------------- /test-tap/fixture/ava-paths/cwd/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-tap/fixture/with-dependencies/dep-1.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-tap/fixture/with-dependencies/dep-2.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-tap/fixture/report/only/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test-tap/fixture/reset-cache/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test-tap/fixture/with-dependencies/dep-3.custom: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/custom-extension/test/foo.jsx: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/no-files/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/cjs/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test-tap/fixture/report/edgecases/no-ava-import.cjs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-tap/fixture/report/failfast/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test-tap/fixture/report/failfast2/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test-tap/fixture/report/regular/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test-tap/fixture/report/watch/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test-tap/fixture/symlinkfile.cjs: -------------------------------------------------------------------------------- 1 | target-symlink.cjs -------------------------------------------------------------------------------- /test-tap/fixture/watcher/ignored-files/ignore.cjs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-tap/fixture/watcher/ignored-files/ignored.cjs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-tap/fixture/watcher/ignored-files/source.cjs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/config/fixtures/js-as-cjs/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/custom-extension/test/helpers/a.jsx: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/custom-extension/test/helpers/b.cjs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/custom-extension/test/sub/bar.jsx: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/cwd/dir-a/test/bar.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/cwd/dir-a/test/foo.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/cwd/dir-b/test/baz.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-dir/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/removal/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/try/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-tests/fixtures/corrupt/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-tests/fixtures/large/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /examples/macros/index.js: -------------------------------------------------------------------------------- 1 | exports.sum = (a, b) => a + b; 2 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/custom-extension/test/do-not-compile.cjs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/custom-extension/test/sub/_helper.jsx: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/test.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/no-default-export/ava.config.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test-tap/fixture/report/timeoutinsinglefile/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test-tap/fixture/report/timeoutwithmatch/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/__tests__-dir/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/watcher-rerun/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/no-snapshots/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/only-test/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/snapshot-dir/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/adding-test/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/commit-skip/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/first-run/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/reorder/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test-tap/fixture/esm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/test-foo.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/test-foo.ts: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/test/baz.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/tests/baz.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/report/timeoutinmultiplefiles/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/watcher-rerun-unlink/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/skipped-snapshots/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/skipped-tests/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/adding-snapshots/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/changing-label/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/changing-title/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/discard-skip/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/invalid-snapfile/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/removing-test/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/skipping-test/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | *.ai binary 3 | *.psd binary 4 | -------------------------------------------------------------------------------- /entrypoints/main.mjs: -------------------------------------------------------------------------------- 1 | export {default} from '../lib/worker/main.cjs'; 2 | -------------------------------------------------------------------------------- /media/logo.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/media/logo.ai -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/test/_foo-help.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/test/deep/deep.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/tests/_foo-help.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/tests/deep/deep.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/explicit-bad-extension/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/config/fixtures/mjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test/snapshot-tests/fixtures/multiline-snapshot-label/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/filling-in-blanks/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/removing-snapshots/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/select-test-update/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/skipping-snapshot/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/skipping-test-update/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /lib/pkg.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | module.exports = require('../package.json'); 3 | -------------------------------------------------------------------------------- /media/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/media/header.png -------------------------------------------------------------------------------- /media/header.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/media/header.psd -------------------------------------------------------------------------------- /media/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/media/logo.png -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/test/helpers/test.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/tests/helpers/test.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/install-global.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | global.foo = 'bar'; 3 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/throws/ava.config.js: -------------------------------------------------------------------------------- 1 | throw new Error('foo'); 2 | -------------------------------------------------------------------------------- /test-tap/fixture/report/edgecases/throws.cjs: -------------------------------------------------------------------------------- 1 | throw new Error('throws'); 2 | -------------------------------------------------------------------------------- /test/config/fixtures/config-errors/ava.config.js: -------------------------------------------------------------------------------- 1 | throw new Error('foo'); 2 | -------------------------------------------------------------------------------- /test/config/fixtures/js-as-esm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test/shared-workers/worker-startup-crashes/fixtures/_no-factory-function.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/skipped-snapshots-in-try/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-tests/fixtures/normalized-title-in-snapshots/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-tests/fixtures/normalized-title-in-stdout/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/adding-skipped-snapshots/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/removing-all-snapshots/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/skipping-snapshot-update/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /test/worker-threads/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/sub/directory/bar.spec.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/sub/directory/bar.test.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/test/fixtures/foo-fixt.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/tests/fixtures/foo-fixt.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/require/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/throws/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test-tap/fixture/pkg-type-module/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test/config/fixtures/config-errors/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test/config/fixtures/promise-config/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test-tap/fixture/eslint-plugin-helper/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/sub/directory/__tests__/_foo.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/sub/directory/__tests__/foo.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test/config/fixtures/mjs/ava.config.mjs: -------------------------------------------------------------------------------- 1 | export default { 2 | failFast: true, 3 | }; 4 | -------------------------------------------------------------------------------- /test/config/fixtures/monorepo/package/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test/configurable-module-format/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test/snapshot-order/fixtures/randomness/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test/snapshot-regenerate-report/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /media/pronunciation.m4a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/media/pronunciation.m4a -------------------------------------------------------------------------------- /media/tap-reporter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/media/tap-reporter.png -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/sub/directory/__tests__/fixtures/foo.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/sub/directory/__tests__/helpers/foo.cjs: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/globs/default-patterns/sub/directory/__tests__/helpers/foo.ts: -------------------------------------------------------------------------------- 1 | // Empty 2 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/file-yes-cjs-yes/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/no-default-export/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/no-plain-config/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test-tap/fixture/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "ava": { 3 | "files": ["**/*"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/.gitignore: -------------------------------------------------------------------------------- 1 | *.snap 2 | *.md 3 | snapshots 4 | __snapshots__ 5 | -------------------------------------------------------------------------------- /test/config/fixtures/factory-promise-return/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test/config/fixtures/file-yes-cjs-yes-mjs-yes/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test/config/fixtures/js-as-esm/ava.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | failFast: true, 3 | }; 4 | -------------------------------------------------------------------------------- /test/node_modules/.bin/test-ava: -------------------------------------------------------------------------------- 1 | /Users/jsamines/dev/personal/ava/node_modules/.bin/test-ava -------------------------------------------------------------------------------- /test/shared-workers/worker-protocol/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test/shared-workers/worker-startup-crashes/fixtures/_module.js: -------------------------------------------------------------------------------- 1 | throw new Error('🙊'); 2 | -------------------------------------------------------------------------------- /test/snapshot-order/fixtures/intertest-order/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /entrypoints/cli.mjs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import run from '../lib/cli.js'; 3 | 4 | run(); 5 | -------------------------------------------------------------------------------- /entrypoints/main.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | module.exports = require('../lib/worker/main.cjs'); 3 | -------------------------------------------------------------------------------- /entrypoints/plugin.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | module.exports = require('../lib/worker/plugin.cjs'); 3 | -------------------------------------------------------------------------------- /media/snapshot-testing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/media/snapshot-testing.png -------------------------------------------------------------------------------- /media/verbose-reporter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/media/verbose-reporter.png -------------------------------------------------------------------------------- /test-tap/fixture/load-config/contains-ava-property/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/no-plain-config/ava.config.js: -------------------------------------------------------------------------------- 1 | export default 'should not work!'; 2 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/non-object-experiments/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/package-no-file-yes/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test-tap/fixture/watcher/with-dependencies/source.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | module.exports = true; 3 | -------------------------------------------------------------------------------- /test/config/fixtures/monorepo/ava.config.mjs: -------------------------------------------------------------------------------- 1 | export default { 2 | files: ['foo.js'], 3 | }; 4 | -------------------------------------------------------------------------------- /test/node-arguments/fixtures/node-arguments-from-config/setup.cjs: -------------------------------------------------------------------------------- 1 | global.SETUP_CALLED = true; 2 | -------------------------------------------------------------------------------- /test/shared-workers/worker-execution-crash/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": [ 3 | "test", 4 | "test-d", 5 | "test-tap" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /media/screenshot-fixtures/snapshot-testing.md: -------------------------------------------------------------------------------- 1 | See: https://github.com/avajs/ava-snapshot-example 2 | -------------------------------------------------------------------------------- /test-tap/fixture/eslint-plugin-helper/for-overriding/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/factory-no-plain-return/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/package-no-file-yes-factory/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/unsupported-experiments/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test/config/fixtures/mjs/no-default-export.mjs: -------------------------------------------------------------------------------- 1 | export const config = { 2 | failFast: true, 3 | }; 4 | -------------------------------------------------------------------------------- /test/multiple-implementations/fixtures/test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('title', []); 4 | -------------------------------------------------------------------------------- /test/snapshot-order/fixtures/report-declaration-order/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /docs/recipes/es-modules.md: -------------------------------------------------------------------------------- 1 | # Using ES modules in AVA 2 | 3 | AVA 4 supports ES modules out of the box. 4 | -------------------------------------------------------------------------------- /examples/typescript-context/source/index.ts: -------------------------------------------------------------------------------- 1 | export const concat = (input: string[]) => input.join(' '); 2 | -------------------------------------------------------------------------------- /media/magic-assert-combined.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/media/magic-assert-combined.png -------------------------------------------------------------------------------- /media/screenshot-fixtures/mini-reporter.md: -------------------------------------------------------------------------------- 1 | Run the [Got](https://github.com/sindresorhus/got) tests. 2 | -------------------------------------------------------------------------------- /test-tap/fixture/caching/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "application-name", 3 | "version": "0.0.1" 4 | } 5 | -------------------------------------------------------------------------------- /test-tap/fixture/watcher/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "ava": { 3 | "files": ["**/test*.*"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test-tap/fixture/watcher/tap-in-conf/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "ava": { 3 | "tap": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/config/fixtures/js-as-esm/no-default-export.js: -------------------------------------------------------------------------------- 1 | export const config = { 2 | failFast: true, 3 | }; 4 | -------------------------------------------------------------------------------- /test/config/fixtures/mjs-with-tests/ava.config.mjs: -------------------------------------------------------------------------------- 1 | export default { 2 | files: ['dir-a/*.js'], 3 | }; 4 | -------------------------------------------------------------------------------- /test/environment-variables/fixtures/environment-variables/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test/shared-workers/cannot-publish-before-available/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test/shared-workers/restricted-to-worker-threads/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module" 3 | } 4 | -------------------------------------------------------------------------------- /test/worker-threads/fixtures/child-process.config.mjs: -------------------------------------------------------------------------------- 1 | export default { 2 | workerThreads: false, 3 | }; 4 | -------------------------------------------------------------------------------- /test-tap/fixture/assert.cjs.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test-tap/fixture/assert.cjs.snap -------------------------------------------------------------------------------- /test-tap/fixture/extensions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "application-name", 3 | "version": "0.0.1" 4 | } 5 | -------------------------------------------------------------------------------- /test-tap/helper/chalk0.js: -------------------------------------------------------------------------------- 1 | import {set as setChalk} from '../../lib/chalk.js'; 2 | 3 | setChalk({level: 0}); 4 | -------------------------------------------------------------------------------- /test/cjs-default/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "ava": { 3 | "files": [ 4 | "*.cjs" 5 | ] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/globs/fixtures/files/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "files": [] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/globs/snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/globs/snapshots/test.js.snap -------------------------------------------------------------------------------- /test-tap/fixture/load-config/require/cjs.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | files: 'config-file-cjs-test-value', 3 | }; 4 | -------------------------------------------------------------------------------- /test/config/fixtures/mjs/error.mjs: -------------------------------------------------------------------------------- 1 | export default { 2 | failFast: true, 3 | }; 4 | 5 | throw new Error('🙈'); 6 | -------------------------------------------------------------------------------- /test/config/fixtures/promise-config/ava.config.js: -------------------------------------------------------------------------------- 1 | export default Promise.resolve({ 2 | failFast: true, 3 | }); 4 | -------------------------------------------------------------------------------- /test/config/snapshots/loader.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/config/snapshots/loader.js.snap -------------------------------------------------------------------------------- /test-tap/fixture/load-config/cjs/ava.config.cjs: -------------------------------------------------------------------------------- 1 | module.exports = ({projectDir}) => ({ 2 | files: projectDir, 3 | }); 4 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/contains-ava-property/ava.config.js: -------------------------------------------------------------------------------- 1 | export default Object.create({ 2 | ava: {}, 3 | }); 4 | -------------------------------------------------------------------------------- /test-tap/fixture/no-tests.cjs: -------------------------------------------------------------------------------- 1 | require('../../entrypoints/main.cjs'); // eslint-disable-line import/no-unassigned-import 2 | -------------------------------------------------------------------------------- /test-tap/fixture/try-snapshot.cjs.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test-tap/fixture/try-snapshot.cjs.snap -------------------------------------------------------------------------------- /test/assertions/snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/assertions/snapshots/test.js.snap -------------------------------------------------------------------------------- /test/concurrency/fixtures/concurrency.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('works', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test/config/fixtures/config-errors/test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('test', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test/config/fixtures/factory-promise-return/ava.config.js: -------------------------------------------------------------------------------- 1 | export default async () => ({ 2 | failFast: true, 3 | }); 4 | -------------------------------------------------------------------------------- /test/config/fixtures/js-as-esm/error.js: -------------------------------------------------------------------------------- 1 | export default { 2 | failFast: true, 3 | }; 4 | 5 | throw new Error('🙈'); 6 | -------------------------------------------------------------------------------- /test/config/fixtures/monorepo/package/foo.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('foo', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test/config/snapshots/next-gen.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/config/snapshots/next-gen.js.snap -------------------------------------------------------------------------------- /test/configurable-module-format/fixtures/array-custom.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | extensions: ['js', 'ts'], 3 | }; 4 | -------------------------------------------------------------------------------- /test/extensions/snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/extensions/snapshots/test.js.snap -------------------------------------------------------------------------------- /test-tap/fixture/ava-paths/target/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('ava'); 2 | 3 | test('test', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/non-object-experiments/ava.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | nonSemVerExperiments: [], 3 | }; 4 | -------------------------------------------------------------------------------- /test-tap/fixture/mjs.mjs: -------------------------------------------------------------------------------- 1 | import test from '../../entrypoints/main.mjs'; 2 | 3 | test('pass', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/parallel-runs/no-files/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "ava": { 3 | "files": [ 4 | "*.cjs" 5 | ] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/concurrency/snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/concurrency/snapshots/test.js.snap -------------------------------------------------------------------------------- /test/config/snapshots/integration.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/config/snapshots/integration.js.snap -------------------------------------------------------------------------------- /test/globs/fixtures/filter-by-directory/test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('file', t => { 4 | t.fail(); 5 | }); 6 | -------------------------------------------------------------------------------- /test/line-numbers/snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/line-numbers/snapshots/test.js.snap -------------------------------------------------------------------------------- /test/macros/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "files": [ 5 | "*" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/scheduler/fixtures/disabled-cache.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | files: [ 3 | '*.js', 4 | ], 5 | cache: false, 6 | }; 7 | -------------------------------------------------------------------------------- /test/test-timeouts/snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/test-timeouts/snapshots/test.js.snap -------------------------------------------------------------------------------- /test-tap/fixture/cjs.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../entrypoints/main.cjs'); 2 | 3 | test('pass', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/factory-no-plain-return/ava.config.js: -------------------------------------------------------------------------------- 1 | class Config {} 2 | 3 | export default () => new Config(); 4 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/tests-dir/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "ava": { 3 | "files": [ 4 | "tests/**/*.cjs" 5 | ] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/assertions/fixtures/happy-path.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/assertions/fixtures/happy-path.js.snap -------------------------------------------------------------------------------- /test/assertions/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "files": [ 5 | "*.js" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/concurrency/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "files": [ 5 | "*.js" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/node-arguments/snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/node-arguments/snapshots/test.js.snap -------------------------------------------------------------------------------- /test/scheduler/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "files": [ 5 | "*.js" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test-tap/fixture/es2015.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../entrypoints/main.cjs'); 2 | 3 | test('test', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/ignored-dirs/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../entrypoints/main.cjs'); 2 | 3 | test('pass', t => t.pass()); 4 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/file-yes-cjs-yes/ava.config.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | files: 'package-yes-files-yes-test-value', 3 | }; 4 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/file-yes-cjs-yes/ava.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | files: 'package-yes-files-yes-test-value', 3 | }; 4 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/package-only/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "ava": { 3 | "failFast": true, 4 | "concurrency": 10 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test-tap/fixture/pkg-conf/fail-without-assertions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "ava": { 3 | "failWithoutAssertions": false 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test-tap/fixture/report/only/b.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('passes', t => t.pass()); 4 | -------------------------------------------------------------------------------- /test-tap/fixture/reset-cache/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../entrypoints/main.cjs'); 2 | 3 | test('pass', t => t.pass()); 4 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-content/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "ava": { 3 | "files": [ 4 | "tests/test.cjs" 5 | ] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/config/fixtures/file-yes-cjs-yes-mjs-yes/ava.config.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | files: 'package-yes-files-yes-test-value', 3 | }; 4 | -------------------------------------------------------------------------------- /test/config/fixtures/file-yes-cjs-yes-mjs-yes/ava.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | files: 'package-yes-files-yes-test-value', 3 | }; 4 | -------------------------------------------------------------------------------- /test/config/fixtures/file-yes-cjs-yes-mjs-yes/ava.config.mjs: -------------------------------------------------------------------------------- 1 | export default { 2 | files: 'package-yes-files-yes-test-value', 3 | }; 4 | -------------------------------------------------------------------------------- /test/config/fixtures/mjs-with-tests/dir-a/dir-a-base-1.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('test', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test/config/fixtures/mjs-with-tests/dir-a/dir-a-base-2.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('test', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test/config/fixtures/pkg-with-tests/dir-a/dir-a-base-1.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('test', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test/config/fixtures/pkg-with-tests/dir-a/dir-a-base-2.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('test', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test/configurable-module-format/fixtures/array-extensions.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | extensions: ['js', 'cjs', 'mjs'], 3 | }; 4 | -------------------------------------------------------------------------------- /test/globs/fixtures/ignored-by-watcher/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "ignoredByWatcher": [] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/globs/fixtures/treat-patterns-as-files/test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('test.js', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test/hook-restrictions/snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/hook-restrictions/snapshots/test.js.snap -------------------------------------------------------------------------------- /test/line-numbers/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "files": [ 5 | "*.js" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/multiple-implementations/fixtures/try.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('try', async t => { 4 | await t.try([]); 5 | }); 6 | -------------------------------------------------------------------------------- /test/scheduler/fixtures/1pass.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('pass', t => { 4 | t.log(Date.now()); 5 | t.pass(); 6 | }); 7 | -------------------------------------------------------------------------------- /test/scheduler/fixtures/2fail.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('fail', t => { 4 | t.log(Date.now()); 5 | t.fail(); 6 | }); 7 | -------------------------------------------------------------------------------- /test/shared-workers/worker-protocol/fixtures/other.test.js: -------------------------------------------------------------------------------- 1 | import declare from './_declare.js'; 2 | 3 | declare(import.meta.url); 4 | -------------------------------------------------------------------------------- /test/shared-workers/worker-startup-crashes/fixtures/_factory-function.js: -------------------------------------------------------------------------------- 1 | export default () => { 2 | throw new Error('🙈'); 3 | }; 4 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/fixed-snapshot-dir/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "ava": { 3 | "snapshotDir": "fixedSnapshotDir" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/snapshot-removal/snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-removal/snapshots/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-tests/snapshots/corrupt.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-tests/snapshots/corrupt.js.snap -------------------------------------------------------------------------------- /test/test-timeouts/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "files": [ 5 | "*.js" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/package-no-file-yes-factory/ava.config.js: -------------------------------------------------------------------------------- 1 | export default ({projectDir}) => ({ 2 | files: projectDir, 3 | }); 4 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/package-yes-file-yes/ava.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | files: 'package-yes-files-yes-test-value', 3 | }; 4 | -------------------------------------------------------------------------------- /test-tap/fixture/parallel-runs/less-files-than-ci-total/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "ava": { 3 | "files": [ 4 | "*.cjs" 5 | ] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test-tap/fixture/parallel-runs/more-files-than-ci-total/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "ava": { 3 | "files": [ 4 | "*.cjs" 5 | ] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test-tap/fixture/report/failfast/a.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('fails', t => t.fail()); 4 | -------------------------------------------------------------------------------- /test-tap/fixture/report/failfast/b.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('passes', t => t.pass()); 4 | -------------------------------------------------------------------------------- /test-tap/fixture/report/failfast2/b.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('passes', t => t.pass()); 4 | -------------------------------------------------------------------------------- /test-tap/fixture/report/watch/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('passes', t => t.pass()); 4 | -------------------------------------------------------------------------------- /test-tap/fixture/skip-only.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../entrypoints/main.cjs'); 2 | 3 | test.skip('test', t => { 4 | t.fail(); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-sourcemaps/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "ava": { 3 | "files": [ 4 | "build/**/test.cjs" 5 | ] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test-tap/fixture/target-symlink.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../entrypoints/main.cjs'); 2 | 3 | test('test', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test/builtin-nodejs-assert/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "files": [ 5 | "*.js" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/config/fixtures/js-as-cjs/ava.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { // eslint-disable-line unicorn/prefer-module 2 | failFast: true, 3 | }; 4 | -------------------------------------------------------------------------------- /test/config/fixtures/mjs-with-tests/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "name": "application-name", 4 | "version": "0.0.1" 5 | } 6 | -------------------------------------------------------------------------------- /test/configurable-module-format/fixtures/change-js-loading.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | extensions: { 3 | js: 'module', 4 | }, 5 | }; 6 | -------------------------------------------------------------------------------- /test/configurable-module-format/fixtures/test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('always passing test', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test/globs/fixtures/filter-by-directory/directory/test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('directory', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test/hook-restrictions/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "files": [ 5 | "*.js" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/multiple-implementations/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "files": [ 5 | "*" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/shared-workers/lifecycle/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "files": [ 5 | "*" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/snapshot-order/snapshots/randomness.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-order/snapshots/randomness.js.snap -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/try/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-removal/fixtures/try/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-tests/snapshots/formatting.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-tests/snapshots/formatting.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/snapshots/adding.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/snapshots/adding.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/snapshots/reorder.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/snapshots/reorder.js.snap -------------------------------------------------------------------------------- /lib/now-and-timers.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const timers = require('timers'); 3 | 4 | Object.assign(exports, timers); 5 | exports.now = Date.now; 6 | -------------------------------------------------------------------------------- /test-tap/fixture/fail-fast/without-error/a.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('pass', t => t.pass()); 4 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/package-yes-explicit-yes/explicit.js: -------------------------------------------------------------------------------- 1 | export default { 2 | files: 'package-yes-explicit-yes-test-value', 3 | }; 4 | -------------------------------------------------------------------------------- /test-tap/fixture/pkg-type-module/test.js: -------------------------------------------------------------------------------- 1 | import test from '../../../entrypoints/main.mjs'; 2 | 3 | test('pass', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/report/edgecases/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('passes', t => t.pass()); 4 | -------------------------------------------------------------------------------- /test-tap/fixture/watcher/ignored-files/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('pass', t => t.pass()); 4 | -------------------------------------------------------------------------------- /test-tap/fixture/watcher/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../entrypoints/main.cjs'); 2 | 3 | test('works', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test/configurable-module-format/fixtures/change-cjs-loading.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | extensions: { 3 | cjs: 'module', 4 | }, 5 | }; 6 | -------------------------------------------------------------------------------- /test/configurable-module-format/fixtures/change-mjs-loading.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | extensions: { 3 | mjs: 'commonjs', 4 | }, 5 | }; 6 | -------------------------------------------------------------------------------- /test/configurable-module-format/fixtures/test.mjs: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('always passing test', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test/environment-variables/snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/environment-variables/snapshots/test.js.snap -------------------------------------------------------------------------------- /test/extensions/fixtures/top-level/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "extensions": [ 5 | "js" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/shared-workers/lifecycle/fixtures/_worker.js: -------------------------------------------------------------------------------- 1 | export default ({negotiateProtocol}) => { 2 | negotiateProtocol(['ava-4']).ready(); 3 | }; 4 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/removal/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-removal/fixtures/removal/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/snapshots/selection.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/snapshots/selection.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/snapshots/try-skip.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/snapshots/try-skip.js.snap -------------------------------------------------------------------------------- /test-tap/fixture/pkg-conf/fail-without-assertions/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('test', () => {}); 4 | -------------------------------------------------------------------------------- /test-tap/fixture/symlinkdir/symlink.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../entrypoints/main.cjs'); 2 | 3 | test('test', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test/configurable-module-format/fixtures/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('ava'); 2 | 3 | test('always passing test', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test/globs/fixtures/filter-by-directory/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "files": [ 5 | "**/test.js" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/node-arguments/fixtures/node-arguments/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "files": [ 5 | "*.js" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/snapshot-order/fixtures/randomness/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-order/fixtures/randomness/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/only-test/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-removal/fixtures/only-test/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/reorder/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/fixtures/reorder/test.js.snap -------------------------------------------------------------------------------- /test-tap/fixture/caching/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../entrypoints/main.cjs'); 2 | 3 | test('test', t => { 4 | t.true(2 + 2 === 4); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/package-yes-explicit-yes/nested/explicit.js: -------------------------------------------------------------------------------- 1 | export default { 2 | files: 'package-yes-explicit-yes-nested-test-value', 3 | }; 4 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/unsupported-experiments/ava.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | nonSemVerExperiments: { 3 | unsupported: true, 4 | }, 5 | }; 6 | -------------------------------------------------------------------------------- /test-tap/fixture/validate-installed-global.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../entrypoints/main.cjs'); 2 | 3 | test('test', t => t.is(global.foo, 'bar')); 4 | -------------------------------------------------------------------------------- /test/configurable-module-format/fixtures/bad-custom-type.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | extensions: { 3 | js: true, 4 | ts: 'cjs', 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /test/configurable-module-format/fixtures/object-custom.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | extensions: { 3 | js: true, 4 | ts: 'commonjs', 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /test/shared-workers/unsupported-protocol/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "files": [ 5 | "*" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/shared-workers/worker-startup-crashes/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "files": [ 5 | "*" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/shared-workers/workers-are-loaded-once/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "files": [ 5 | "*" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/adding-test/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/fixtures/adding-test/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/commit-skip/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/fixtures/commit-skip/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/snapshots/changing-label.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/snapshots/changing-label.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/snapshots/removing-test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/snapshots/removing-test.js.snap -------------------------------------------------------------------------------- /entrypoints/plugin.mjs: -------------------------------------------------------------------------------- 1 | import * as plugin from '../lib/worker/plugin.cjs'; 2 | 3 | const {registerSharedWorker} = plugin; 4 | export {registerSharedWorker}; 5 | -------------------------------------------------------------------------------- /examples/typescript-basic/source/index.ts: -------------------------------------------------------------------------------- 1 | export const sum = (a: number, b: number) => a + b; 2 | 3 | export const subtract = (a: number, b: number) => a - b; 4 | -------------------------------------------------------------------------------- /test-tap/fixture/fail-fast/crash/passes.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('first pass', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/ignored-dirs/helpers/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('test', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/watcher/tap-in-conf/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('works', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test/shared-workers/unsupported-protocol/fixtures/_worker.js: -------------------------------------------------------------------------------- 1 | export default async ({negotiateProtocol}) => { 2 | negotiateProtocol(['🙈']).ready(); 3 | }; 4 | -------------------------------------------------------------------------------- /test/shared-workers/worker-protocol/snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/shared-workers/worker-protocol/snapshots/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/skipped-tests/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-removal/fixtures/skipped-tests/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/discard-skip/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/fixtures/discard-skip/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/removing-test/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/fixtures/removing-test/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/skipping-test/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/fixtures/skipping-test/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/snapshots/invalid-snapfile.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/snapshots/invalid-snapfile.js.snap -------------------------------------------------------------------------------- /types/subscribable.ts: -------------------------------------------------------------------------------- 1 | export interface Subscribable { 2 | subscribe(observer: { 3 | error(error: any): void; 4 | complete(): void; 5 | }): void; 6 | } 7 | -------------------------------------------------------------------------------- /test-tap/fixture/fail-fast/timeout/passes.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('first pass', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/formatting-color.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../entrypoints/main.cjs'); 2 | 3 | test('test', t => { 4 | t.deepEqual({foo: 1}, {foo: 2}); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/explicit-bad-extension/explicit.txt: -------------------------------------------------------------------------------- 1 | const config = { 2 | files: 'config-file-esm-test-value' 3 | }; 4 | 5 | export default config; 6 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/package-no-file-yes/ava.config.js: -------------------------------------------------------------------------------- 1 | const config = { 2 | files: 'config-file-esm-test-value', 3 | }; 4 | 5 | export default config; 6 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/require/ava.config.js: -------------------------------------------------------------------------------- 1 | const config = require('./cjs.cjs'); // eslint-disable-line unicorn/prefer-module 2 | 3 | export default config; 4 | -------------------------------------------------------------------------------- /test-tap/fixture/report/edgecases/ava-import-no-test-declaration.cjs: -------------------------------------------------------------------------------- 1 | require('../../../../entrypoints/main.cjs'); // eslint-disable-line import/no-unassigned-import 2 | -------------------------------------------------------------------------------- /test-tap/fixture/report/edgecases/import-and-use-test-member.cjs: -------------------------------------------------------------------------------- 1 | const {test} = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('pass', t => t.pass()); 4 | -------------------------------------------------------------------------------- /test-tap/fixture/report/regular/bad-test-chain.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test.serial.test('passes', t => t.pass()); 4 | -------------------------------------------------------------------------------- /test-tap/fixture/watcher/with-dependencies/test-2.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('works', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/with-dependencies/require-custom.cjs: -------------------------------------------------------------------------------- 1 | /* eslint-disable node/no-deprecated-api */ 2 | require.extensions['.custom'] = require.extensions['.js']; 3 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/skipped-snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-removal/fixtures/skipped-snapshots/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/adding-snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/fixtures/adding-snapshots/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/changing-label/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/fixtures/changing-label/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/changing-title/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/fixtures/changing-title/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/snapshots/removing-snapshots.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/snapshots/removing-snapshots.js.snap -------------------------------------------------------------------------------- /test-tap/fixture/fail-fast/multiple-files/passes.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('first pass', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/process-cwd-pkgdir.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../entrypoints/main.cjs'); 2 | 3 | test('test', t => { 4 | t.is(process.cwd(), __dirname); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-content/test.cjs.snap.expected: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test-tap/fixture/snapshots/test-content/test.cjs.snap.expected -------------------------------------------------------------------------------- /test-tap/fixture/stalled-tests/promise.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../entrypoints/main.cjs'); 2 | 3 | test('test', t => new Promise(() => { 4 | t.pass(); 5 | })); 6 | -------------------------------------------------------------------------------- /test/configurable-module-format/fixtures/object-extensions.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | extensions: { 3 | js: true, 4 | cjs: true, 5 | mjs: true, 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /test/shared-workers/cannot-publish-before-available/fixtures/_worker.js: -------------------------------------------------------------------------------- 1 | export default async ({negotiateProtocol}) => { 2 | negotiateProtocol(['ava-4']).ready(); 3 | }; 4 | -------------------------------------------------------------------------------- /test/shared-workers/restricted-to-worker-threads/fixtures/_worker.js: -------------------------------------------------------------------------------- 1 | export default async ({negotiateProtocol}) => { 2 | negotiateProtocol(['ava-4']).ready(); 3 | }; 4 | -------------------------------------------------------------------------------- /test/shared-workers/unsupported-protocol/snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/shared-workers/unsupported-protocol/snapshots/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/filling-in-blanks/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/fixtures/filling-in-blanks/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/removing-snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/fixtures/removing-snapshots/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/select-test-update/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/fixtures/select-test-update/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/skipping-snapshot/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/fixtures/skipping-snapshot/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/snapshots/removing-all-snapshots.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/snapshots/removing-all-snapshots.js.snap -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /coverage 2 | /media/**/node_modules/ 3 | /node_modules/ 4 | /test-tap/**/node_modules/ 5 | /test/**/fixtures/**/node_modules/*/ 6 | /examples/**/node_modules/ 7 | -------------------------------------------------------------------------------- /test-tap/fixture/report/failfast2/a.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('fails', t => t.fail()); 4 | test('passes', t => t.pass()); 5 | -------------------------------------------------------------------------------- /test/line-numbers/fixtures/README.md: -------------------------------------------------------------------------------- 1 | Compile using: 2 | 3 | ```console 4 | npx tsc line-numbers.ts --outDir . --sourceMap --module es2020 --moduleResolution node 5 | ``` 6 | -------------------------------------------------------------------------------- /test/meta/fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "files": [ 5 | "*" 6 | ], 7 | "snapshotDir": "snapshot-fixture" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/shared-workers/worker-execution-crash/snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/shared-workers/worker-execution-crash/snapshots/test.js.snap -------------------------------------------------------------------------------- /test/shared-workers/worker-startup-crashes/snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/shared-workers/worker-startup-crashes/snapshots/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/skipping-test-update/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/fixtures/skipping-test-update/test.js.snap -------------------------------------------------------------------------------- /examples/typescript-basic/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@sindresorhus/tsconfig", 3 | "compilerOptions": { 4 | "module": "commonjs", 5 | "outDir": "build", 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /examples/typescript-context/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@sindresorhus/tsconfig", 3 | "compilerOptions": { 4 | "module": "commonjs", 5 | "outDir": "build", 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test-tap/fixture/load-config/package-yes-file-yes/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "ava": { 3 | "files": [ 4 | "abc", 5 | "!xyz" 6 | ] 7 | }, 8 | "type": "module" 9 | } 10 | -------------------------------------------------------------------------------- /test-tap/fixture/report/only/a.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test.only('only', t => t.pass()); 4 | 5 | test('passes', t => t.pass()); 6 | -------------------------------------------------------------------------------- /test/builtin-nodejs-assert/fixtures/assert-failure.js: -------------------------------------------------------------------------------- 1 | import assert from 'node:assert'; 2 | 3 | import test from 'ava'; 4 | 5 | test('test', () => { 6 | assert(false); 7 | }); 8 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/skipped-snapshots-in-try/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-removal/fixtures/skipped-snapshots-in-try/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/removing-all-snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/fixtures/removing-all-snapshots/test.js.snap -------------------------------------------------------------------------------- /test-tap/fixture/load-config/package-yes-explicit-yes/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "ava": { 3 | "files": [ 4 | "abc", 5 | "!xyz" 6 | ] 7 | }, 8 | "type": "module" 9 | } 10 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-snapshot-location/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "ava": { 3 | "files": [ 4 | "src/**/*test.cjs" 5 | ], 6 | "snapshotDir": "snapshot-fixtures" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/snapshot-dir/test/snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-removal/fixtures/snapshot-dir/test/snapshots/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/adding-skipped-snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/fixtures/adding-skipped-snapshots/test.js.snap -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/skipping-snapshot-update/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-workflow/fixtures/skipping-snapshot-update/test.js.snap -------------------------------------------------------------------------------- /lib/worker/state.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | exports.flags = {loadedMain: false}; 3 | exports.refs = {runnerChain: null}; 4 | exports.sharedWorkerTeardowns = []; 5 | exports.waitForReady = []; 6 | -------------------------------------------------------------------------------- /media/screenshot-fixtures/magic-assert-exceptions.js: -------------------------------------------------------------------------------- 1 | import fs from 'fs'; 2 | import test from 'ava'; 3 | 4 | test('exception', t => { 5 | fs.readFileSync('non-existent-file') 6 | }); 7 | -------------------------------------------------------------------------------- /media/screenshot-fixtures/verbose-reporter.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('unicorn', t => { 4 | t.pass(); 5 | }); 6 | 7 | test('rainbow', t => { 8 | t.pass(); 9 | }); 10 | -------------------------------------------------------------------------------- /test-tap/fixture/fail-fast/without-error/b.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | setTimeout(() => { 4 | test.serial('pass', t => t.pass()); 5 | }, 2000); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/node-env-foo.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../entrypoints/main.cjs'); 2 | 3 | test('NODE_ENV is foo', t => { 4 | t.plan(1); 5 | t.is(process.env.NODE_ENV, 'foo'); 6 | }); 7 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-content/tests/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../../entrypoints/main.cjs'); 2 | 3 | test('test title', t => { 4 | t.snapshot({foo: 'bar'}); 5 | }); 6 | -------------------------------------------------------------------------------- /test/cjs-default/test.js: -------------------------------------------------------------------------------- 1 | import test from '@ava/test'; 2 | 3 | import {fixture} from '../helpers/exec.js'; 4 | 5 | test('ok', async t => { 6 | await t.notThrowsAsync(fixture()); 7 | }); 8 | -------------------------------------------------------------------------------- /test/configurable-module-format/snapshots/invalid-configurations.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/configurable-module-format/snapshots/invalid-configurations.js.snap -------------------------------------------------------------------------------- /test/environment-variables/fixtures/environment-variables/ava.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | environmentVariables: {MY_ENVIRONMENT_VARIABLE: 'some value'}, 3 | files: ['*.js'], 4 | }; 5 | -------------------------------------------------------------------------------- /test/globs/fixtures/treat-patterns-as-files/foo.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line ava/no-ignored-test-files 2 | import test from 'ava'; 3 | 4 | test('foo.js', t => { 5 | t.pass(); 6 | }); 7 | -------------------------------------------------------------------------------- /test-tap/fixture/node-env-test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../entrypoints/main.cjs'); 2 | 3 | test('NODE_ENV is test', t => { 4 | t.plan(1); 5 | t.is(process.env.NODE_ENV, 'test'); 6 | }); 7 | -------------------------------------------------------------------------------- /test-tap/fixture/report/edgecases/ast-syntax-error.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | const fn = do { 4 | t => t.pass(); 5 | }; 6 | 7 | test('fn', fn); 8 | -------------------------------------------------------------------------------- /test-tap/fixture/watcher/ignored-files/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "ava": { 3 | "files": [ 4 | "test.cjs" 5 | ], 6 | "ignoredByWatcher": [ 7 | "ignored.cjs" 8 | ] 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/shared-workers/cannot-publish-before-available/snapshots/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/shared-workers/cannot-publish-before-available/snapshots/test.js.snap -------------------------------------------------------------------------------- /test/worker-threads/fixtures/test.js: -------------------------------------------------------------------------------- 1 | import {isMainThread} from 'node:worker_threads'; 2 | 3 | import test from 'ava'; 4 | 5 | test('in worker thread', t => { 6 | t.false(isMainThread); 7 | }); 8 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/fixed-snapshot-dir/fixedSnapshotDir/test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/ava/main/test/snapshot-removal/fixtures/fixed-snapshot-dir/fixedSnapshotDir/test.js.snap -------------------------------------------------------------------------------- /examples/specific-line-numbers/test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const test = require('ava'); 3 | 4 | test('unicorn', t => { 5 | t.pass(); 6 | }); 7 | 8 | test('rainbow', t => { 9 | t.fail(); 10 | }); 11 | -------------------------------------------------------------------------------- /test-tap/helper/report-worker.js: -------------------------------------------------------------------------------- 1 | import {onlyColors} from './fix-reporter-env.js'; 2 | 3 | onlyColors(); 4 | import('../../lib/worker/base.js'); // eslint-disable-line node/no-unsupported-features/es-syntax 5 | -------------------------------------------------------------------------------- /test/config/fixtures/mjs-with-tests/dir-a-wrapper/dir-a/dir-a-wrapper-3.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line ava/no-ignored-test-files 2 | import test from 'ava'; 3 | 4 | test('test', t => { 5 | t.pass(); 6 | }); 7 | -------------------------------------------------------------------------------- /test/config/fixtures/mjs-with-tests/dir-a-wrapper/dir-a/dir-a-wrapper-4.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line ava/no-ignored-test-files 2 | import test from 'ava'; 3 | 4 | test('test', t => { 5 | t.pass(); 6 | }); 7 | -------------------------------------------------------------------------------- /test/config/fixtures/pkg-with-tests/dir-a-wrapper/dir-a/dir-a-wrapper-3.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line ava/no-ignored-test-files 2 | import test from 'ava'; 3 | 4 | test('test', t => { 5 | t.pass(); 6 | }); 7 | -------------------------------------------------------------------------------- /test/config/fixtures/pkg-with-tests/dir-a-wrapper/dir-a/dir-a-wrapper-4.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line ava/no-ignored-test-files 2 | import test from 'ava'; 3 | 4 | test('test', t => { 5 | t.pass(); 6 | }); 7 | -------------------------------------------------------------------------------- /test/environment-variables/fixtures/environment-variables/environment-variables.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('works', t => { 4 | t.is(process.env.MY_ENVIRONMENT_VARIABLE, 'some value'); 5 | }); 6 | -------------------------------------------------------------------------------- /test/extensions/fixtures/top-level-duplicates/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "extensions": [ 5 | "js", 6 | "js", 7 | "jsx", 8 | "jsx" 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/test-timeouts/fixtures/invalid-message.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('timeout with invalid message', t => { 4 | t.timeout(10, 20); // eslint-disable-line ava/assertion-arguments 5 | }); 6 | 7 | -------------------------------------------------------------------------------- /test-tap/fixture/fail-fast/crash/crashes.cjs: -------------------------------------------------------------------------------- 1 | require('../../../../entrypoints/main.cjs'); // eslint-disable-line import/no-unassigned-import 2 | 3 | process.exit(1); // eslint-disable-line unicorn/no-process-exit 4 | -------------------------------------------------------------------------------- /test-tap/fixture/parallel-runs/less-files-than-ci-total/2.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('at expected index', t => { 4 | t.is(process.env.CI_NODE_INDEX, '0'); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/parallel-runs/less-files-than-ci-total/9.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('at expected index', t => { 4 | t.is(process.env.CI_NODE_INDEX, '1'); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/parallel-runs/more-files-than-ci-total/10.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('at expected index', t => { 4 | t.is(process.env.CI_NODE_INDEX, '1'); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/parallel-runs/more-files-than-ci-total/2.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('at expected index', t => { 4 | t.is(process.env.CI_NODE_INDEX, '0'); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/parallel-runs/more-files-than-ci-total/2a.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('at expected index', t => { 4 | t.is(process.env.CI_NODE_INDEX, '0'); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/parallel-runs/more-files-than-ci-total/9.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('at expected index', t => { 4 | t.is(process.env.CI_NODE_INDEX, '0'); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/parallel-runs/more-files-than-ci-total/a.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('at expected index', t => { 4 | t.is(process.env.CI_NODE_INDEX, '1'); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/parallel-runs/more-files-than-ci-total/b.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('at expected index', t => { 4 | t.is(process.env.CI_NODE_INDEX, '2'); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/parallel-runs/more-files-than-ci-total/c.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('at expected index', t => { 4 | t.is(process.env.CI_NODE_INDEX, '2'); 5 | }); 6 | -------------------------------------------------------------------------------- /test/config/fixtures/pkg-with-tests/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "name": "application-name", 4 | "version": "0.0.1", 5 | "ava": { 6 | "files": [ 7 | "dir-a/*.js" 8 | ] 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/test-timeouts/fixtures/custom-message.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('timeout with custom message', async t => { 4 | t.timeout(10, 'time budget exceeded'); 5 | await new Promise(() => {}); 6 | }); 7 | -------------------------------------------------------------------------------- /media/screenshot-fixtures/magic-assert-strings.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('strings', t => { 4 | const actual = 'this is amazing'; 5 | const expected = 'this is cool'; 6 | t.is(actual, expected); 7 | }); 8 | -------------------------------------------------------------------------------- /test/environment-variables/fixtures/invalid-environment-variables/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "environmentVariables": { 5 | "SOME_INVALID_ENVIRONMENT_VARIABLE": {} 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/globs/fixtures/treat-patterns-as-files/_helper.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line ava/no-ignored-test-files 2 | import test from 'ava'; 3 | 4 | test('helper files must not be selected', t => { 5 | t.fail(); 6 | }); 7 | -------------------------------------------------------------------------------- /test/globs/fixtures/treat-patterns-as-files/foo.ts: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line ava/no-ignored-test-files 2 | import test from 'ava'; 3 | 4 | test('typescript files must not be selected', t => { 5 | t.fail(); 6 | }); 7 | -------------------------------------------------------------------------------- /test/shared-workers/unsupported-protocol/fixtures/in-test-worker.js: -------------------------------------------------------------------------------- 1 | import * as plugin from 'ava/plugin'; 2 | 3 | plugin.registerSharedWorker({ 4 | supportedProtocols: ['🙈'], 5 | filename: import.meta.url, 6 | }); 7 | -------------------------------------------------------------------------------- /lib/is-ci.js: -------------------------------------------------------------------------------- 1 | import process from 'node:process'; 2 | 3 | import info from 'ci-info'; 4 | 5 | const {AVA_FORCE_CI} = process.env; 6 | 7 | export default AVA_FORCE_CI === 'not-ci' ? false : AVA_FORCE_CI === 'ci' || info.isCI; 8 | -------------------------------------------------------------------------------- /test-tap/fixture/stalled-tests/observable.cjs: -------------------------------------------------------------------------------- 1 | const Observable = require('zen-observable'); 2 | 3 | const test = require('../../../entrypoints/main.cjs'); 4 | 5 | test('test', t => new Observable(() => { 6 | t.pass(); 7 | })); 8 | -------------------------------------------------------------------------------- /test-tap/fixture/watcher/with-dependencies/test-1.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | const dependency = require('./source.cjs'); 4 | 5 | test('works', t => { 6 | t.truthy(dependency); 7 | }); 8 | -------------------------------------------------------------------------------- /test/hook-restrictions/fixtures/invalid-snapshots-in-hooks.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test.before(t => { 4 | t.snapshot({}); 5 | }); 6 | 7 | test('cannot use snapshot in hook', t => { 8 | t.pass(); 9 | }); 10 | -------------------------------------------------------------------------------- /test/macros/test.js: -------------------------------------------------------------------------------- 1 | import test from '@ava/test'; 2 | 3 | import {fixture} from '../helpers/exec.js'; 4 | 5 | test('a-okay', async t => { 6 | const result = await fixture([]); 7 | t.is(result.stats.passed.length, 3); 8 | }); 9 | -------------------------------------------------------------------------------- /.c8rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "all": true, 3 | "exclude": [ 4 | "{coverage,examples,media,test,test-d,test-tap,types}/**", 5 | "*.config.cjs", 6 | "*.d.ts" 7 | ], 8 | "reporter": [ 9 | "html", 10 | "lcov" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /.taprc: -------------------------------------------------------------------------------- 1 | browser: false 2 | coverage: false 3 | files: 4 | - "test-tap/*.js" 5 | - "test-tap/reporters/*.js" 6 | - "test-tap/integration/*.js" 7 | flow: false 8 | jobs: 2 9 | jsx: false 10 | timeout: 300 11 | ts: false 12 | -------------------------------------------------------------------------------- /test-tap/fixture/fail-fast/timeout/fails.cjs: -------------------------------------------------------------------------------- 1 | const delay = require('delay'); 2 | 3 | const test = require('../../../../entrypoints/main.cjs'); 4 | 5 | test('slow pass', async t => { 6 | await delay(1000); 7 | t.pass(); 8 | }); 9 | -------------------------------------------------------------------------------- /test/globs/fixtures/treat-patterns-as-files/node_modules/test.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line ava/no-ignored-test-files 2 | import test from 'ava'; 3 | 4 | test('node_modules files must not be selected', t => { 5 | t.fail(); 6 | }); 7 | -------------------------------------------------------------------------------- /test-tap/fixture/report/README.md: -------------------------------------------------------------------------------- 1 | To run these tests directly, `cd` into the respective directories and invoke via `node ../../../../entrypoints/cli.mjs`. 2 | 3 | Note that the `report` helper sorts the test files before running tests. 4 | -------------------------------------------------------------------------------- /test-tap/fixture/worker-argv.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../entrypoints/main.cjs'); 2 | 3 | test('argv', t => { 4 | t.deepEqual(process.argv, [process.execPath, require.resolve('../../lib/worker/base'), '--hello', 'world']); 5 | }); 6 | -------------------------------------------------------------------------------- /test-tap/fixture/report/regular/uncaught-exception.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('passes', t => { 4 | setImmediate(() => { 5 | throw new Error('Can’t catch me'); 6 | }); 7 | t.pass(); 8 | }); 9 | -------------------------------------------------------------------------------- /test/hook-restrictions/fixtures/invalid-t-try-in-hooks.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test.before(async t => { 4 | await t.try(tt => tt.pass()); 5 | }); 6 | 7 | test('cannot use `t.try()` in hook', t => { 8 | t.pass(); 9 | }); 10 | -------------------------------------------------------------------------------- /test/node-arguments/fixtures/node-arguments/node-arguments.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('exec arguments includes --throw-deprecation', t => { 4 | t.plan(1); 5 | t.truthy(process.execArgv.includes('--throw-deprecation')); 6 | }); 7 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.yml] 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /examples/macros/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ava-macros", 3 | "description": "Example for reusing test logic through macros", 4 | "scripts": { 5 | "test": "ava" 6 | }, 7 | "devDependencies": { 8 | "ava": "^3.15.0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/node-arguments/fixtures/node-arguments-from-config/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "files": [ 5 | "*.js" 6 | ], 7 | "nodeArguments": [ 8 | "--require", 9 | "./setup.cjs" 10 | ] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/shared-workers/worker-protocol/fixtures/_plugin.js: -------------------------------------------------------------------------------- 1 | import * as plugin from 'ava/plugin'; 2 | 3 | export default plugin.registerSharedWorker({ 4 | filename: new URL('_worker.js', import.meta.url), 5 | supportedProtocols: ['ava-4'], 6 | }); 7 | -------------------------------------------------------------------------------- /examples/timeouts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ava-timeouts", 3 | "description": "Example for test timeouts", 4 | "scripts": { 5 | "test": "ava --timeout=2s --verbose" 6 | }, 7 | "devDependencies": { 8 | "ava": "^3.15.0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/shared-workers/worker-execution-crash/fixtures/_plugin.js: -------------------------------------------------------------------------------- 1 | import * as plugin from 'ava/plugin'; 2 | 3 | export default plugin.registerSharedWorker({ 4 | filename: new URL('_worker.js', import.meta.url), 5 | supportedProtocols: ['ava-4'], 6 | }); 7 | -------------------------------------------------------------------------------- /test-tap/fixture/long-running.cjs: -------------------------------------------------------------------------------- 1 | const delay = require('delay'); 2 | 3 | const test = require('../../entrypoints/main.cjs'); 4 | 5 | test('slow', async t => { 6 | await delay(5000); 7 | t.pass(); 8 | }); 9 | 10 | test('fast', t => t.pass()); 11 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-sourcemaps/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "outDir": "build", 6 | "sourceMap": true 7 | }, 8 | "include": [ 9 | "src/**/*test.ts" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /lib/worker/utils.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const process = require('process'); 3 | const {isMainThread} = require('worker_threads'); 4 | 5 | exports.isRunningInThread = isMainThread === false; 6 | exports.isRunningInChildProcess = typeof process.send === 'function'; 7 | -------------------------------------------------------------------------------- /test-tap/fixture/match-no-match.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../entrypoints/main.cjs'); 2 | 3 | test('foo', t => { 4 | t.pass(); 5 | }); 6 | 7 | test.only('bar', t => { 8 | t.pass(); 9 | }); 10 | 11 | test.only('baz', t => { 12 | t.pass(); 13 | }); 14 | -------------------------------------------------------------------------------- /test-tap/fixture/parallel-runs/more-files-than-ci-total/Ab.cjs: -------------------------------------------------------------------------------- 1 | /* eslint-disable unicorn/filename-case */ 2 | const test = require('../../../../entrypoints/main.cjs'); 3 | 4 | test('at expected index', t => { 5 | t.is(process.env.CI_NODE_INDEX, '1'); 6 | }); 7 | -------------------------------------------------------------------------------- /test-tap/fixture/error-in-anonymous-function.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../entrypoints/main.cjs'); 2 | 3 | const getAnonymousFn = () => () => { 4 | throw new Error(); 5 | }; 6 | 7 | test('test', t => { 8 | getAnonymousFn()(); 9 | t.pass(); 10 | }); 11 | -------------------------------------------------------------------------------- /test-tap/fixture/eslint-plugin-helper/ava.config.mjs: -------------------------------------------------------------------------------- 1 | export default { 2 | extensions: [], 3 | files: ['tests/**/*'], 4 | typescript: { 5 | compile: false, 6 | rewritePaths: { 7 | 'src/': 'build/', 8 | }, 9 | extensions: ['foo'], 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /test/shared-workers/worker-protocol/test.js: -------------------------------------------------------------------------------- 1 | import test from '@ava/test'; 2 | 3 | import {fixture} from '../../helpers/exec.js'; 4 | 5 | test('shared worker plugins work', async t => { 6 | const result = await fixture(); 7 | t.snapshot(result.stats.passed); 8 | }); 9 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/no-snapshots/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | test('without snapshots', t => { 4 | t.pass(); 5 | }); 6 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/try/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## snapshots in try 8 | 9 | > Snapshot 1 10 | 11 | 'in try' 12 | -------------------------------------------------------------------------------- /test/assertions/test.js: -------------------------------------------------------------------------------- 1 | import test from '@ava/test'; 2 | 3 | import {fixture} from '../helpers/exec.js'; 4 | 5 | test('happy path', async t => { 6 | const result = await fixture(['happy-path.js']); 7 | t.snapshot(result.stats.passed.map(({title}) => title)); 8 | }); 9 | -------------------------------------------------------------------------------- /test/snapshot-tests/fixtures/corrupt/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); 2 | 3 | test('a snapshot', t => { 4 | t.snapshot('foo'); 5 | }); 6 | 7 | test('a snapshot with a message', t => { 8 | t.snapshot('foo', 'a message'); 9 | }); 10 | -------------------------------------------------------------------------------- /examples/matching-titles/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ava-matching-titles", 3 | "description": "Example for running tests with matching titles", 4 | "scripts": { 5 | "test": "ava --match='*oo*'" 6 | }, 7 | "devDependencies": { 8 | "ava": "^3.15.0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test-tap/fixture/fail-fast/timeout/passes-slow.cjs: -------------------------------------------------------------------------------- 1 | const delay = require('delay'); 2 | 3 | const test = require('../../../../entrypoints/main.cjs'); 4 | 5 | test('slow pass with timeout', async t => { 6 | t.timeout(120); 7 | await delay(110); 8 | t.pass(); 9 | }); 10 | -------------------------------------------------------------------------------- /test-tap/fixture/infinity-stack-trace.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../entrypoints/main.cjs'); 2 | 3 | Error.stackTraceLimit = 1; 4 | 5 | test('test', t => { 6 | const c = () => t.fail(); 7 | const b = () => c(); 8 | const a = () => b(); 9 | 10 | a(); 11 | }); 12 | -------------------------------------------------------------------------------- /test-tap/fixture/with-dependencies/no-tests.cjs: -------------------------------------------------------------------------------- 1 | require('./dep-1.js'); // eslint-disable-line import/no-unassigned-import 2 | require('./dep-2.js'); // eslint-disable-line import/no-unassigned-import 3 | require('./dep-3.custom'); // eslint-disable-line import/no-unassigned-import 4 | -------------------------------------------------------------------------------- /test/globs/fixtures/treat-patterns-as-files/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "files": [ 5 | "**/test.js" 6 | ], 7 | "typescript": { 8 | "compile": false, 9 | "rewritePaths": { 10 | "src/": "build/" 11 | } 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../entrypoints/main.cjs'); 2 | 3 | test('test title', t => { 4 | t.snapshot({foo: 'bar'}); 5 | 6 | t.snapshot({answer: 42}); 7 | }); 8 | 9 | test('another test', t => { 10 | t.snapshot(new Map()); 11 | }); 12 | -------------------------------------------------------------------------------- /test/shared-workers/cannot-publish-before-available/test.js: -------------------------------------------------------------------------------- 1 | import test from '@ava/test'; 2 | 3 | import {fixture} from '../../helpers/exec.js'; 4 | 5 | test('shared worker plugins work', async t => { 6 | const result = await fixture(); 7 | t.snapshot(result.stats.passed); 8 | }); 9 | -------------------------------------------------------------------------------- /test/shared-workers/workers-are-loaded-once/fixtures/test-1.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | import {random} from './_plugin.js'; 4 | 5 | test('the shared worker produces a random value', async t => { 6 | const {data} = await random; 7 | t.log(data); 8 | t.pass(); 9 | }); 10 | -------------------------------------------------------------------------------- /test/shared-workers/workers-are-loaded-once/fixtures/test-2.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | import {random} from './_plugin.js'; 4 | 5 | test('the shared worker produces a random value', async t => { 6 | const {data} = await random; 7 | t.log(data); 8 | t.pass(); 9 | }); 10 | -------------------------------------------------------------------------------- /examples/specific-line-numbers/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ava-specific-line-numbers", 3 | "description": "Example for running tests at specific line numbers", 4 | "scripts": { 5 | "test": "ava test.js:5" 6 | }, 7 | "devDependencies": { 8 | "ava": "^3.15.0" 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /examples/tap-reporter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ava-tap-reporter", 3 | "description": "Example for a custom TAP reporter", 4 | "scripts": { 5 | "test": "ava --tap | tap-nyan" 6 | }, 7 | "devDependencies": { 8 | "ava": "^3.15.0", 9 | "tap-nyan": "^1.1.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test-tap/fixture/eslint-plugin-helper/for-overriding/ava.config.mjs: -------------------------------------------------------------------------------- 1 | export default { 2 | extensions: [], 3 | typescript: { 4 | rewritePaths: { 5 | 'src/': 'build/', 6 | }, 7 | compile: false, 8 | extensions: ['bar'], 9 | }, 10 | files: ['build/tests/**/*'], 11 | }; 12 | -------------------------------------------------------------------------------- /test-tap/fixture/fail-fast/single-file/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('first pass', t => { 4 | t.pass(); 5 | }); 6 | 7 | test('second fail', t => { 8 | t.fail(); 9 | }); 10 | 11 | test('third pass', t => { 12 | t.pass(); 13 | }); 14 | -------------------------------------------------------------------------------- /test/snapshot-tests/fixtures/large/test.js: -------------------------------------------------------------------------------- 1 | const {Buffer} = require('buffer'); 2 | 3 | const test = require(process.env.TEST_AVA_IMPORT_FROM); 4 | 5 | for (let i = 0; i < 2; i++) { 6 | test(`large snapshot ${i}`, t => { 7 | t.snapshot(Buffer.alloc(1024 * 16)); 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/adding-test/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## foo 8 | 9 | > Snapshot 1 10 | 11 | { 12 | foo: 'one', 13 | } 14 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/changing-label/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## foo 8 | 9 | > Snapshot 1 10 | 11 | { 12 | foo: 'one', 13 | } 14 | -------------------------------------------------------------------------------- /test-tap/chalk.js: -------------------------------------------------------------------------------- 1 | import {test} from 'tap'; 2 | 3 | import {set} from '../lib/chalk.js'; 4 | 5 | test('throws an error when trying to set chalk config and chalk config is configured', t => { 6 | set({}); 7 | t.throws(set, 'Chalk has already been configured'); 8 | t.end(); 9 | }); 10 | -------------------------------------------------------------------------------- /test-tap/fixture/fail-fast/multiple-files/fails.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('first pass', t => { 4 | t.pass(); 5 | }); 6 | 7 | test('second fail', t => { 8 | t.fail(); 9 | }); 10 | 11 | test('third pass', t => { 12 | t.pass(); 13 | }); 14 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/skipped-snapshots-in-try/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## skipped snapshots in try 8 | 9 | > Snapshot 1 10 | 11 | 'in try' 12 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/adding-snapshots/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## foo 8 | 9 | > Snapshot 1 10 | 11 | { 12 | foo: 'one', 13 | } 14 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/changing-title/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## a title 8 | 9 | > Snapshot 1 10 | 11 | { 12 | foo: 'one', 13 | } 14 | -------------------------------------------------------------------------------- /examples/matching-titles/test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const test = require('ava'); 3 | 4 | test('foo will run', t => { 5 | t.pass(); 6 | }); 7 | 8 | test('moo will also run', t => { 9 | t.pass(); 10 | }); 11 | 12 | test.only('boo will run but not exclusively', t => { 13 | t.pass(); 14 | }); 15 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/watcher-rerun/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | test('test title', t => { 4 | t.snapshot({foo: 'bar'}); 5 | 6 | t.snapshot({answer: 42}); 7 | }); 8 | 9 | test('another test', t => { 10 | t.snapshot(new Map()); 11 | }); 12 | -------------------------------------------------------------------------------- /test-tap/reporters/tap.only.v12.log: -------------------------------------------------------------------------------- 1 | TAP version 13 2 | ---tty-stream-chunk-separator 3 | ok 1 - a › only 4 | ---tty-stream-chunk-separator 5 | ok 2 - b › passes 6 | ---tty-stream-chunk-separator 7 | 8 | 1..2 9 | # tests 2 10 | # pass 2 11 | # fail 0 12 | 13 | ---tty-stream-chunk-separator 14 | -------------------------------------------------------------------------------- /test-tap/reporters/tap.only.v14.log: -------------------------------------------------------------------------------- 1 | TAP version 13 2 | ---tty-stream-chunk-separator 3 | ok 1 - a › only 4 | ---tty-stream-chunk-separator 5 | ok 2 - b › passes 6 | ---tty-stream-chunk-separator 7 | 8 | 1..2 9 | # tests 2 10 | # pass 2 11 | # fail 0 12 | 13 | ---tty-stream-chunk-separator 14 | -------------------------------------------------------------------------------- /test-tap/reporters/tap.only.v16.log: -------------------------------------------------------------------------------- 1 | TAP version 13 2 | ---tty-stream-chunk-separator 3 | ok 1 - a › only 4 | ---tty-stream-chunk-separator 5 | ok 2 - b › passes 6 | ---tty-stream-chunk-separator 7 | 8 | 1..2 9 | # tests 2 10 | # pass 2 11 | # fail 0 12 | 13 | ---tty-stream-chunk-separator 14 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/adding-skipped-snapshots/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## foo 8 | 9 | > Snapshot 1 10 | 11 | { 12 | foo: 'one', 13 | } 14 | -------------------------------------------------------------------------------- /examples/endpoint-testing/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ava-endpoint-testing", 3 | "description": "Example for endpoint testing", 4 | "scripts": { 5 | "test": "ava" 6 | }, 7 | "devDependencies": { 8 | "ava": "^3.15.0", 9 | "got": "^11.8.2", 10 | "test-listen": "^1.1.0" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /examples/typescript-basic/source/test.ts: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | import {sum, subtract} from '.'; 4 | 5 | test('sum', t => { 6 | t.is(sum(0, 0), 0); 7 | t.is(sum(2, 2), 4); 8 | }); 9 | 10 | test('subtract', t => { 11 | t.is(subtract(0, 0), 0); 12 | t.is(subtract(4, 2), 2); 13 | }); 14 | -------------------------------------------------------------------------------- /media/screenshot-fixtures/magic-assert-buffers.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('buffers', t => { 4 | const actual = Buffer.from('decafbadcab00d1e'.repeat(4), 'hex') 5 | const expected = Buffer.from('cab00d1edecafbad' + 'decafbadcab00d1e'.repeat(3), 'hex') 6 | t.deepEqual(actual, expected) 7 | }); 8 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-dir/test/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../../entrypoints/main.cjs'); 2 | 3 | test('test title', t => { 4 | t.snapshot({foo: 'bar'}); 5 | 6 | t.snapshot({answer: 42}); 7 | }); 8 | 9 | test('another test', t => { 10 | t.snapshot(new Map()); 11 | }); 12 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/tests-dir/tests/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../../entrypoints/main.cjs'); 2 | 3 | test('test title', t => { 4 | t.snapshot({foo: 'bar'}); 5 | 6 | t.snapshot({answer: 42}); 7 | }); 8 | 9 | test('another test', t => { 10 | t.snapshot(new Map()); 11 | }); 12 | -------------------------------------------------------------------------------- /test-tap/fixture/test-count.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../entrypoints/main.cjs'); 2 | 3 | test('passCount', t => { 4 | t.pass(); 5 | }); 6 | 7 | test('failCount', t => { 8 | t.fail(); 9 | }); 10 | 11 | test.skip('skipCount', t => { 12 | t.pass(); 13 | }); 14 | 15 | test.todo('todoCount'); 16 | -------------------------------------------------------------------------------- /test-tap/integration/repl.js: -------------------------------------------------------------------------------- 1 | import {execa} from 'execa'; 2 | import {test} from 'tap'; 3 | 4 | test('Throws error when required from the REPL', t => execa('node', ['-r', 'ava'], {reject: false}).then(result => { 5 | t.match(result.stderr, 'The ’ava’ module can only be imported in test files'); 6 | })); 7 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-content/test.cjs.md.expected: -------------------------------------------------------------------------------- 1 | # Snapshot report for `tests/test.cjs` 2 | 3 | The actual snapshot is saved in `test.cjs.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## test title 8 | 9 | > Snapshot 1 10 | 11 | { 12 | foo: 'bar', 13 | } 14 | -------------------------------------------------------------------------------- /test-tap/fixture/test-count-2.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../entrypoints/main.cjs'); 2 | 3 | test('passCount', t => { 4 | t.pass(); 5 | }); 6 | 7 | test('failCount', t => { 8 | t.fail(); 9 | }); 10 | 11 | test.skip('skipCount', t => { 12 | t.pass(); 13 | }); 14 | 15 | test.todo('todoCount'); 16 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/changing-title/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | test(`a ${process.env.TEMPLATE ? '' : 'new '}title`, t => { 4 | t.snapshot({foo: 'one'}); 5 | }); 6 | -------------------------------------------------------------------------------- /media/screenshot-fixtures/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "screenshot-fixtures", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "magic-assert-buffers.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "" 11 | } 12 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/__tests__-dir/__tests__/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../../entrypoints/main.cjs'); 2 | 3 | test('test title', t => { 4 | t.snapshot({foo: 'bar'}); 5 | 6 | t.snapshot({answer: 42}); 7 | }); 8 | 9 | test('another test', t => { 10 | t.snapshot(new Map()); 11 | }); 12 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-snapshot-location/src/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../../entrypoints/main.cjs'); 2 | 3 | test('test title', t => { 4 | t.snapshot({foo: 'bar'}); 5 | 6 | t.snapshot({answer: 42}); 7 | }); 8 | 9 | test('another test', t => { 10 | t.snapshot(new Map()); 11 | }); 12 | -------------------------------------------------------------------------------- /test/assertions/fixtures/happy-path.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `happy-path.js` 2 | 3 | The actual snapshot is saved in `happy-path.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## t.snapshot({"foo":"bar"}) passes 8 | 9 | > Snapshot 1 10 | 11 | { 12 | foo: 'bar', 13 | } 14 | -------------------------------------------------------------------------------- /test/node-arguments/fixtures/node-arguments-from-config/node-arguments-from-config.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('works', t => { 4 | t.plan(2); 5 | t.truthy(global.SETUP_CALLED, 'setup variable set'); 6 | t.truthy(process.execArgv.some(argv => argv.startsWith('--require')), 'require passed'); 7 | }); 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggestions for new or different behavior 4 | labels: question 5 | --- 6 | 7 | Please provide details about: 8 | 9 | * What you're trying to do 10 | * Why you can't use AVA for this 11 | * And maybe how you think AVA could handle this 12 | -------------------------------------------------------------------------------- /test-tap/fixture/match-no-match-2.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../entrypoints/main.cjs'); 2 | 3 | test('this test will match', t => { 4 | t.pass(); 5 | }); 6 | 7 | test('this test will not match', t => { 8 | t.pass(); 9 | }); 10 | 11 | test('this test will also not match', t => { 12 | t.pass(); 13 | }); 14 | -------------------------------------------------------------------------------- /media/screenshot-fixtures/magic-assert-objects.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('objects', t => { 4 | const actual = { 5 | a: 1, 6 | b: { 7 | c: 2 8 | } 9 | }; 10 | 11 | const expected = { 12 | a: 1, 13 | b: { 14 | c: 3 15 | } 16 | }; 17 | 18 | t.deepEqual(actual, expected); 19 | }); 20 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/changing-label/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | test('foo', t => { 4 | t.snapshot({foo: 'one'}, process.env.TEMPLATE ? undefined : 'a new message'); 5 | }); 6 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/commit-skip/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## commit a skipped snapshot 8 | 9 | > Snapshot 1 10 | 11 | 1 12 | 13 | > Snapshot 2 14 | 15 | 'before' 16 | -------------------------------------------------------------------------------- /ava.config.js: -------------------------------------------------------------------------------- 1 | export default { // eslint-disable-line import/no-anonymous-default-export 2 | files: ['test/**', '!test/**/{fixtures,helpers}/**'], 3 | ignoredByWatcher: ['{coverage,docs,media,test-d,test-tap}/**'], 4 | environmentVariables: { 5 | AVA_FAKE_SCM_ROOT: '.fake-root', // This is an internal test flag. 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /test-tap/reporters/default.only.v12.log: -------------------------------------------------------------------------------- 1 | 2 | ---tty-stream-chunk-separator 3 | ✔ a › only 4 | ---tty-stream-chunk-separator 5 | ✔ b › passes 6 | ---tty-stream-chunk-separator 7 | ─ 8 | 9 | 2 tests passed 10 | ---tty-stream-chunk-separator 11 | -------------------------------------------------------------------------------- /test-tap/reporters/default.only.v14.log: -------------------------------------------------------------------------------- 1 | 2 | ---tty-stream-chunk-separator 3 | ✔ a › only 4 | ---tty-stream-chunk-separator 5 | ✔ b › passes 6 | ---tty-stream-chunk-separator 7 | ─ 8 | 9 | 2 tests passed 10 | ---tty-stream-chunk-separator 11 | -------------------------------------------------------------------------------- /test-tap/reporters/default.only.v16.log: -------------------------------------------------------------------------------- 1 | 2 | ---tty-stream-chunk-separator 3 | ✔ a › only 4 | ---tty-stream-chunk-separator 5 | ✔ b › passes 6 | ---tty-stream-chunk-separator 7 | ─ 8 | 9 | 2 tests passed 10 | ---tty-stream-chunk-separator 11 | -------------------------------------------------------------------------------- /test/shared-workers/restricted-to-worker-threads/fixtures/test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | import * as plugin from 'ava/plugin'; 3 | 4 | plugin.registerSharedWorker({ 5 | filename: new URL('_worker.js', import.meta.url), 6 | supportedProtocols: ['ava-4'], 7 | }); 8 | 9 | test('registering', t => { 10 | t.pass(); 11 | }); 12 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/discard-skip/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## discard a skipped snapshot 8 | 9 | > Snapshot 1 10 | 11 | 1 12 | 13 | > Snapshot 2 14 | 15 | 'before (second try)' 16 | -------------------------------------------------------------------------------- /examples/timeouts/readme.md: -------------------------------------------------------------------------------- 1 | # Test timeouts 2 | 3 | > Example for [test timeouts](https://github.com/avajs/ava/blob/main/docs/07-test-timeouts.md) 4 | 5 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/avajs/ava/tree/main/examples/timeouts?file=test.js&terminal=test&view=editor) 6 | -------------------------------------------------------------------------------- /lib/worker/main.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | require('./guard-environment.cjs'); // eslint-disable-line import/no-unassigned-import 3 | 4 | const assert = require('assert'); 5 | 6 | const {flags, refs} = require('./state.cjs'); 7 | 8 | assert(refs.runnerChain); 9 | 10 | flags.loadedMain = true; 11 | 12 | module.exports = refs.runnerChain; 13 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-snapshot-location/src/feature/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../../../entrypoints/main.cjs'); 2 | 3 | test('test feature title', t => { 4 | t.snapshot({foo: 'bar'}); 5 | 6 | t.snapshot({answer: 42}); 7 | }); 8 | 9 | test('another feature test', t => { 10 | t.snapshot(new Map()); 11 | }); 12 | -------------------------------------------------------------------------------- /test/extensions/fixtures/shared-duplicates/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "ava": { 4 | "typescript": { 5 | "rewritePaths": { 6 | "src/": "build/" 7 | }, 8 | "compile": false, 9 | "extensions": [ 10 | "ts", 11 | "tsx" 12 | ] 13 | }, 14 | "extensions": [ 15 | "tsx" 16 | ] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/endpoint-testing/app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = (request, response) => { 4 | if (request.url === '/user') { 5 | response.setHeader('Content-Type', 'application/json'); 6 | response.end(JSON.stringify({email: 'ava@rocks.com'})); 7 | } else { 8 | response.writeHead('404'); 9 | response.end(); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /test/meta/fixtures/meta.mjs: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('meta.file', t => { 4 | t.is(test.meta.file, import.meta.url); 5 | }); 6 | 7 | test('meta.snapshotDirectory', t => { 8 | const {meta} = test; 9 | t.true(meta.snapshotDirectory.startsWith('file://')); 10 | t.regex(meta.snapshotDirectory, /snapshot-fixture/); 11 | }); 12 | 13 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/skipping-snapshot/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | test('foo', t => { 4 | (process.env.TEMPLATE ? t.snapshot : t.snapshot.skip)({foo: 'one'}); 5 | t.snapshot({foo: 'two'}); 6 | }); 7 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-sourcemaps/build/test/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../../../entrypoints/main.cjs'); 2 | test('test title', t => { 3 | t.snapshot({ foo: 'bar' }); 4 | t.snapshot({ answer: 43 }); 5 | }); 6 | test('another test', t => { 7 | t.snapshot(new Map()); 8 | }); 9 | //# sourceMappingURL=test.cjs.map 10 | -------------------------------------------------------------------------------- /examples/tap-reporter/test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const test = require('ava'); 3 | 4 | test('unicorn', t => { 5 | t.pass(); 6 | }); 7 | 8 | test('rainbow', t => { 9 | t.fail(); 10 | }); 11 | 12 | test('foo', t => { 13 | t.pass(); 14 | }); 15 | 16 | test('bar', t => { 17 | t.pass(); 18 | }); 19 | 20 | test('baz', t => { 21 | t.pass(); 22 | }); 23 | -------------------------------------------------------------------------------- /test/helpers/with-temporary-fixture.js: -------------------------------------------------------------------------------- 1 | import fse from 'fs-extra'; 2 | import tempy from 'tempy'; 3 | 4 | export async function withTemporaryFixture(cwd, task) { 5 | let result; 6 | await tempy.directory.task(async temporary => { 7 | await fse.copy(cwd, temporary); 8 | result = await task(temporary); 9 | }); 10 | 11 | return result; 12 | } 13 | -------------------------------------------------------------------------------- /test/shared-workers/worker-execution-crash/test.js: -------------------------------------------------------------------------------- 1 | import test from '@ava/test'; 2 | 3 | import {fixture} from '../../helpers/exec.js'; 4 | 5 | test('shared worker plugins work', async t => { 6 | const result = await t.throwsAsync(fixture()); 7 | t.snapshot(result.stats.passed); 8 | t.is(result.stats.sharedWorkerErrors[0].message, '🙈'); 9 | }); 10 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/adding-snapshots/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | test('foo', t => { 4 | t.snapshot({foo: 'one'}); 5 | 6 | if (!process.env.TEMPLATE) { 7 | t.snapshot({foo: 'two'}); 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/removing-snapshots/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | test('foo', t => { 4 | t.snapshot({foo: 'one'}); 5 | 6 | if (process.env.TEMPLATE) { 7 | t.snapshot({foo: 'two'}); 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: Discussions 4 | url: https://github.com/avajs/ava/discussions 5 | about: Questions? Ideas? Something to share? 6 | - name: TypeScript compilation 7 | url: https://github.com/avajs/typescript/issues 8 | about: Report a bug with AVA's TypeScript integration 9 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-sourcemaps/build/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../../entrypoints/main.cjs'); 2 | test('top level test title', t => { 3 | t.snapshot({ foo: 'bar' }); 4 | t.snapshot({ answer: 42 }); 5 | }); 6 | test('another top level test', t => { 7 | t.snapshot(new Map()); 8 | }); 9 | //# sourceMappingURL=test.cjs.map 10 | -------------------------------------------------------------------------------- /test/snapshot-tests/fixtures/normalized-title-in-snapshots/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); 2 | 3 | test('test\r\n\ttitle', t => { 4 | t.snapshot('Hello, World!'); 5 | }); 6 | 7 | test('test\r\n\ttitle', Object.assign(t => { 8 | t.snapshot('Hello, World!'); 9 | }, { 10 | title: title => `macro\n${title}`, 11 | })); 12 | 13 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-sourcemaps/src/test/test.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-unsafe-call */ 2 | import test from '../../../../../../entrypoints/main.cjs'; 3 | 4 | test('test title', t => { 5 | t.snapshot({foo: 'bar'}); 6 | 7 | t.snapshot({answer: 43}); 8 | }); 9 | 10 | test('another test', t => { 11 | t.snapshot(new Map()); 12 | }); 13 | -------------------------------------------------------------------------------- /test-tap/fixture/test-count-3.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../entrypoints/main.cjs'); 2 | 3 | test('passCount', t => { 4 | t.pass(); 5 | }); 6 | 7 | test('passCount2', t => { 8 | t.pass(); 9 | }); 10 | 11 | test('failCount', t => { 12 | t.fail(); 13 | }); 14 | 15 | test.skip('skipCount', t => { 16 | t.pass(); 17 | }); 18 | 19 | test.todo('todoCount'); 20 | -------------------------------------------------------------------------------- /test/shared-workers/worker-startup-crashes/fixtures/module.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | import * as plugin from 'ava/plugin'; 3 | 4 | plugin.registerSharedWorker({ 5 | filename: new URL('_module.js', import.meta.url), 6 | supportedProtocols: ['ava-4'], 7 | }); 8 | 9 | test('shared worker should cause tests to fail', t => { 10 | t.fail(); 11 | }); 12 | 13 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/removing-snapshots/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## foo 8 | 9 | > Snapshot 1 10 | 11 | { 12 | foo: 'one', 13 | } 14 | 15 | > Snapshot 2 16 | 17 | { 18 | foo: 'two', 19 | } 20 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/skipping-snapshot/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## foo 8 | 9 | > Snapshot 1 10 | 11 | { 12 | foo: 'one', 13 | } 14 | 15 | > Snapshot 2 16 | 17 | { 18 | foo: 'two', 19 | } 20 | -------------------------------------------------------------------------------- /examples/endpoint-testing/readme.md: -------------------------------------------------------------------------------- 1 | # Endpoint testing 2 | 3 | > Example for [endpoint testing](https://github.com/avajs/ava/blob/main/docs/recipes/endpoint-testing.md) 4 | 5 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/avajs/ava/tree/main/examples/endpoint-testing?file=test.js&terminal=test&view=editor) 6 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-snapshot-location/src/feature/nested-feature/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../../../../entrypoints/main.cjs'); 2 | 3 | test('test nested feature title', t => { 4 | t.snapshot({foo: 'bar'}); 5 | 6 | t.snapshot({answer: 42}); 7 | }); 8 | 9 | test('another nested feature test', t => { 10 | t.snapshot(new Map()); 11 | }); 12 | -------------------------------------------------------------------------------- /test/shared-workers/unsupported-protocol/fixtures/in-shared-worker.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | import * as plugin from 'ava/plugin'; 3 | 4 | plugin.registerSharedWorker({ 5 | filename: new URL('_worker.js', import.meta.url), 6 | supportedProtocols: ['ava-4'], 7 | }); 8 | 9 | test('shared worker should cause tests to fail', t => { 10 | t.fail(); 11 | }); 12 | 13 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/skipping-snapshot-update/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## foo 8 | 9 | > Snapshot 1 10 | 11 | { 12 | foo: 'one', 13 | } 14 | 15 | > Snapshot 2 16 | 17 | { 18 | foo: 'two', 19 | } 20 | -------------------------------------------------------------------------------- /lib/worker/options.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | let options = null; 3 | exports.get = () => { 4 | if (!options) { 5 | throw new Error('Options have not yet been set'); 6 | } 7 | 8 | return options; 9 | }; 10 | 11 | exports.set = newOptions => { 12 | if (options) { 13 | throw new Error('Options have already been set'); 14 | } 15 | 16 | options = newOptions; 17 | }; 18 | -------------------------------------------------------------------------------- /test-tap/fixture/matcher-skip.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../entrypoints/main.cjs'); 2 | 3 | test('foo', t => { 4 | t.pass(); 5 | }); 6 | 7 | test('bar', t => { 8 | t.pass(); 9 | }); 10 | 11 | test('baz', t => { 12 | t.fail(); 13 | }); 14 | 15 | test('tests are fun', t => { 16 | t.pass(); 17 | }); 18 | 19 | test('tests are not fun', t => { 20 | t.fail(); 21 | }); 22 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-sourcemaps/build/feature/__tests__/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../../../../entrypoints/main.cjs'); 2 | test('feature test title', t => { 3 | t.snapshot({ foo: 'bar' }); 4 | t.snapshot({ answer: 40 }); 5 | }); 6 | test('another feature test', t => { 7 | t.snapshot(new Map()); 8 | }); 9 | //# sourceMappingURL=test.cjs.map 10 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-sourcemaps/src/test.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-unsafe-call */ 2 | import test from '../../../../../entrypoints/main.cjs'; 3 | 4 | test('top level test title', t => { 5 | t.snapshot({foo: 'bar'}); 6 | 7 | t.snapshot({answer: 42}); 8 | }); 9 | 10 | test('another top level test', t => { 11 | t.snapshot(new Map()); 12 | }); 13 | -------------------------------------------------------------------------------- /test/snapshot-order/helpers/get-snapshot-ids.js: -------------------------------------------------------------------------------- 1 | export default function getSnapshotIds(report) { 2 | function * matchAll(string, regexp) { 3 | let match; 4 | while ((match = regexp.exec(string)) !== null) { 5 | yield match; 6 | } 7 | } 8 | 9 | const ids = [...matchAll(report, /'index: ([-.\d]+)'/g)].map(match => Number(match[1])); 10 | 11 | return ids; 12 | } 13 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/only-test/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## some snapshots 8 | 9 | > Snapshot 1 10 | 11 | 'foo' 12 | 13 | > Snapshot 2 14 | 15 | 'bar' 16 | 17 | ## another snapshot 18 | 19 | > Snapshot 1 20 | 21 | 'baz' 22 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/removal/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## some snapshots 8 | 9 | > Snapshot 1 10 | 11 | 'foo' 12 | 13 | > Snapshot 2 14 | 15 | 'bar' 16 | 17 | ## another snapshot 18 | 19 | > Snapshot 1 20 | 21 | 'baz' 22 | -------------------------------------------------------------------------------- /test/snapshot-tests/fixtures/multiline-snapshot-label/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); 2 | 3 | const f = () => [ 4 | 'Hello', 5 | 'World!', 6 | ].join(', '); 7 | 8 | test('snapshot with a multiline label', t => { 9 | const result = f(); 10 | const label = '```javascript\n' + f.toString() + '\n```'; 11 | t.snapshot(result, label); 12 | }); 13 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/removing-test/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## foo 8 | 9 | > Snapshot 1 10 | 11 | { 12 | foo: 'one', 13 | } 14 | 15 | ## bar 16 | 17 | > Snapshot 1 18 | 19 | { 20 | bar: 'one', 21 | } 22 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/skipping-test/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | (process.env.TEMPLATE ? test : test.skip)('foo', t => { 4 | t.snapshot({foo: 'one'}); 5 | }); 6 | 7 | test('bar', t => { 8 | t.snapshot({bar: 'one'}); 9 | }); 10 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/skipping-test/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## foo 8 | 9 | > Snapshot 1 10 | 11 | { 12 | foo: 'one', 13 | } 14 | 15 | ## bar 16 | 17 | > Snapshot 1 18 | 19 | { 20 | bar: 'one', 21 | } 22 | -------------------------------------------------------------------------------- /examples/macros/readme.md: -------------------------------------------------------------------------------- 1 | # Macros 2 | 3 | > Example for [reusing test logic through macros](https://github.com/avajs/ava/blob/main/docs/01-writing-tests.md#reusing-test-logic-through-macros) 4 | 5 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/avajs/ava/tree/main/examples/macros?file=test.js&terminal=test&view=editor) 6 | -------------------------------------------------------------------------------- /test-tap/fixture/report/regular/unhandled-rejection.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | const passes = t => { 4 | Promise.reject(new Error('Can’t catch me')); 5 | t.pass(); 6 | }; 7 | 8 | test('passes', passes); 9 | 10 | test('unhandled non-error rejection', t => { 11 | const error = null; 12 | Promise.reject(error); 13 | t.pass(); 14 | }); 15 | -------------------------------------------------------------------------------- /test/shared-workers/worker-startup-crashes/fixtures/factory-function.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | import * as plugin from 'ava/plugin'; 3 | 4 | plugin.registerSharedWorker({ 5 | filename: new URL('_factory-function.js', import.meta.url), 6 | supportedProtocols: ['ava-4'], 7 | }); 8 | 9 | test('shared worker should cause tests to fail', t => { 10 | t.fail(); 11 | }); 12 | 13 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/skipped-tests/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## some snapshots 8 | 9 | > Snapshot 1 10 | 11 | 'foo' 12 | 13 | > Snapshot 2 14 | 15 | 'bar' 16 | 17 | ## another snapshot 18 | 19 | > Snapshot 1 20 | 21 | 'baz' 22 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/adding-test/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | test('foo', t => { 4 | t.snapshot({foo: 'one'}); 5 | }); 6 | 7 | if (!process.env.TEMPLATE) { 8 | test('bar', t => { 9 | t.snapshot({bar: 'one'}); 10 | }); 11 | } 12 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/removing-all-snapshots/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## foo 8 | 9 | > Snapshot 1 10 | 11 | { 12 | foo: 'one', 13 | } 14 | 15 | ## bar 16 | 17 | > Snapshot 1 18 | 19 | { 20 | bar: 'one', 21 | } 22 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/removing-test/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | test('foo', t => { 4 | t.snapshot({foo: 'one'}); 5 | }); 6 | 7 | if (process.env.TEMPLATE) { 8 | test('bar', t => { 9 | t.snapshot({bar: 'one'}); 10 | }); 11 | } 12 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/reorder/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## first test 8 | 9 | > Snapshot 1 10 | 11 | { 12 | foo: 'bar', 13 | } 14 | 15 | ## second test 16 | 17 | > Snapshot 1 18 | 19 | { 20 | bar: 'baz', 21 | } 22 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/select-test-update/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## foo 8 | 9 | > Snapshot 1 10 | 11 | { 12 | foo: 'one', 13 | } 14 | 15 | ## bar 16 | 17 | > Snapshot 1 18 | 19 | { 20 | bar: 'one', 21 | } 22 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/skipping-test-update/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## foo 8 | 9 | > Snapshot 1 10 | 11 | { 12 | foo: 'one', 13 | } 14 | 15 | ## bar 16 | 17 | > Snapshot 1 18 | 19 | { 20 | bar: 'one', 21 | } 22 | -------------------------------------------------------------------------------- /examples/typescript-basic/readme.md: -------------------------------------------------------------------------------- 1 | # TypeScript basic example 2 | 3 | > Basic example for [AVA with TypeScript](https://github.com/avajs/ava/blob/main/docs/recipes/typescript.md) 4 | 5 | [![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) 6 | -------------------------------------------------------------------------------- /test-tap/fixture/extensions/test.foo.bar: -------------------------------------------------------------------------------- 1 | const test = require('../../../entrypoints/main.cjs'); 2 | 3 | const one = {one: 1}; 4 | const two = {two: 2}; 5 | 6 | test('foo', t => { 7 | // Using optional catch-binding to ensure it transpiles on Node.js 8, since this 8 | // is a Node.js 10 feature 9 | try { 10 | throw new Error('test') 11 | } catch { 12 | t.pass() 13 | } 14 | }); 15 | -------------------------------------------------------------------------------- /test/shared-workers/lifecycle/test.js: -------------------------------------------------------------------------------- 1 | import test from '@ava/test'; 2 | 3 | import {fixture} from '../../helpers/exec.js'; 4 | 5 | test('availability', async t => { 6 | await t.notThrowsAsync(fixture(['available.js'])); 7 | }); 8 | 9 | test('teardown', async t => { 10 | const result = await fixture('teardown.js'); 11 | t.true(result.stderr.includes('TEARDOWN CALLED')); 12 | }); 13 | -------------------------------------------------------------------------------- /test/shared-workers/worker-startup-crashes/fixtures/no-factory-function.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | import * as plugin from 'ava/plugin'; 3 | 4 | plugin.registerSharedWorker({ 5 | filename: new URL('_no-factory-function.js', import.meta.url), 6 | supportedProtocols: ['ava-4'], 7 | }); 8 | 9 | test('shared worker should cause tests to fail', t => { 10 | t.fail(); 11 | }); 12 | 13 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/skipped-snapshots/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## some snapshots 8 | 9 | > Snapshot 1 10 | 11 | 'foo' 12 | 13 | > Snapshot 2 14 | 15 | 'bar' 16 | 17 | ## another snapshot 18 | 19 | > Snapshot 1 20 | 21 | 'baz' 22 | -------------------------------------------------------------------------------- /examples/macros/test.js: -------------------------------------------------------------------------------- 1 | const test = require('ava'); 2 | 3 | const {sum} = require('.'); 4 | 5 | function macro(t, a, b, expected) { 6 | t.is(sum(a, b), expected); 7 | } 8 | 9 | macro.title = (providedTitle, a, b, expected) => `${providedTitle || ''} ${a}+${b} = ${expected}`.trim(); 10 | 11 | test(macro, 2, 2, 4); 12 | test(macro, 3, 3, 6); 13 | test('providedTitle', macro, 4, 4, 8); 14 | -------------------------------------------------------------------------------- /test/meta/test.js: -------------------------------------------------------------------------------- 1 | import test from '@ava/test'; 2 | 3 | import {fixture} from '../helpers/exec.js'; 4 | 5 | test('with CJS files', async t => { 6 | const result = await fixture(['meta.cjs']); 7 | t.is(result.stats.passed.length, 2); 8 | }); 9 | 10 | test('with MJS files', async t => { 11 | const result = await fixture(['meta.mjs']); 12 | t.is(result.stats.passed.length, 2); 13 | }); 14 | -------------------------------------------------------------------------------- /test/shared-workers/workers-are-loaded-once/fixtures/_worker.js: -------------------------------------------------------------------------------- 1 | import crypto from 'node:crypto'; 2 | 3 | export default async ({negotiateProtocol}) => { 4 | const protocol = negotiateProtocol(['ava-4']).ready(); 5 | 6 | const random = crypto.randomBytes(16).toString('hex'); 7 | for await (const testWorker of protocol.testWorkers()) { 8 | testWorker.publish({random}); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-sourcemaps/src/feature/__tests__/test.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-unsafe-call */ 2 | import test from '../../../../../../../entrypoints/main.cjs'; 3 | 4 | test('feature test title', t => { 5 | t.snapshot({foo: 'bar'}); 6 | 7 | t.snapshot({answer: 40}); 8 | }); 9 | 10 | test('another feature test', t => { 11 | t.snapshot(new Map()); 12 | }); 13 | -------------------------------------------------------------------------------- /test-tap/fixture/with-dependencies/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../entrypoints/main.cjs'); 2 | 3 | require('./dep-1.js'); // eslint-disable-line import/no-unassigned-import 4 | require('./dep-2.js'); // eslint-disable-line import/no-unassigned-import 5 | require('./dep-3.custom'); // eslint-disable-line import/no-unassigned-import 6 | 7 | test('hey ho', t => { 8 | t.pass(); 9 | }); 10 | -------------------------------------------------------------------------------- /test/shared-workers/workers-are-loaded-once/test.js: -------------------------------------------------------------------------------- 1 | import test from '@ava/test'; 2 | 3 | import {fixture} from '../../helpers/exec.js'; 4 | 5 | test('shared workers are loaded only once', async t => { 6 | const result = await fixture(); 7 | const logs = result.stats.passed.map(object => result.stats.getLogs(object)); 8 | t.is(logs.length, 2); 9 | t.deepEqual(logs[0], logs[1]); 10 | }); 11 | -------------------------------------------------------------------------------- /test-tap/fixture/with-dependencies/test-failure.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../entrypoints/main.cjs'); 2 | 3 | require('./dep-1.js'); // eslint-disable-line import/no-unassigned-import 4 | require('./dep-2.js'); // eslint-disable-line import/no-unassigned-import 5 | require('./dep-3.custom'); // eslint-disable-line import/no-unassigned-import 6 | 7 | test('hey ho', t => { 8 | t.fail(); 9 | }); 10 | -------------------------------------------------------------------------------- /test/shared-workers/workers-are-loaded-once/fixtures/_plugin.js: -------------------------------------------------------------------------------- 1 | import * as plugin from 'ava/plugin'; 2 | 3 | const worker = plugin.registerSharedWorker({ 4 | filename: new URL('_worker.js', import.meta.url), 5 | supportedProtocols: ['ava-4'], 6 | }); 7 | 8 | const messages = worker.subscribe(); 9 | export const random = messages.next().then(({value}) => value).finally(() => messages.return()); 10 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/snapshot-dir/test/snapshots/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test/test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## some snapshots 8 | 9 | > Snapshot 1 10 | 11 | 'foo' 12 | 13 | > Snapshot 2 14 | 15 | 'bar' 16 | 17 | ## another snapshot 18 | 19 | > Snapshot 1 20 | 21 | 'baz' 22 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/adding-skipped-snapshots/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | test('foo', t => { 4 | t.snapshot({foo: 'one'}); 5 | 6 | if (!process.env.TEMPLATE) { 7 | t.snapshot.skip({foo: 'two'}); 8 | t.snapshot({foo: 'three'}); 9 | } 10 | }); 11 | -------------------------------------------------------------------------------- /test-tap/fixture/report/timeoutinsinglefile/a.cjs: -------------------------------------------------------------------------------- 1 | const delay = require('delay'); 2 | 3 | const test = require('../../../../entrypoints/main.cjs'); 4 | 5 | test('passes', t => t.pass()); 6 | 7 | test('slow', async t => { 8 | await delay(15_000); 9 | t.pass(); 10 | }); 11 | test('slow two', async t => { 12 | await delay(15_000); 13 | t.pass(); 14 | }); 15 | 16 | test('passes two', t => t.pass()); 17 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/fixed-snapshot-dir/fixedSnapshotDir/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## some snapshots 8 | 9 | > Snapshot 1 10 | 11 | 'foo' 12 | 13 | > Snapshot 2 14 | 15 | 'bar' 16 | 17 | ## another snapshot 18 | 19 | > Snapshot 1 20 | 21 | 'baz' 22 | -------------------------------------------------------------------------------- /test/meta/fixtures/meta.cjs: -------------------------------------------------------------------------------- 1 | const url = require('url'); 2 | 3 | const test = require('ava'); 4 | 5 | test('meta.file', t => { 6 | t.is(test.meta.file, url.pathToFileURL(__filename).toString()); 7 | }); 8 | 9 | test('meta.snapshotDirectory', t => { 10 | const {meta} = test; 11 | t.true(meta.snapshotDirectory.startsWith('file://')); 12 | t.regex(meta.snapshotDirectory, /snapshot-fixture/); 13 | }); 14 | 15 | -------------------------------------------------------------------------------- /test/shared-workers/worker-execution-crash/fixtures/_worker.js: -------------------------------------------------------------------------------- 1 | export default async ({negotiateProtocol}) => { 2 | const protocol = negotiateProtocol(['ava-4']); 3 | protocol.ready(); 4 | 5 | crash(protocol.subscribe()); 6 | }; 7 | 8 | async function crash(messages) { 9 | for await (const message of messages) { // eslint-disable-line no-unreachable-loop 10 | throw new Error(message.data); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/filling-in-blanks/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## foo 8 | 9 | > Snapshot 1 10 | 11 | { 12 | foo: 'one', 13 | } 14 | 15 | > Snapshot 2 16 | 17 | 18 | 19 | > Snapshot 3 20 | 21 | { 22 | foo: 'three', 23 | } 24 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/removing-all-snapshots/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | test('foo', t => { 4 | if (process.env.TEMPLATE) { 5 | t.snapshot({foo: 'one'}); 6 | } 7 | 8 | t.pass(); 9 | }); 10 | 11 | test('bar', t => { 12 | t.snapshot({bar: 'one'}); 13 | }); 14 | -------------------------------------------------------------------------------- /examples/tap-reporter/readme.md: -------------------------------------------------------------------------------- 1 | # Running tests at specific line numbers 2 | 3 | > Example for a [custom TAP reporter](https://github.com/avajs/ava/blob/main/docs/05-command-line.md#running-tests-at-specific-line-numbers) 4 | 5 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/avajs/ava/tree/main/examples/tap-reporter?file=test.js&terminal=test&view=editor) 6 | -------------------------------------------------------------------------------- /examples/typescript-context/readme.md: -------------------------------------------------------------------------------- 1 | # TypeScript context example 2 | 3 | > TypeScript example for [typing `t.context`](https://github.com/avajs/ava/blob/main/docs/recipes/typescript.md#typing-tcontext) 4 | 5 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/avajs/ava/tree/main/examples/typescript-context?file=source%2Ftest.ts&terminal=test&view=editor) 6 | -------------------------------------------------------------------------------- /test-tap/fixture/report/timeoutinmultiplefiles/a.cjs: -------------------------------------------------------------------------------- 1 | const delay = require('delay'); 2 | 3 | const test = require('../../../../entrypoints/main.cjs'); 4 | 5 | test('a passes', t => t.pass()); 6 | 7 | test('a slow', async t => { 8 | await delay(15_000); 9 | t.pass(); 10 | }); 11 | test('a slow two', async t => { 12 | await delay(15_000); 13 | t.pass(); 14 | }); 15 | 16 | test('a passes two', t => t.pass()); 17 | -------------------------------------------------------------------------------- /test-tap/node-arguments.js: -------------------------------------------------------------------------------- 1 | import {test} from 'tap'; 2 | 3 | import normalizeNodeArguments from '../lib/node-arguments.js'; 4 | 5 | test('combines arguments', async t => { 6 | t.same( 7 | await normalizeNodeArguments(['--require setup.cjs'], '--throw-deprecation --zero-fill-buffers'), 8 | [...process.execArgv, '--require setup.cjs', '--throw-deprecation', '--zero-fill-buffers'], 9 | ); 10 | t.end(); 11 | }); 12 | -------------------------------------------------------------------------------- /test-tap/reporters/tap.failfast.v12.log: -------------------------------------------------------------------------------- 1 | TAP version 13 2 | ---tty-stream-chunk-separator 3 | not ok 1 - a › fails 4 | --- 5 | name: AssertionError 6 | message: Test failed via `t.fail()` 7 | assertion: fail 8 | at: 'test-tap/fixture/report/failfast/a.cjs:3:22' 9 | ... 10 | ---tty-stream-chunk-separator 11 | 12 | 1..1 13 | # tests 1 14 | # pass 0 15 | # fail 1 16 | 17 | ---tty-stream-chunk-separator 18 | -------------------------------------------------------------------------------- /test-tap/reporters/tap.failfast.v14.log: -------------------------------------------------------------------------------- 1 | TAP version 13 2 | ---tty-stream-chunk-separator 3 | not ok 1 - a › fails 4 | --- 5 | name: AssertionError 6 | message: Test failed via `t.fail()` 7 | assertion: fail 8 | at: 'test-tap/fixture/report/failfast/a.cjs:3:22' 9 | ... 10 | ---tty-stream-chunk-separator 11 | 12 | 1..1 13 | # tests 1 14 | # pass 0 15 | # fail 1 16 | 17 | ---tty-stream-chunk-separator 18 | -------------------------------------------------------------------------------- /test-tap/reporters/tap.failfast.v16.log: -------------------------------------------------------------------------------- 1 | TAP version 13 2 | ---tty-stream-chunk-separator 3 | not ok 1 - a › fails 4 | --- 5 | name: AssertionError 6 | message: Test failed via `t.fail()` 7 | assertion: fail 8 | at: 'test-tap/fixture/report/failfast/a.cjs:3:22' 9 | ... 10 | ---tty-stream-chunk-separator 11 | 12 | 1..1 13 | # tests 1 14 | # pass 0 15 | # fail 1 16 | 17 | ---tty-stream-chunk-separator 18 | -------------------------------------------------------------------------------- /test/shared-workers/worker-startup-crashes/snapshots/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test/shared-workers/worker-startup-crashes/test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## handles crashes in when there is no factory function 8 | 9 | > Snapshot 1 10 | 11 | 'Missing default factory function export for shared worker plugin at FILE' 12 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/select-test-update/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | test('foo', t => { 4 | t.snapshot(process.env.TEMPLATE ? {foo: 'one'} : {foo: 'new'}); 5 | }); 6 | 7 | test('bar', t => { 8 | t.snapshot(process.env.TEMPLATE ? {bar: 'one'} : {bar: 'new'}); 9 | }); 10 | -------------------------------------------------------------------------------- /examples/matching-titles/readme.md: -------------------------------------------------------------------------------- 1 | # Running tests with matching titles 2 | 3 | > Example for [running tests with matching titles](https://github.com/avajs/ava/blob/main/docs/05-command-line.md#running-tests-with-matching-titles) 4 | 5 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/avajs/ava/tree/main/examples/matching-titles?file=test.js&terminal=test&view=editor) 6 | -------------------------------------------------------------------------------- /lib/chalk.js: -------------------------------------------------------------------------------- 1 | import {Chalk} from 'chalk'; // eslint-disable-line unicorn/import-style 2 | 3 | let chalk = new Chalk(); // eslint-disable-line import/no-mutable-exports 4 | 5 | export {chalk}; 6 | 7 | let configured = false; 8 | export function set(options) { 9 | if (configured) { 10 | throw new Error('Chalk has already been configured'); 11 | } 12 | 13 | configured = true; 14 | chalk = new Chalk(options); 15 | } 16 | -------------------------------------------------------------------------------- /test/configurable-module-format/fixtures/test.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call */ 2 | const test = require('ava'); // eslint-disable-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires, ava/no-ignored-test-files, unicorn/prefer-module 3 | 4 | test('always passing test', t => { 5 | const numberWithTypes = 0; 6 | 7 | t.is(numberWithTypes, 0); 8 | }); 9 | -------------------------------------------------------------------------------- /test/shared-workers/worker-execution-crash/snapshots/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test/shared-workers/worker-execution-crash/test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## shared worker plugins work 8 | 9 | > Snapshot 1 10 | 11 | [ 12 | { 13 | file: 'test.js', 14 | title: 'shared workers crash', 15 | }, 16 | ] 17 | -------------------------------------------------------------------------------- /test-tap/fixture/assert.cjs.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `assert.cjs` 2 | 3 | The actual snapshot is saved in `assert.cjs.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## passes 8 | 9 | > Snapshot 1 10 | 11 | { 12 | foo: 'bar', 13 | } 14 | 15 | > Snapshot 2 16 | 17 | { 18 | foo: 'bar', 19 | } 20 | 21 | ## fails 22 | 23 | > Snapshot 1 24 | 25 | { 26 | foo: 'bar', 27 | } 28 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/first-run/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | test('foo', t => { 4 | t.snapshot({foo: 'one'}); 5 | }); 6 | 7 | test('bar', t => { 8 | t.pass(); 9 | }); 10 | 11 | test('baz', t => { 12 | t.snapshot({baz: 'one'}, 'a message'); 13 | t.snapshot({baz: 'two'}); 14 | }); 15 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | import type {TestFn} from './types/test-fn'; 2 | 3 | export * from './types/assertions'; 4 | export * from './types/try-fn'; 5 | export * from './types/test-fn'; 6 | export * from './types/subscribable'; 7 | 8 | /** Call to declare a test, or chain to declare hooks or test modifiers */ 9 | declare const test: TestFn; 10 | 11 | /** Call to declare a test, or chain to declare hooks or test modifiers */ 12 | export default test; 13 | -------------------------------------------------------------------------------- /test-tap/reporters/default.timeoutwithmatch.v12.log: -------------------------------------------------------------------------------- 1 | 2 | ---tty-stream-chunk-separator 3 | ✔ passes needle 4 | ---tty-stream-chunk-separator 5 |  6 | ✖ Timed out while running tests 7 | 8 | 2 tests were pending in a.cjs 9 | 10 | ◌ slow needle 11 | ◌ slow three needle 12 | 13 | ---tty-stream-chunk-separator 14 | ─ 15 | 16 | 1 test passed 17 | ---tty-stream-chunk-separator 18 | -------------------------------------------------------------------------------- /test-tap/reporters/default.timeoutwithmatch.v14.log: -------------------------------------------------------------------------------- 1 | 2 | ---tty-stream-chunk-separator 3 | ✔ passes needle 4 | ---tty-stream-chunk-separator 5 |  6 | ✖ Timed out while running tests 7 | 8 | 2 tests were pending in a.cjs 9 | 10 | ◌ slow needle 11 | ◌ slow three needle 12 | 13 | ---tty-stream-chunk-separator 14 | ─ 15 | 16 | 1 test passed 17 | ---tty-stream-chunk-separator 18 | -------------------------------------------------------------------------------- /test-tap/reporters/default.timeoutwithmatch.v16.log: -------------------------------------------------------------------------------- 1 | 2 | ---tty-stream-chunk-separator 3 | ✔ passes needle 4 | ---tty-stream-chunk-separator 5 |  6 | ✖ Timed out while running tests 7 | 8 | 2 tests were pending in a.cjs 9 | 10 | ◌ slow needle 11 | ◌ slow three needle 12 | 13 | ---tty-stream-chunk-separator 14 | ─ 15 | 16 | 1 test passed 17 | ---tty-stream-chunk-separator 18 | -------------------------------------------------------------------------------- /test/macros/fixtures/macros.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | const withoutTitle = test.macro((t, arg) => { 4 | t.is(arg, 'arg'); 5 | }); 6 | const withTitle = test.macro({ 7 | exec(t, arg) { 8 | t.is(arg, 'arg'); 9 | }, 10 | title(provided, arg) { 11 | return `${provided || ''} ${arg}`; 12 | }, 13 | }); 14 | 15 | test('without title', withoutTitle, 'arg'); 16 | test('with title', withTitle, 'arg'); 17 | test(withTitle, 'arg'); 18 | -------------------------------------------------------------------------------- /test/shared-workers/cannot-publish-before-available/fixtures/test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | import * as plugin from 'ava/plugin'; 3 | 4 | test('cannot publish before ready', t => { 5 | const worker = plugin.registerSharedWorker({ 6 | filename: new URL('_worker.js', import.meta.url), 7 | supportedProtocols: ['ava-4'], 8 | }); 9 | 10 | t.throws(() => worker.publish(), {message: 'Shared worker is not yet available'}); 11 | }); 12 | -------------------------------------------------------------------------------- /examples/typescript-context/source/test.ts: -------------------------------------------------------------------------------- 1 | import anyTest, {TestInterface} from 'ava'; 2 | 3 | import {concat} from '.'; 4 | 5 | const test = anyTest as TestInterface<{sort: (a: string, b: string) => number}>; 6 | 7 | test.beforeEach(t => { 8 | t.context = { 9 | sort: (a: string, b: string) => a.localeCompare(b) 10 | }; 11 | }); 12 | 13 | test('concat', t => { 14 | t.is(concat(['b', 'c', 'a'].sort(t.context.sort)), 'a b c'); 15 | }); 16 | -------------------------------------------------------------------------------- /test-tap/fixture/process-cwd-default.cjs: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const test = require('../../entrypoints/main.cjs'); 4 | 5 | test('test', async t => { 6 | const {packageConfigSync, packageJsonPath} = await import('pkg-conf'); // eslint-disable-line node/no-unsupported-features/es-syntax 7 | const conf = packageConfigSync('ava'); 8 | const pkgDir = path.dirname(packageJsonPath(conf)); 9 | t.is(process.cwd(), pkgDir); 10 | }); 11 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/filling-in-blanks/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | test('foo', t => { 4 | t.snapshot({foo: 'one'}); 5 | 6 | if (process.env.TEMPLATE) { 7 | t.snapshot.skip({foo: 'two'}); 8 | } else { 9 | t.snapshot({foo: 'two'}); 10 | } 11 | 12 | t.snapshot({foo: 'three'}); 13 | }); 14 | -------------------------------------------------------------------------------- /examples/specific-line-numbers/readme.md: -------------------------------------------------------------------------------- 1 | # Running tests at specific line numbers 2 | 3 | > Example for [running tests at specific line numbers](https://github.com/avajs/ava/blob/main/docs/05-command-line.md#running-tests-at-specific-line-numbers) 4 | 5 | [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/avajs/ava/tree/main/examples/specific-line-numbers?file=test.js&terminal=test&view=editor) 6 | -------------------------------------------------------------------------------- /lib/environment-variables.js: -------------------------------------------------------------------------------- 1 | export default function validateEnvironmentVariables(environmentVariables) { 2 | if (!environmentVariables) { 3 | return {}; 4 | } 5 | 6 | for (const value of Object.values(environmentVariables)) { 7 | if (typeof value !== 'string') { 8 | throw new TypeError('The ’environmentVariables’ configuration must be an object containing string values.'); 9 | } 10 | } 11 | 12 | return environmentVariables; 13 | } 14 | -------------------------------------------------------------------------------- /test/shared-workers/cannot-publish-before-available/snapshots/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test/shared-workers/cannot-publish-before-available/test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## shared worker plugins work 8 | 9 | > Snapshot 1 10 | 11 | [ 12 | { 13 | file: 'test.js', 14 | title: 'cannot publish before ready', 15 | }, 16 | ] 17 | -------------------------------------------------------------------------------- /test-tap/fixture/serial.cjs: -------------------------------------------------------------------------------- 1 | const delay = require('delay'); 2 | 3 | const test = require('../../entrypoints/main.cjs'); 4 | 5 | const tests = []; 6 | 7 | test('first', async t => { 8 | await delay(300); 9 | tests.push('first'); 10 | t.pass(); 11 | }); 12 | 13 | test('second', async t => { 14 | await delay(100); 15 | tests.push('second'); 16 | t.pass(); 17 | }); 18 | 19 | test('test', t => { 20 | t.deepEqual(tests, ['first', 'second']); 21 | }); 22 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-sourcemaps/build/test.cjs.map: -------------------------------------------------------------------------------- 1 | {"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"} 2 | -------------------------------------------------------------------------------- /test/hook-restrictions/snapshots/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test/hook-restrictions/test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## snapshots cannot be used in hooks 8 | 9 | > error message 10 | 11 | '`t.snapshot()` can only be used in tests' 12 | 13 | ## `t.try()` cannot be used in hooks 14 | 15 | > error message 16 | 17 | '`t.try()` can only be used in tests' 18 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/skipping-snapshot-update/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | test('foo', t => { 4 | if (process.env.TEMPLATE) { 5 | t.snapshot({foo: 'one'}); 6 | t.snapshot({foo: 'two'}); 7 | } else { 8 | t.snapshot.skip({one: 'something new'}); 9 | t.snapshot({two: 'something new'}); 10 | } 11 | }); 12 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/skipping-test-update/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | (process.env.TEMPLATE ? test : test.skip)('foo', t => { 4 | t.snapshot(process.env.TEMPLATE ? {foo: 'one'} : ['something new']); 5 | }); 6 | 7 | test('bar', t => { 8 | t.snapshot(process.env.TEMPLATE ? {bar: 'one'} : ['something new']); 9 | }); 10 | -------------------------------------------------------------------------------- /test-tap/helper/replay-report.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import fs from 'node:fs'; 3 | 4 | import delay from 'delay'; 5 | 6 | import TTYStream from './tty-stream.js'; 7 | 8 | const lines = fs.readFileSync(process.argv[2], 'utf8').split(TTYStream.SEPARATOR.toString('utf8')); 9 | 10 | (async () => { 11 | while (lines.length > 0) { 12 | process.stdout.write(lines.shift()); 13 | // eslint-disable-next-line no-await-in-loop 14 | await delay(); 15 | } 16 | })(); 17 | -------------------------------------------------------------------------------- /test/test-timeouts/snapshots/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test/test-timeouts/test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## timeout messages must be strings 8 | 9 | > error message 10 | 11 | 'The assertion message must be a string' 12 | 13 | > formatted values 14 | 15 | [ 16 | { 17 | formatted: '20', 18 | label: 'Called with:', 19 | }, 20 | ] 21 | -------------------------------------------------------------------------------- /test-tap/fixture/hooks-skipped.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../entrypoints/main.cjs'); 2 | 3 | test.before(() => { 4 | throw new Error('should not run'); 5 | }); 6 | 7 | test.after(() => { 8 | throw new Error('should not run'); 9 | }); 10 | 11 | test.beforeEach(() => { 12 | throw new Error('should not run'); 13 | }); 14 | 15 | test.afterEach(() => { 16 | throw new Error('should not run'); 17 | }); 18 | 19 | test.skip('some skipped test', t => { 20 | t.fail(); 21 | }); 22 | -------------------------------------------------------------------------------- /test-tap/fixture/with-dependencies/test-uncaught-exception.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../entrypoints/main.cjs'); 2 | 3 | require('./dep-1.js'); // eslint-disable-line import/no-unassigned-import 4 | require('./dep-2.js'); // eslint-disable-line import/no-unassigned-import 5 | require('./dep-3.custom'); // eslint-disable-line import/no-unassigned-import 6 | 7 | test('hey ho', t => { 8 | t.pass(); 9 | }); 10 | 11 | setImmediate(() => { 12 | throw new Error('oops'); 13 | }); 14 | -------------------------------------------------------------------------------- /test-tap/reporters/default.timeoutinsinglefile.v12.log: -------------------------------------------------------------------------------- 1 | 2 | ---tty-stream-chunk-separator 3 | ✔ passes 4 | ---tty-stream-chunk-separator 5 | ✔ passes two 6 | ---tty-stream-chunk-separator 7 |  8 | ✖ Timed out while running tests 9 | 10 | 2 tests were pending in a.cjs 11 | 12 | ◌ slow 13 | ◌ slow two 14 | 15 | ---tty-stream-chunk-separator 16 | ─ 17 | 18 | 2 tests passed 19 | ---tty-stream-chunk-separator 20 | -------------------------------------------------------------------------------- /test-tap/reporters/default.timeoutinsinglefile.v14.log: -------------------------------------------------------------------------------- 1 | 2 | ---tty-stream-chunk-separator 3 | ✔ passes 4 | ---tty-stream-chunk-separator 5 | ✔ passes two 6 | ---tty-stream-chunk-separator 7 |  8 | ✖ Timed out while running tests 9 | 10 | 2 tests were pending in a.cjs 11 | 12 | ◌ slow 13 | ◌ slow two 14 | 15 | ---tty-stream-chunk-separator 16 | ─ 17 | 18 | 2 tests passed 19 | ---tty-stream-chunk-separator 20 | -------------------------------------------------------------------------------- /test-tap/reporters/default.timeoutinsinglefile.v16.log: -------------------------------------------------------------------------------- 1 | 2 | ---tty-stream-chunk-separator 3 | ✔ passes 4 | ---tty-stream-chunk-separator 5 | ✔ passes two 6 | ---tty-stream-chunk-separator 7 |  8 | ✖ Timed out while running tests 9 | 10 | 2 tests were pending in a.cjs 11 | 12 | ◌ slow 13 | ◌ slow two 14 | 15 | ---tty-stream-chunk-separator 16 | ─ 17 | 18 | 2 tests passed 19 | ---tty-stream-chunk-separator 20 | -------------------------------------------------------------------------------- /test-d/plugin.ts: -------------------------------------------------------------------------------- 1 | import {expectType} from 'tsd'; 2 | 3 | import * as plugin from '../plugin'; // eslint-disable-line import/extensions 4 | 5 | expectType(plugin.registerSharedWorker({filename: '', supportedProtocols: ['ava-4']})); 6 | 7 | const factory: plugin.SharedWorker.Factory = ({negotiateProtocol}) => { // eslint-disable-line @typescript-eslint/no-unused-vars 8 | expectType(negotiateProtocol(['ava-4'])); 9 | }; 10 | -------------------------------------------------------------------------------- /test-tap/reporters/tap.failfast2.v12.log: -------------------------------------------------------------------------------- 1 | TAP version 13 2 | ---tty-stream-chunk-separator 3 | not ok 1 - a › fails 4 | --- 5 | name: AssertionError 6 | message: Test failed via `t.fail()` 7 | assertion: fail 8 | at: 'test-tap/fixture/report/failfast2/a.cjs:3:22' 9 | ... 10 | ---tty-stream-chunk-separator 11 | # 1 test remaining in a.cjs 12 | ---tty-stream-chunk-separator 13 | 14 | 1..2 15 | # tests 2 16 | # pass 0 17 | # fail 2 18 | 19 | ---tty-stream-chunk-separator 20 | -------------------------------------------------------------------------------- /test-tap/reporters/tap.failfast2.v14.log: -------------------------------------------------------------------------------- 1 | TAP version 13 2 | ---tty-stream-chunk-separator 3 | not ok 1 - a › fails 4 | --- 5 | name: AssertionError 6 | message: Test failed via `t.fail()` 7 | assertion: fail 8 | at: 'test-tap/fixture/report/failfast2/a.cjs:3:22' 9 | ... 10 | ---tty-stream-chunk-separator 11 | # 1 test remaining in a.cjs 12 | ---tty-stream-chunk-separator 13 | 14 | 1..2 15 | # tests 2 16 | # pass 0 17 | # fail 2 18 | 19 | ---tty-stream-chunk-separator 20 | -------------------------------------------------------------------------------- /test-tap/reporters/tap.failfast2.v16.log: -------------------------------------------------------------------------------- 1 | TAP version 13 2 | ---tty-stream-chunk-separator 3 | not ok 1 - a › fails 4 | --- 5 | name: AssertionError 6 | message: Test failed via `t.fail()` 7 | assertion: fail 8 | at: 'test-tap/fixture/report/failfast2/a.cjs:3:22' 9 | ... 10 | ---tty-stream-chunk-separator 11 | # 1 test remaining in a.cjs 12 | ---tty-stream-chunk-separator 13 | 14 | 1..2 15 | # tests 2 16 | # pass 0 17 | # fail 2 18 | 19 | ---tty-stream-chunk-separator 20 | -------------------------------------------------------------------------------- /test/shared-workers/worker-protocol/fixtures/test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | import declare from './_declare.js'; 4 | import plugin from './_plugin.js'; 5 | 6 | declare(import.meta.url); 7 | 8 | test('test workers are released when they exit', async t => { 9 | for await (const message of plugin.subscribe()) { 10 | if ('cleanup' in message.data) { 11 | t.is(message.data.cleanup, new URL('other.test.js', import.meta.url).toString()); 12 | return; 13 | } 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/invalid-snapfile/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | test('foo', t => { 4 | t.snapshot.skip({foo: 'one'}); 5 | t.snapshot({foo: 'two'}); 6 | }); 7 | 8 | test('bar', t => { 9 | t.snapshot({bar: 'one'}); 10 | t.snapshot.skip({bar: 'two'}); 11 | }); 12 | 13 | test.skip('baz', t => { 14 | t.snapshot({baz: 'one'}); 15 | }); 16 | -------------------------------------------------------------------------------- /test-d/like.ts: -------------------------------------------------------------------------------- 1 | import test from '..'; 2 | 3 | test('like', t => { 4 | t.like({ 5 | map: new Map([['foo', 'bar']]), 6 | nested: { 7 | baz: 'thud', 8 | qux: 'quux', 9 | }, 10 | }, { 11 | map: new Map([['foo', 'bar']]), 12 | nested: { 13 | baz: 'thud', 14 | }, 15 | }); 16 | 17 | type Foo = { 18 | foo?: 'foo'; 19 | bar?: 'bar'; 20 | }; 21 | 22 | const foo: Foo = {bar: 'bar'}; 23 | const {foo: _, ...expected} = foo; 24 | t.like({bar: 'bar'}, expected); 25 | }); 26 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/watcher-rerun-unlink/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('../../../../entrypoints/main.cjs'); 2 | 3 | if (process.env.TEMPLATE) { 4 | test('test title', t => { 5 | t.snapshot({foo: 'bar'}); 6 | t.snapshot({answer: 42}); 7 | t.pass(); 8 | }); 9 | 10 | test('another test', t => { 11 | t.snapshot(new Map()); 12 | }); 13 | } else { 14 | test('test title', t => { 15 | t.pass(); 16 | }); 17 | 18 | test('another test', t => { 19 | t.pass(); 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /test/README.md: -------------------------------------------------------------------------------- 1 | # Self-hosted tests 2 | 3 | This directory contains tests that are run using a stable version of AVA. You can run them using `npx test-ava`. 4 | 5 | Tests should be placed in their own directory, grouped by area of responsibility. Use the `exec` helper to launch the AVA version that is in the repository to run tests. Place these in a nested `fixtures` directory. Add a relative dependency in `package.json`. You can then import from `ava`. 6 | 7 | Prefer snapshotting the test results. 8 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/commit-skip/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | test('commit a skipped snapshot', async t => { 4 | t.snapshot(1); 5 | 6 | const firstTry = await t.try(t => { 7 | if (process.env.TEMPLATE) { 8 | t.snapshot('before'); 9 | } else { 10 | t.snapshot.skip('after'); 11 | } 12 | }); 13 | 14 | firstTry.commit(); 15 | }); 16 | -------------------------------------------------------------------------------- /examples/typescript-basic/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ava-typescript-basic", 3 | "description": "Basic example for AVA with TypeScript", 4 | "scripts": { 5 | "test": "ava" 6 | }, 7 | "devDependencies": { 8 | "@ava/typescript": "^2.0.0", 9 | "@sindresorhus/tsconfig": "^1.0.2", 10 | "ava": "^3.15.0", 11 | "typescript": "^4.3.4" 12 | }, 13 | "ava": { 14 | "typescript": { 15 | "compile": "tsc", 16 | "rewritePaths": { 17 | "source/": "build/" 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/shared-workers/lifecycle/fixtures/available.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | import * as plugin from 'ava/plugin'; 3 | 4 | const worker = plugin.registerSharedWorker({ 5 | filename: new URL('_worker.js', import.meta.url), 6 | supportedProtocols: ['ava-4'], 7 | }); 8 | 9 | const availableImmediately = worker.currentlyAvailable; 10 | 11 | test('the shared worker becomes available before tests start', t => { 12 | t.false(availableImmediately); 13 | t.true(worker.currentlyAvailable); 14 | }); 15 | -------------------------------------------------------------------------------- /test-tap/fixture/report/timeoutinmultiplefiles/b.cjs: -------------------------------------------------------------------------------- 1 | const delay = require('delay'); 2 | 3 | const test = require('../../../../entrypoints/main.cjs'); 4 | 5 | test('b passes', t => t.pass()); 6 | 7 | test('b slow', async t => { 8 | await delay(15_000); 9 | t.pass(); 10 | }); 11 | test('b slow two', async t => { 12 | await delay(15_000); 13 | t.pass(); 14 | }); 15 | test('b slow three', async t => { 16 | await delay(15_000); 17 | t.pass(); 18 | }); 19 | 20 | test('b passes two', t => t.pass()); 21 | -------------------------------------------------------------------------------- /test/shared-workers/restricted-to-worker-threads/test.js: -------------------------------------------------------------------------------- 1 | import test from '@ava/test'; 2 | 3 | import {fixture} from '../../helpers/exec.js'; 4 | 5 | test('can only be used when worker threads are enabled', async t => { 6 | let result = await t.throwsAsync(fixture(['--no-worker-threads'])); 7 | t.true(result.failed); 8 | t.true(result.stdout.includes('Error: Shared workers can be used only when worker threads are enabled')); 9 | result = await fixture([]); 10 | t.false(result.failed); 11 | }); 12 | -------------------------------------------------------------------------------- /examples/typescript-context/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ava-typescript-context", 3 | "description": "TypeScript example for typing t.context", 4 | "scripts": { 5 | "test": "ava" 6 | }, 7 | "devDependencies": { 8 | "@ava/typescript": "^2.0.0", 9 | "@sindresorhus/tsconfig": "^1.0.2", 10 | "ava": "^3.15.0", 11 | "typescript": "^4.3.4" 12 | }, 13 | "ava": { 14 | "typescript": { 15 | "compile": "tsc", 16 | "rewritePaths": { 17 | "source/": "build/" 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test-tap/fixture/report/timeoutwithmatch/a.cjs: -------------------------------------------------------------------------------- 1 | const delay = require('delay'); 2 | 3 | const test = require('../../../../entrypoints/main.cjs'); 4 | 5 | test('passes needle', t => t.pass()); 6 | 7 | test('slow needle', async t => { 8 | await delay(15_000); 9 | t.pass(); 10 | }); 11 | test('slow two', async t => { 12 | await delay(15_000); 13 | t.pass(); 14 | }); 15 | test('slow three needle', async t => { 16 | await delay(15_000); 17 | t.pass(); 18 | }); 19 | 20 | test('passes two', t => t.pass()); 21 | -------------------------------------------------------------------------------- /test/snapshot-tests/snapshots/corrupt.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test/snapshot-tests/corrupt.js` 2 | 3 | The actual snapshot is saved in `corrupt.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## snapshot corruption is reported to the console 8 | 9 | > failed tests 10 | 11 | [ 12 | { 13 | file: 'test.js', 14 | title: 'a snapshot', 15 | }, 16 | { 17 | file: 'test.js', 18 | title: 'a snapshot with a message', 19 | }, 20 | ] 21 | -------------------------------------------------------------------------------- /test/multiple-implementations/test.js: -------------------------------------------------------------------------------- 1 | import test from '@ava/test'; 2 | 3 | import {fixture} from '../helpers/exec.js'; 4 | 5 | test('test()', async t => { 6 | const result = await t.throwsAsync(fixture(['test.js'])); 7 | t.regex(result.stdout, /AVA 4 no longer supports multiple implementations/); 8 | }); 9 | 10 | test('t.try()', async t => { 11 | const result = await t.throwsAsync(fixture(['try.js'])); 12 | t.regex(result.stdout, /AVA 4 no longer supports t\.try\(\) with multiple implementations/); 13 | }); 14 | -------------------------------------------------------------------------------- /docs/recipes/babel.md: -------------------------------------------------------------------------------- 1 | # Configuring Babel with AVA 3 2 | 3 | Translations: [Français](https://github.com/avajs/ava-docs/blob/master/fr_FR/docs/recipes/babel.md) 4 | 5 | **This is no longer available in AVA 4.** 6 | 7 | You can enable Babel support by installing `@ava/babel`, and then in AVA's configuration setting `babel` to `true`: 8 | 9 | **`package.json`:** 10 | 11 | ```json 12 | { 13 | "ava": { 14 | "babel": true 15 | } 16 | } 17 | ``` 18 | 19 | Find out more in [`@ava/babel`](https://github.com/avajs/babel). 20 | -------------------------------------------------------------------------------- /lib/node-arguments.js: -------------------------------------------------------------------------------- 1 | import process from 'node:process'; 2 | 3 | import arrgv from 'arrgv'; 4 | 5 | export default function normalizeNodeArguments(fromConf = [], fromArgv = '') { 6 | let parsedArgv = []; 7 | if (fromArgv !== '') { 8 | try { 9 | parsedArgv = arrgv(fromArgv); 10 | } catch { 11 | throw new Error('Could not parse `--node-arguments` value. Make sure all strings are closed and backslashes are used correctly.'); 12 | } 13 | } 14 | 15 | return [...process.execArgv, ...fromConf, ...parsedArgv]; 16 | } 17 | -------------------------------------------------------------------------------- /test/extensions/snapshots/test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test/extensions/test.js` 2 | 3 | The actual snapshot is saved in `test.js.snap`. 4 | 5 | Generated by [AVA](https://avajs.dev). 6 | 7 | ## errors if top-level extensions include duplicates 8 | 9 | > fails with message 10 | 11 | 'Unexpected duplicate extensions in options: ’js’, ’jsx’.' 12 | 13 | ## errors if top-level and typescript extensions include duplicates 14 | 15 | > fails with message 16 | 17 | 'Unexpected duplicate extensions in options: ’tsx’.' 18 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-sourcemaps/build/test/test.cjs.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "test.cjs", 4 | "sourceRoot": "", 5 | "sources": [ 6 | "../../src/test/test.ts" 7 | ], 8 | "names": [], 9 | "mappings": "AAAA,OAAO,IAAI,MAAM,mBAAmB,CAAC;AAErC,IAAI,CAAC,YAAY,EAAE,CAAC;IACnB,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,cAAc,EAAE,CAAC;IACrB,CAAC,CAAC,QAAQ,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC" 10 | } 11 | -------------------------------------------------------------------------------- /lib/reporters/format-serialized-error.js: -------------------------------------------------------------------------------- 1 | export default function formatSerializedError(error) { 2 | const printMessage = error.values.length === 0 3 | ? Boolean(error.message) 4 | : !error.values[0].label.startsWith(error.message); 5 | 6 | if (error.values.length === 0) { 7 | return {formatted: null, printMessage}; 8 | } 9 | 10 | let formatted = ''; 11 | for (const value of error.values) { 12 | formatted += `${value.label}\n\n${value.formatted}\n\n`; 13 | } 14 | 15 | return {formatted: formatted.trim(), printMessage}; 16 | } 17 | -------------------------------------------------------------------------------- /test-d/implementation-result.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */ 2 | import test from '..'; 3 | 4 | test('return a promise-like', t => ({ 5 | then(resolve) { 6 | resolve?.(); // eslint-disable-line @typescript-eslint/no-floating-promises 7 | }, 8 | })); 9 | 10 | test('return a subscribable', t => ({ 11 | subscribe({complete}) { 12 | complete(); 13 | }, 14 | })); 15 | 16 | test.after('return anything else', t => ({ 17 | foo: 'bar', 18 | subscribe() {}, 19 | then() {}, 20 | })); 21 | -------------------------------------------------------------------------------- /test-tap/reporters/improper-usage-messages.js: -------------------------------------------------------------------------------- 1 | import {test} from 'tap'; 2 | 3 | import improperUsageMessages from '../../lib/reporters/improper-usage-messages.js'; 4 | 5 | test('results when nothing is applicable', t => { 6 | const error = { 7 | assertion: 'assertion', 8 | improperUsage: { 9 | name: 'VersionMismatchError', 10 | snapPath: 'path', 11 | snapVersion: 2, 12 | expectedVersion: 1, 13 | }, 14 | }; 15 | 16 | const actualOutput = improperUsageMessages(error); 17 | 18 | t.equal(actualOutput, null); 19 | t.end(); 20 | }); 21 | -------------------------------------------------------------------------------- /test-tap/integration/stack-traces.js: -------------------------------------------------------------------------------- 1 | import {test} from 'tap'; 2 | 3 | import {execCli} from '../helper/cli.js'; 4 | 5 | test('`AssertionError` should capture infinity stack trace', t => { 6 | execCli('infinity-stack-trace.cjs', (error, stdout) => { 7 | t.ok(error); 8 | t.match(stdout, /c \(.*infinity-stack-trace\.cjs:6:20\)/); 9 | t.match(stdout, /b \(.*infinity-stack-trace\.cjs:7:18\)/); 10 | t.match(stdout, /a \(.*infinity-stack-trace\.cjs:8:18\)/); 11 | t.match(stdout, /.+?infinity-stack-trace\.cjs:10:2/); 12 | t.end(); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /test/snapshot-workflow/fixtures/reorder/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | if (process.env.TEMPLATE) { 4 | test('first test', t => { 5 | t.snapshot({foo: 'bar'}); 6 | }); 7 | 8 | test('second test', t => { 9 | t.snapshot({bar: 'baz'}); 10 | }); 11 | } else { 12 | test('second test', t => { 13 | t.snapshot({bar: 'baz'}); 14 | }); 15 | 16 | test('first test', t => { 17 | t.snapshot({foo: 'bar'}); 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /test/extensions/test.js: -------------------------------------------------------------------------------- 1 | import test from '@ava/test'; 2 | 3 | import {cleanOutput, cwd, fixture} from '../helpers/exec.js'; 4 | 5 | for (const [where, which] of [ 6 | ['top-level', 'top-level-duplicates'], 7 | ['top-level and typescript', 'shared-duplicates'], 8 | ]) { 9 | test(`errors if ${where} extensions include duplicates`, async t => { 10 | const options = { 11 | cwd: cwd(which), 12 | }; 13 | 14 | const result = await t.throwsAsync(fixture([], options)); 15 | 16 | t.snapshot(cleanOutput(result.stderr), 'fails with message'); 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /test-tap/fixture/snapshots/test-sourcemaps/build/feature/__tests__/test.cjs.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "test.cjs", 4 | "sourceRoot": "", 5 | "sources": [ 6 | "../../../src/feature/__tests__/test.ts" 7 | ], 8 | "names": [], 9 | "mappings": "AAAA,OAAO,IAAI,MAAM,sBAAsB,CAAA;AAEvC,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC3B,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,sBAAsB,EAAE,CAAC;IAC7B,CAAC,CAAC,QAAQ,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC" 10 | } 11 | -------------------------------------------------------------------------------- /test/cjs-default/fixtures/test.cjs: -------------------------------------------------------------------------------- 1 | const test = require('ava'); 2 | 3 | test.default('callable', t => { 4 | t.pass(); 5 | }); 6 | 7 | test('no recursion', t => { 8 | t.throws(() => test.default.default, { 9 | name: 'TypeError', 10 | }); 11 | }); 12 | 13 | test('not enumerable', t => { 14 | t.false(Object.keys(test).includes('default')); 15 | }); 16 | 17 | test('main export equals the ESM export', async t => { 18 | const {default: exported} = await import('ava'); // eslint-disable-line node/no-unsupported-features/es-syntax 19 | t.is(test, exported); 20 | }); 21 | -------------------------------------------------------------------------------- /test/shared-workers/worker-execution-crash/fixtures/test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | import plugin from './_plugin.js'; 4 | 5 | test('shared workers crash', async t => { 6 | const replies = plugin.publish('🙈').replies(); 7 | await t.throwsAsync(replies.next(), {message: 'The shared worker is no longer available'}); 8 | await t.throwsAsync(plugin.subscribe().next(), {message: 'The shared worker is no longer available'}); 9 | t.false(plugin.currentlyAvailable); 10 | t.throws(() => plugin.publish(), {message: 'The shared worker is no longer available'}); 11 | }); 12 | -------------------------------------------------------------------------------- /test/snapshot-tests/large.js: -------------------------------------------------------------------------------- 1 | import test from '@ava/test'; 2 | 3 | import {cwd, fixture} from '../helpers/exec.js'; 4 | import {withTemporaryFixture} from '../helpers/with-temporary-fixture.js'; 5 | 6 | // Reproduction for https://github.com/avajs/ava/issues/2932. 7 | test('can encode and decode large snapshots', async t => { 8 | await withTemporaryFixture(cwd('large'), async cwd => { 9 | const env = { 10 | AVA_FORCE_CI: 'not-ci', 11 | }; 12 | await fixture(['--update-snapshots'], {cwd, env}); 13 | await t.notThrowsAsync(fixture([], {cwd, env})); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /test/snapshot-workflow/removing-test.js: -------------------------------------------------------------------------------- 1 | import test from '@ava/test'; 2 | 3 | import {cwd} from '../helpers/exec.js'; 4 | 5 | import {beforeAndAfter} from './helpers/macros.js'; 6 | 7 | test.serial( 8 | 'Removing a test retains its data', 9 | beforeAndAfter, 10 | { 11 | cwd: cwd('removing-test'), 12 | expectChanged: false, 13 | }, 14 | ); 15 | 16 | test.serial( 17 | 'With --update-snapshots, removing a test removes its block', 18 | beforeAndAfter, 19 | { 20 | cwd: cwd('removing-test'), 21 | cli: ['--update-snapshots'], 22 | expectChanged: true, 23 | }, 24 | ); 25 | -------------------------------------------------------------------------------- /media/screenshot-fixtures/tap-reporter.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | 3 | test('a', t => { 4 | t.pass(); 5 | }); 6 | 7 | test('b', t => { 8 | t.pass(); 9 | }); 10 | 11 | test('c', t => { 12 | t.pass(); 13 | }); 14 | 15 | test('d', t => { 16 | t.pass(); 17 | }); 18 | 19 | test('e', t => { 20 | t.pass(); 21 | }); 22 | 23 | test('f', t => { 24 | t.pass(); 25 | }); 26 | 27 | test('g', t => { 28 | t.pass(); 29 | }); 30 | 31 | test('h', t => { 32 | t.pass(); 33 | }); 34 | 35 | test('i', t => { 36 | t.pass(); 37 | }); 38 | 39 | test('j', t => { 40 | t.pass(); 41 | }); 42 | 43 | -------------------------------------------------------------------------------- /test/snapshot-removal/fixtures/removal/test.js: -------------------------------------------------------------------------------- 1 | const test = require(process.env.TEST_AVA_IMPORT_FROM); // This fixture is copied to a temporary directory, so require AVA through its configured path. 2 | 3 | if (process.env.TEMPLATE) { 4 | test('some snapshots', t => { 5 | t.snapshot('foo'); 6 | t.snapshot('bar'); 7 | t.pass(); 8 | }); 9 | 10 | test('another snapshot', t => { 11 | t.snapshot('baz'); 12 | t.pass(); 13 | }); 14 | } else { 15 | test('some snapshots', t => { 16 | t.pass(); 17 | }); 18 | 19 | test('another snapshot', t => { 20 | t.pass(); 21 | }); 22 | } 23 | -------------------------------------------------------------------------------- /test/snapshot-workflow/reorder.js: -------------------------------------------------------------------------------- 1 | import test from '@ava/test'; 2 | 3 | import {cwd} from '../helpers/exec.js'; 4 | 5 | import {beforeAndAfter} from './helpers/macros.js'; 6 | 7 | test.serial( 8 | 'Reordering tests does not change the .snap or .md', 9 | beforeAndAfter, 10 | { 11 | cwd: cwd('reorder'), 12 | expectChanged: false, 13 | }, 14 | ); 15 | 16 | test.serial( 17 | 'With --update-snapshots, reordering tests reorders the .snap and .md', 18 | beforeAndAfter, 19 | { 20 | cwd: cwd('reorder'), 21 | cli: ['--update-snapshots'], 22 | expectChanged: true, 23 | }, 24 | ); 25 | -------------------------------------------------------------------------------- /test-d/snapshot.ts: -------------------------------------------------------------------------------- 1 | import {expectError} from 'tsd'; 2 | 3 | import test from '..'; 4 | 5 | test('snapshot', t => { 6 | t.snapshot({foo: 'bar'}); 7 | t.snapshot(null, 'a snapshot with a message'); 8 | expectError(t.snapshot('hello world', null)); // eslint-disable-line @typescript-eslint/no-confusing-void-expression 9 | }); 10 | 11 | test('snapshot.skip', t => { 12 | t.snapshot.skip({foo: 'bar'}); 13 | t.snapshot.skip(null, 'a snapshot with a message'); 14 | expectError(t.snapshot.skip('hello world', null)); // eslint-disable-line @typescript-eslint/no-confusing-void-expression 15 | }); 16 | --------------------------------------------------------------------------------