Node.js test runner that lets you develop with confidence 🚀

Overview

AVA logo

AVA is a test runner for Node.js with a concise API, detailed error output, embrace of new language features and process isolation that lets you develop with confidence 🚀

Follow the AVA Twitter account for updates.

Read our contributing guide if you're looking to contribute (issues / PRs / etc).

Translations: Español, Français, Italiano, 日本語, 한국어, Português, Русский, 简体中文

Why AVA?

Usage

To install and set up AVA, run:

npm init ava

Your package.json will then look like this (exact version notwithstanding):

{
	"name": "awesome-package",
	"scripts": {
		"test": "ava"
	},
	"devDependencies": {
		"ava": "^1.0.0"
	}
}

Or if you prefer using Yarn:

yarn add ava --dev

Alternatively you can install ava manually:

npm install --save-dev ava

Don't forget to configure the test script in your package.json as per above.

Create your test file

Create a file named test.js in the project root directory:

const test = require('ava');

test('foo', t => {
	t.pass();
});

test('bar', async t => {
	const bar = Promise.resolve('bar');
	t.is(await bar, 'bar');
});

Running your tests

npm test

Or with npx:

npx ava

Run with the --watch flag to enable AVA's watch mode:

npx ava --watch

Supported Node.js versions

AVA supports the latest release of any major version that is supported by Node.js itself. Read more in our support statement.

Highlights

Magic assert

AVA adds code excerpts and clean diffs for actual and expected values. If values in the assertion are objects or arrays, only a diff is displayed, to remove the noise and focus on the problem. The diff is syntax-highlighted too! If you are comparing strings, both single and multi line, AVA displays a different kind of output, highlighting the added or missing characters.

Clean stack traces

AVA automatically removes unrelated lines in stack traces, allowing you to find the source of an error much faster, as seen above.

Parallel runs in CI

AVA automatically detects whether your CI environment supports parallel builds. Each build will run a subset of all test files, while still making sure all tests get executed. See the ci-parallel-vars package for a list of supported CI environments.

Documentation

Please see the files in the docs directory:

Common pitfalls

We have a growing list of common pitfalls you may experience while using AVA. If you encounter any issues you think are common, comment in this issue.

Recipes

FAQ

Why not mocha, tape, tap?

Mocha requires you to use implicit globals like describe and it with the default interface (which most people use). It's not very opinionated and executes tests serially without process isolation, making it slow.

Tape and tap are pretty good. AVA is highly inspired by their syntax. They too execute tests serially. Their default TAP output isn't very user-friendly though so you always end up using an external tap reporter.

In contrast AVA is highly opinionated and runs tests concurrently, with a separate process for each test file. Its default reporter is easy on the eyes and yet AVA still supports TAP output through a CLI flag.

How is the name written and pronounced?

AVA, not Ava or ava. Pronounced /ˈeɪvə/: Ay (face, made) V (vie, have) A (comma, ago)

What is the header background?

It's the Andromeda galaxy.

What is the difference between concurrency and parallelism?

Concurrency is not parallelism. It enables parallelism.

Support

Related

Links

Team

Mark Wubben Sindre Sorhus
Mark Wubben Sindre Sorhus
Former
Comments
  • Allow tests files to have any extension (i.e. `.jsx`, `.ts`)

    Allow tests files to have any extension (i.e. `.jsx`, `.ts`)

    With the latest release(0.13) and the ability to support jsx; I would like the ability to write my test that contains jsx with a jsx extension. However ava is filtering only for files with .js extensions. I'm a little confused as to why ava allows for a glob pattern in the cli but then only filters down to .js files.

    I can make a PR if this is something worthwhile to the maintainers.


    See conclusion here: https://github.com/avajs/ava/issues/631#issuecomment-248659780

    enhancement help wanted 
    opened by dustinsanders 84
  • Support to Run TypeScript test file(.ts) directly without Precompiling(tsc)

    Support to Run TypeScript test file(.ts) directly without Precompiling(tsc)

    Issuehunt badges

    Description

    AVA now support ES6 by using Babel, run directly without any precompiling, this is very convenience. But for TypeScript, AVA has to precompile ts files by run tsc.

    I use TypeScript in my project wechaty, run TS code directly by ts-node like this: ts-node demo.ts. This is a convenience way for developing.

    If we can run TypeScript file directly by AVA, just like ava test.ts, that will be wonderful.

    About this topic, there has already an issue #631 on it. I saw @sindresorhus agree that use TypeScript without precompiling is a better way.

    @niieani You can already use TypeScript by precompiling it. I know it's not optimal, but it's not like anyone has done a pull request fixing this. https://github.com/avajs/ava/issues/631#issuecomment-250368210

    I love AVA, because I'm a TAP fan, and AVA is based on TAP. So I tried to hack AVA to support TypeScript directly. After some study & work, I finished it finally, and in the past month, I was using it in my own project and it worked as my expected.

    I'll share my idea here, and send a Pull Request later. Hope we can support TypeScript without precompiling soon.

    ava-typescript

    About the Hack

    I added a --ext ts argument parameter to CLI, then pass ext to AVA API. If ext is ts then I use TypeScript Compiler to replace the Babel Compiler, because TypeScript is the superset of ES6/7.

    1. Add CLI Arg: --ext/-e

      In order to support TypeScript without precompiling, first, we need to add a CLI args to support that. I use the name --ext and the alias -e for this, like ava -e ts. Set the ext automatically is considered, but I think maybe it should be done later. If set ext automatically, then we can just run TS tests by ava test.ts

    2. Get Test Files from ava-files

      AVA use a submodule ava-files to get all test files list. It had to be modified to support the ext parameter. I use exts in the ava-files module and it is an Array type, that's for the future support of multiple file extensions.

    3. new API options: ext

      in API call, we get file extension name from options.ext, pass it to AvaFiles/CachingPrecompiler/Watcher.

    4. Add a Switcher between Babel with TypeScript

      AVA compile ES6 by Babel in CachingPrecompiler, so we could compile TypeScript here. If the file extension is set to ts, then CachingPrecompiler will use a new module extTs to compile the source.

    5. Introduce a new Module: extTs(lib/ext/ts.js)

      For ts file extension, the compiler module ext/ts.js will be loaded. In the furture, other extension could modulize their own compile code in different file in ext/ directory. i.e. ext/jsx.js for a new extJsx compiling module.

    6. Enable Run TypeScript in test-worker.js

      AVA use subprocess to run tests, the worker needs to register to TypeScript compiler.

    7. Add TypeScript dependence to package.json

    8. Make XO happy

    Test Source

    test.ts:

    import { test } from 'ava'
    
    test('AVA run TypeScript without tsc', t => {
      let i: number = 42
      t.is(i, <number>42, 'meaning of life')
    })
    

    Run:

    $ ava --ext ts test.ts
    
      ✔ AVA run TypeScript without tsc
    
      1 test passed [02:55:58]
    

    Yeah~

    Relevant Links

    • https://github.com/avajs/ava/issues/631#issuecomment-250067693

    There is a $142.00 open bounty on this issue. Add more on Issuehunt.

    enhancement help wanted scope:typescript :dollar: Funded on Issuehunt 
    opened by huan 75
  • Browser support

    Browser support

    Trying to get this working in the browser, and then later hihat for debugging/breakpoints/etc.

    After browserifying the demo in the readme, I get the following:

    Uncaught ReferenceError: setImmediate is not defined

    relevant line

    (weird cause I thought browserify would have shimmed this)

    enhancement low priority 
    opened by mattdesl 74
  • Added support for babel config under package.json/ava key (Fixes #448)

    Added support for babel config under package.json/ava key (Fixes #448)

    Here's an initial commit that allows package owners to specify a babel config for tests under the package.json/ava key.

    This conforms to the proposal in the following comment: https://github.com/sindresorhus/ava/issues/448#issuecomment-187694472

    I chose not to implement an extends key discussed in the thread because 1) it adds to the complexity, 2) I personally don't need it, and 3) how to solve that request is still somewhat unresolved. If needed, someone can add that later in another pull request.

    Let me know what you think. I'm a little unsure about whether my method for obtaining babelConfig is the best one.

    priority 
    opened by spudly 70
  • Transpile dependencies of the test file

    Transpile dependencies of the test file

    [email protected] works smoothly on a clean project, but fails to run on mine (tests broke when i've upgraded to from [email protected]):

    (function (exports, require, module, __filename, __dirname) { import {
                                                                  ^^^^^^
    SyntaxError: Unexpected reserved word
    

    I'm sure it's caused by some weird babel dependency, so it might be unrelated to ava. Last working state is 7d31571, if i try to upgrade to [email protected], tests are broken. I will investigate it tomorrow...

    enhancement help wanted good for beginner 
    opened by madbence 58
  • Only run tests with title matching expression

    Only run tests with title matching expression

    This is something that I would do with mocha. Here's the mocha help:

        -g, --grep <pattern>                    only run tests matching <pattern>
    

    I'm hoping to get something like that working.

    enhancement help wanted 
    opened by matthewbauer 56
  • Add `match` CLI option to run only matching tests

    Add `match` CLI option to run only matching tests

    Add a match option for running a specific set of tests with titles matching the given pattern. Leverages matcher internally, so ! and * is supported.

    ava --match='foo*' --match='!*bar' /test/*.js
    
    # shorthand
    ava -m='foo*' -m='!*bar' /test/*.js
    

    This would run all tests inside /test with a title starting with foo and not ending with bar.

    The match option can also be configured in the ava section of package.json.

    {
      "ava": {
        "match": [
          "foo*"
        ]
      }
    }
    

    Fixes #476

    opened by kasperlewau 51
  • Transpile in the main process

    Transpile in the main process

    Fixes #577

    Use the --precompile flag to apply transpilation to all file dependencies.

    The idea would be to drop --require babel-register and use the --precompile flag instead.

    It's pretty naive right now:

    • The shouldTranspile method just prevents transpiling node_modules, there's probably more logic that needs to be incorporated from Babels only and ignore options.
    • It caches using the hash of the transpilation output. This means the transpiler needs to run every time (and consequently babel-core gets loaded every time). We could speed things up more by trying to create a cache key from the input and the babel config, but that means resolving and parsing said config.
    • It can't handle dynamic requires, and using them will currently cause things to blow up (if the dynamic require needs transpilation). This could be improved by creating our own version of babel-register that does not load up babel-core except for dynamic requires (so you only pay the price when you actually use a dynamic require).
    • The test suite is very basic right now. Just a couple integration tests that verify it has an impact. This could be improved. Specifically, it probably needs some tests with dependencies in node_modules, and circular dependencies. It could also stand to have some true unit tests instead of just integration tests.

    I would like it if a few people gave it a try to see if it improved performance at all. Especially people with lots of test files that are using --require babel-register. (paging @kentcdodds).

    opened by jamestalmage 50
  • set child process debug port to an available port - fixes #342

    set child process debug port to an available port - fixes #342

    Continue #613

    More robust and maintainable approach was found. Just compute required data before main promise for all files. So, it is simple to add new function in to the existing promise chain. Yeah, I spend a lot of time trying to fix last failed test and decided to rework solution.

    This also doesn't handle the case where the user would do --debug-brk 213 instead of --debug-brk=213. https://github.com/avajs/ava/pull/613#discussion_r55246479

    This syntax is not supported because node supports only --debug=, but not --debug <port number>.

    develar-work:~ develar$ node --debug 12334 foo.js
    Debugger listening on port 5858
    module.js:442
        throw err;
        ^
    
    Error: Cannot find module '/Users/develar/12334'
    

    Can you add some tests? https://github.com/avajs/ava/pull/613#issuecomment-193336125

    Tests added. Initially as heavy-weight tests, but I got weird error Test files must be run with the AVA CLI if I run with nyc (passed without nyc). So, I decided to write unit tests.

    opened by develar 50
  • Retry flakey tests

    Retry flakey tests

    I've searched around for a bit and couldn't find anything about retrying flakey tests with AVA.

    I've been working on trying AVA for the generator-angular-fullstack Yeoman generator to see if it can speed up our tests. Right now in CircleCI our tests take about 15 minutes. This mainly includes running a few different configurations of the generator, and then some test command after that on the scaffolded code, namely linting, client tests, server tests, and E2E tests. The E2E tests can be quite flakey. Right now, we use Mocha, which has the ablility to add this.retry(2) to a test to retry it x times if it fails. Is there any plan to add something like this to AVA? If not, it would definitely be helpful to note some way of achieving this in the readme.

    Environment

    • ava --version: 0.15.2
    • node -v: v5.11.1
    • npm -v: 3.8.6
    enhancement question scope:assertions scope:test-interface 
    opened by Awk34 46
  • Forking for every test file is slow

    Forking for every test file is slow

    Update: Blocked by #696


    Seems like it is not quite good idea to spawn a fork for every test file. I have try'd fresh version of ava in got and tests run time get worse (not to mention, that iTunes is getting icky while tests).

    May be it is better to fork batched runners and/or have a concurrency flag?

    bug help wanted priority blocked 
    opened by floatdrop 44
  • De-register shared workers by filename

    De-register shared workers by filename

    This fixes the bug introduced in https://github.com/avajs/ava/pull/3149 that I briefly mentioned.

    Since we were assigning the launched shared worker to a single variable per test worker, we inadvertently assumed that a test worker would launch a maximum of 1 shared worker.

    I tested this patch with two of our internal codebases that heavily use shared workers and everything's working as expected now.

    Sorry for the previous buggy PR!

    opened by codetheweb 0
  • Invalid execArgv for worker threads causes a subsequent TypeError

    Invalid execArgv for worker threads causes a subsequent TypeError

    Hi,

    when launching ava with node --disable-proto=throw, it first produces this error:

    $ node --disable-proto=throw /usr/bin/ava
    
    file:///usr/share/nodejs/ava/lib/api.js:312
                                    for (const error_ of error.errors) {
                                                               ^
    
    TypeError: error.errors is not iterable
        at Api.run (file:///usr/share/nodejs/ava/lib/api.js:312:32)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async loadCli (file:///usr/share/nodejs/ava/lib/cli.js:489:21)
    
    Node.js v18.10.0
    

    With a little hook, we can see the real error (which has no errors property):

    AggregateError: 
        Error [ERR_WORKER_INVALID_EXEC_ARGV]: Initiated Worker with invalid execArgv flags: --disable-proto=throw
            at createWorker (file:///usr/share/nodejs/ava/lib/fork.js:24:12)
            at loadFork (file:///usr/share/nodejs/ava/lib/fork.js:84:39)
            at pMap.concurrency.concurrency (file:///usr/share/nodejs/ava/lib/api.js:289:20)
            at /usr/share/nodejs/p-map/index.js:57:28
        at next (/usr/share/nodejs/p-map/index.js:43:14)
        at /usr/share/nodejs/p-map/index.js:67:7
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    

    Ava version: 5.0.1

    bug help wanted 
    opened by guimard 6
  • Rewrite watcher

    Rewrite watcher

    This PR aims to rewrite the watcher implementation.

    Goals:

    • [x] Remove chokidar dependency, rely on fs.watch().
    • [x] This will require some additional logic for Linux (where we cannot watch recursively), but we don't need the full behavior that chokidar (or similar) provides
    • [x] Simplify logic
    • [x] Use static analysis for dependency tracking (https://github.com/vercel/nft)
    • [ ] Use self-hosted integration-style tests

    And as a follow-up goal, integrate with @ava/typescript so changes to say src/ are detected, and depending on whether it assumes a running tsc wait for build/ to be updated, or run immediately since it compiles prior to testing. But this is beyond AVA's current watch mode so can come later.

    opened by novemberborn 1
  • Snapshot report descriptions

    Snapshot report descriptions

    Description

    Firstly, thank you for creating and maintaining this brilliant tool. I leverage AVA's snapshot feature for comparing responses generated from parsers/lexers and it would be nice if I could feed descriptions of the snapshot test into reports to help better understand what is going in and what I am testing etc.

    Currently and AFAIK ava provides this functionality as "labels" when passing a string to the 2nd parameter in the .snapshot() method which will write to the quoted > output, eg:

    test('Some example test name', t => {
    
      const source = '<div>Hello World</div>';
    
      t.snapshot(source, 'Testing hello world');
    
    })
    

    The above example will output the following in a markdown file:

    # Snapshot report for `tests/eg.test.mjs`
    
    The actual snapshot is saved in `eg.mjs.snap`.
    
    Generated by [AVA](https://avajs.dev).
    
    ## Some example test name
    
    > Testing hello world
    
        '<div>Hello World</div>'
    

    While this suffices for a lot of cases, it does not allow for me (and maybe others) to have clear understanding on the purpose of the test and it becomes exceptionally difficult when reviewing snap reports. The current label and test title (even when multi-line) are not enough. Below is an example to better visualize what I mean.

    Notice the generate snapshot reports include a description following the test title:

    # Snapshot report for `tests/eg.test.mjs`
    
    The actual snapshot is saved in `eg.mjs.snap`.
    
    Generated by [AVA](https://avajs.dev).
    
    ## Some example test name
    
    An example of where the description should be output.
    
    > Testing hello world (snapshot 1)
    
        '<div>Hello World</div>'
    
    > Testing something else (snapshot 2)
    
        '<div>etc etc etc</div>'
    
    > Testing some else (snapshot 3)
    
        'xxx xxx xxx xxx'
    

    In the above, a description of the test is applied to the report. Passing markdown descriptions would be ideal but simple multiline strings would also suffice too.

    Why you can't use AVA for this

    There is no way to apply this (AFAIK) in reports.

    And maybe how you think AVA could handle this

    Personally, I haven't looked at the overall implementation approach one might employ to support such a capability and I am unsure of how ava is handling this aspect internally. Ideally and given the feature request pertains to snapshot assertions, exposing a description or describe to the t.snapshot method seems elegant and non-intrusive (ie: t.snapshot.describe()). IIRC I once read an issue where someone proposed something similar to be applied on the label parameter but that feels a tad extraneous.

    To better demonstrate, see the below example:

    _In this I am assuming the following type: t.snapshot.describe(...description: string[]) and also passing some markdown, grain of salt that aspect.

    
    test('Some example test name', t => {
    
     // ...
      
      t.snapshot.describe(
        'The snapshot report description can be provided here.',
        'The `describe` method similar to `t.log` could accept spread argument and',
        'maybe some low level **markdown** could be accepted if it does not interfere',
        'with the existing logic, for example:',
        '- List item 1',
        '- List item 2'
        'etc etc',
      )
     
      t.snapshot(source, 'The snapshot label');
      
    })
    

    The resulting report would be:

    # Snapshot report for `tests/eg.test.mjs`
    
    The actual snapshot is saved in `eg.mjs.snap`.
    
    Generated by [AVA](https://avajs.dev).
    
    ## Some example test name
    
    The snapshot report description can be provided here. The `describe` method similar to `t.log` could accept spread argument and maybe some low level **markdown** could be accepted if it does not interfere with the existing logic, for example:
    
    - List item 1
    - List item 2
    
    etc etc
    
    > The snapshot label
    
        'xxx xxx xxx xxx'
    
    question 
    opened by panoply 7
  • Project fails running: uncaught exception, exited with a non-zero exit code

    Project fails running: uncaught exception, exited with a non-zero exit code

    Please provide details about:

    • What you're trying to do Running the tutorial project from the README to test if my set up is OK.

    • Reproduction:

      • npm init ava
      • project.json like in the example
      • test.js like in the example
      • npm test
    • What happened

    npm WARN config global --global, --local are deprecated. Use --location=global instead.

    > test > ava

    Uncaught exception in test.js

    SyntaxError: Cannot use import statement outside a module × test.js exited with a non-zero exit code: 1 ─

    1 uncaught exception
    
    • What you expected to happen Tests run and succeed.

    This is really trivial. After setting ava in my own project and having the same error, I tried on a blanck projet, just following the example from the README.

    Running on Windows, with NodeJS 16.16.0 under a cmd console.

    Please share relevant sample code. Or better yet, provide a link to a minimal reproducible example.

    We'll also need your AVA configuration (in package.json or ava.config.* configuration files) and how you're invoking AVA. Share the installed AVA version (get it by running npx ava --version).

    scope:documentation needs triage 
    opened by Tyrben 2
  • Make line number selection work with TS and JSX syntax

    Make line number selection work with TS and JSX syntax

    Line number selection relies on parsing the test file. This only supports JS syntax:

    https://github.com/avajs/ava/blob/ac0d75d05d28e511b1b3654b09d11d602e360179/lib/worker/line-numbers.js#L9-L18

    Acorn has a plugin for JSX. If we want to use that we need to decide whether to add it to AVA's dependencies or how else we register it.

    There is no plugin for TypeScript. We'd have to work out a solution so that line number selection can work without using @ava/typescript. See https://github.com/avajs/ava/issues/3064 for making it work with @ava/typescript.

    enhancement help wanted scope:globbing scope:internals scope:typescript 
    opened by novemberborn 0
Releases(v5.1.0)
  • v5.1.0(Nov 14, 2022)

    What's Changed

    • Output logs for tests that remain pending when AVA exits by @kevo1ution in https://github.com/avajs/ava/pull/3125
    • Check for --config file extensions after they fail to load, allowing custom loaders by @panva in https://github.com/avajs/ava/pull/3135

    New Contributors

    • @kevo1ution made their first contribution in https://github.com/avajs/ava/pull/3125
    • @panva made their first contribution in https://github.com/avajs/ava/pull/3135

    Full Changelog: https://github.com/avajs/ava/compare/v5.0.1...v5.1.0

    Source code(tar.gz)
    Source code(zip)
  • v5.0.1(Sep 25, 2022)

    Despite the major version bump this is a relatively minor release. Node.js 12 is no longer supported. The type definitions are now distributed to be compatible with TypeScript 4.7 or newer.

    npm install --save-dev ava
    

    Breaking Changes

    • AVA now requires Node.js 14.19, 16.15 or 18. https://github.com/avajs/ava/pull/3043
    • Type definition distribution assumes at least TypeScript 4.7. https://github.com/avajs/ava/pull/3041
    • We're now exporting types rather than interfaces. https://github.com/avajs/ava/pull/3096

    Improvements

    • Detect process.exit() called from tests by @gibson042 in https://github.com/avajs/ava/pull/3080
    • Improve test result accessibility by @gibson042 in https://github.com/avajs/ava/pull/3082
    • Parse for line numbers with latest supported ECMA version by @novemberborn in https://github.com/avajs/ava/pull/3063
    • Work around os.cpus() returning an empty array on unsupported platforms by @catink123 in https://github.com/avajs/ava/pull/3095
    • Count timeouts separately from the timed out tests by @novemberborn in https://github.com/avajs/ava/pull/3099
    • Cap idle timeouts to the maximum possible value by @creestor in https://github.com/avajs/ava/pull/3100

    New Contributors

    • @Prinzhorn made their first contribution in https://github.com/avajs/ava/pull/3073
    • @catink123 made their first contribution in https://github.com/avajs/ava/pull/3095
    • @creestor made their first contribution in https://github.com/avajs/ava/pull/3100
    • @DavidVujic made their first contribution in https://github.com/avajs/ava/pull/3109

    Full Changelog: https://github.com/avajs/ava/compare/v4.3.3...v5.0.1

    Source code(tar.gz)
    Source code(zip)
  • v5.0.0(Sep 4, 2022)

    Despite the major version bump this is a relatively minor release. Node.js 12 is no longer supported. The type definitions are now distributed to be compatible with TypeScript 4.7 or newer.

    It's available as a pre-release under the next tag for the next few weeks:

    npm install --save-dev ava@next
    

    Breaking Changes

    • AVA now requires Node.js 14.19, 16.15 or 18. https://github.com/avajs/ava/pull/3043
    • Type definition distribution is no longer compatible with TypeScript versions before 4.7. https://github.com/avajs/ava/pull/3041
    • We're now exporting types rather than interfaces. https://github.com/avajs/ava/pull/3096

    Improvements

    • Detect process.exit() called from tests by @gibson042 in https://github.com/avajs/ava/pull/3080
    • Improve test result accessibility by @gibson042 in https://github.com/avajs/ava/pull/3082
    • Parse for line numbers with latest supported ECMA version by @novemberborn in https://github.com/avajs/ava/pull/3063
    • Work around os.cpus() returning an empty array on unsupported platforms by @catink123 in https://github.com/avajs/ava/pull/3095
    • Count timeouts separately from the timed out tests by @novemberborn in https://github.com/avajs/ava/pull/3099

    New Contributors

    • @Prinzhorn made their first contribution in https://github.com/avajs/ava/pull/3073
    • @catink123 made their first contribution in https://github.com/avajs/ava/pull/3095

    Full Changelog: https://github.com/avajs/ava/compare/v4.3.3...v5.0.0

    Source code(tar.gz)
    Source code(zip)
  • v4.3.3(Aug 25, 2022)

  • v4.3.1(Jul 10, 2022)

    What's Changed

    • When translating line numbers, check whether the source map entry has original values in https://github.com/avajs/ava/pull/3061
    • Report error when parsing for line number selection in https://github.com/avajs/ava/pull/3062

    New Contributors

    • @ericcornelissen made their first contribution in https://github.com/avajs/ava/pull/3048
    • @AlencarGabriel made their first contribution in https://github.com/avajs/ava/pull/3051
    • @binyamin made their first contribution in https://github.com/avajs/ava/pull/3028

    Full Changelog: https://github.com/avajs/ava/compare/v4.3.0...v4.3.1

    Source code(tar.gz)
    Source code(zip)
  • v4.3.0(Jun 2, 2022)

    What's Changed

    • We're now shipping type definitions compatible with TypeScript 4.7, by @RebeccaStevens in https://github.com/avajs/ava/pull/3024
    • throws and throwsAsync assertions now take a function to test error messages, by @il3ven in https://github.com/avajs/ava/pull/2995
    • Test failure summaries no longer duplicate t.log() messages, by @il3ven in https://github.com/avajs/ava/pull/3013
    • The number of timed-out tests is printed at the end of a run, by @il3ven in https://github.com/avajs/ava/pull/3021
    • We've documented how to load multiple instances of the same "shared" worker, by @codetheweb in https://github.com/avajs/ava/pull/3009
    • Links to translated documentation have been updated, by @forresst in https://github.com/avajs/ava/pull/3037
    • Node.js 17 has been removed from the test matrix, and Node.js 18 added in https://github.com/avajs/ava/pull/3039

    Full Changelog: https://github.com/avajs/ava/compare/v4.2.0...v4.3.0

    Source code(tar.gz)
    Source code(zip)
  • v4.2.0(Apr 10, 2022)

    What's Changed

    • Update Babel recipe for AVA 4 by @il3ven in https://github.com/avajs/ava/pull/3000
    • Document how GitHub Actions can be configured for parallel builds by @codetheweb in https://github.com/avajs/ava/pull/3007
    • Allow parallel builds to be disabled by @il3ven in https://github.com/avajs/ava/pull/3001
    • Improve typing of teardown methods by @novemberborn in https://github.com/avajs/ava/pull/3003

    New Contributors

    • @mefengl made their first contribution in https://github.com/avajs/ava/pull/2999
    • @il3ven made their first contribution in https://github.com/avajs/ava/pull/3000
    • @codetheweb made their first contribution in https://github.com/avajs/ava/pull/3007

    Full Changelog: https://github.com/avajs/ava/compare/v4.1.0...v4.2.0

    Source code(tar.gz)
    Source code(zip)
  • v4.1.0(Mar 6, 2022)

    New features

    • Allow customized sorting of test files prior to execution using sortTestFiles() in ava.config.js files by @erezrokah in https://github.com/avajs/ava/pull/2968
    • Warn when unsupported ava.config.json files are encountered by @razor-x in https://github.com/avajs/ava/pull/2962
    • Loosen type constraints for deepEqual assertion by @RebeccaStevens in https://github.com/avajs/ava/pull/2969

    Fixes

    • ava --version works again by @novemberborn in https://github.com/avajs/ava/pull/2961

    New Contributors

    • @sikrinick made their first contribution in https://github.com/avajs/ava/pull/2958
    • @scottdotjs made their first contribution in https://github.com/avajs/ava/pull/2954
    • @gibson042 made their first contribution in https://github.com/avajs/ava/pull/2975
    • @erezrokah made their first contribution in https://github.com/avajs/ava/pull/2968
    • @razor-x made their first contribution in https://github.com/avajs/ava/pull/2962
    • @RebeccaStevens made their first contribution in https://github.com/avajs/ava/pull/2969

    Full Changelog: https://github.com/avajs/ava/compare/v4.0.1...v4.1.0

    Source code(tar.gz)
    Source code(zip)
  • v4.0.1(Jan 8, 2022)

    What's Changed

    • Fix encoding of large snapshot data by @novemberborn in https://github.com/avajs/ava/pull/2936

    Full Changelog: https://github.com/avajs/ava/compare/v4.0.0...v4.0.1

    Source code(tar.gz)
    Source code(zip)
  • v4.0.0(Jan 3, 2022)

    We're celebrating the new year with the official AVA 4 release! 🎊

    npm install -D ava
    

    The cool new stuff 🆒

    Worker threads 🧑‍💼

    By default, test files are now run in worker threads! Huge thanks to @dnlup for landing this.

    Test files should run a little quicker, since it's easier to spin up a worker thread than a child process. You can use --no-worker-threads on the command line, or workerThreads: false in your AVA configuration, to fall back to using child processes.

    Shared workers are no longer experimental 🎊

    Shared workers are no longer experimental. This is a powerful feature that loads a program in a worker thread in AVA's main process and then communicate with code running in the test workers. This enables your tests to better utilize shared resources during a test run, as well as providing opportunities to set up these resources before tests start (or clean them up after).

    When you use watch mode, shared workers remain loaded across runs.

    Improved test selection 🤳

    AVA selects test files based on your package.json or ava.config.* configuration files. When used on the CLI you can then provide patterns to select a subset of these files.

    You can now pass a folder and AVA will select the test files contained therein. Or you can provide a specific JavaScript file and AVA will run it even if it wasn’t selected by your configuration.

    If AVA finds files based on the configuration, but none of those were selected to the CLI arguments, it now prints a warning.

    Better monorepo support 🚝

    AVA now looks for ava.config.* files in parent directories, until it finds a directory with a .git directory (or file). This lets you specify AVA configuration at the top of your monorepo and still run AVA from within each package.

    New snapshot format 📸

    @ninevra has worked tirelessly on landing a new snapshot format. It contains all information necessary to regenerate the report file. This allows for snapshots to be updated even if tests or assertions are skipped.

    Previously failing test files run first 🏃

    AVA now records which test files failed in the previous run. It then prioritizes testing these files when you run AVA again. Thanks @bunysae!

    ESM support 🤾

    AVA 4 comes with full ES module support. Both ESM and CJS entrypoints are provided so that you can use it no matter how you manage your project.

    The ava.config.js file is now treated as CJS or ESM depending on module type configured in the package.json file. ava.config.mjs is now supported.

    If you use JavaScript files with non-standard extensions you can configure AVA to import them.

    Note that dependency tracking in watch mode does not yet work with ES modules.

    Dedicated macro factory with type inference 🏭

    test.macro() returns an object that can be used with test() and hooks. The t.context type is inherited from test. When used with TypeScript this gives much better type inference.

    Like with AVA 3, regular functions that also have a title property that is a string-returning function are supported. However the type checking won’t be as good.

    Source maps 🗺

    AVA now uses the source map support that’s built in to Node.js itself. This should give better stack traces. However we’re not sure yet what happens if you load a program that automatically modifies stack traces.

    Line number selection (where npx ava test.js:5 runs the test at line 5) now uses source maps and so should work better with TypeScript files.

    Assertions as type guards 💂

    Most assertions now return a boolean indicating whether they passed. If you use AVA with TypeScript, you can use this as a type guard. Thanks @jmarkham828!

    (This is not supported for t.snapshot() and the "throws" assertions.)

    Breaking changes 💥

    AVA 4 requires at least Node.js 12.22, 14.17, 16.4 or 17. Node.js 10 is no longer supported.

    If installed globally, AVA will no longer use any locally installed version. Install locally and run with npx ava instead. When running test files from another project that also has AVA installed, those test files will now fail to run (because they'll try and use that other AVA version).

    Ecosystem 🏞

    • Support for @ava/babel has been removed. We haven’t seen enough contributions to that package to recommend it for AVA 4. We’d be open to reinstating it in the future (just as we’d be open to support any other compilation provider).
    • As a consequence, “enhanced assertions” are no longer available.
    • AVA 4 requires avajs/[email protected] or newer.
    • Support for the esm package has been removed.

    Configuration 🗒

    • ava.config.js now follows the module type configured in package.json.
    • ava.config.* files may be found that are outside your project directory.

    Tests and assertions 🥼

    • By default test files execute in worker threads, not child processes.
    • test.meta.file and test.meta.snapshotDirectory are now file URL strings.
    • Whitespace in test titles is now normalized. This could result in two tests being treated as having the same title, even though they are different in code. Thanks @KillyMXI!
    • test() and t.try() no longer take an array of test implementations. Use a loop instead.
    • The t.throws() and t.throwAsync() assertions can no longer be called with a null value for the expectations argument.
    • test.cb() and t.end() have been removed. Use async functions and util.promisify() instead.
    • t.teardown() now executes in last-in-first-out order.

    Snapshots 📸

    • Snapshots recorded using earlier AVA versions are no longer recognized. Run npx ava -u to rebuild your snapshots after upgrading.
    • Snapshots no longer recognize React elements, instead we want to provide this functionality through a plugin interface
    • t.snapshot() no longer works in hooks.
    • t.snapshot() no longer takes an options argument allowing you to customize the snapshot ID.

    TypeScript 🪛

    • The instanceOf expectation of t.throws() and t.throwsAsync() assertions must now be an Error constructor.
    • You’re expected to use test.macro() when declaring macros.
    • Implementation arguments now default to unknown.
    • Types have been renamed. Meta replaces MetaInterface, other types with Interface suffixes now use the Fn suffix. There may be some other changes too. 4b4b2f63f184056b4038dfc692f99421038d3ec1
    • t.throws() and t.throwsAsync() return undefined when the assertion fails. The type definition now matches this behavior.
    • Our TypeScript definitions are now tested against TypeScript 4.4

    Other changes 🤓

    • We’ve removed the non-verbose reporter because it proved too hard to maintain two subtly different reporter outputs. We’d really like to rewrite the reporter.
    • AVA's configuration files may now export promises or asynchronous factory methods.
    • The --config argument may now point to a file that is not alongside the package.json file.
    • When you use t.timeout(), AVA itself won’t time out until your test does. Thanks @OhYash!
    • Multi-line snapshot labels now render correctly in Markdown. Thanks @KillyMXI!
    • The reporters now clean up .test and .spec extensions from file names, as well as test- prefixes.
    • Watch mode is better at detecting changes to snapshots and not rerunning tests.

    New Contributors

    • @Fem-Fem made their first contribution in https://github.com/avajs/ava/pull/2750
    • @OhYash made their first contribution in https://github.com/avajs/ava/pull/2758
    • @KillyMXI made their first contribution in https://github.com/avajs/ava/pull/2773
    • @mcecode made their first contribution in https://github.com/avajs/ava/pull/2794
    • @duncanfinney made their first contribution in https://github.com/avajs/ava/pull/2820
    • @asaid-0 made their first contribution in https://github.com/avajs/ava/pull/2788
    • @bompus made their first contribution in https://github.com/avajs/ava/pull/2843
    • @StefanoA1 made their first contribution in https://github.com/avajs/ava/pull/2849
    • @live627 made their first contribution in https://github.com/avajs/ava/pull/2851
    • @alessandroasm made their first contribution in https://github.com/avajs/ava/pull/2863
    • @eltociear made their first contribution in https://github.com/avajs/ava/pull/2870
    • @hamidbae made their first contribution in https://github.com/avajs/ava/pull/2878
    • @rrichardson made their first contribution in https://github.com/avajs/ava/pull/2910
    • @make-github-pseudonymous-again made their first contribution in https://github.com/avajs/ava/pull/2913
    • @lightmare made their first contribution in https://github.com/avajs/ava/pull/2918

    Full changelog since RC 1: https://github.com/avajs/ava/compare/v4.0.0-rc.1...v4.0.0 Full changelog since AVA 3: https://github.com/avajs/ava/compare/v3.15.0...v4.0.0

    Source code(tar.gz)
    Source code(zip)
  • v4.0.0-rc.1(Nov 1, 2021)

    AVA 4 is nearly done! We’re not expecting major breaking changes, so barring any bugs or other surprises this should be it.

    As always with pre-releases though you’re best-off installing an exact version:

    npm install -D -E ava@next
    

    The cool new stuff 🆒

    Worker threads 🧑‍💼

    By default, test files are now run in worker threads! Huge thanks to @dnlup for landing this.

    Test files should run a little quicker, since it's easier to spin up a worker thread than a child process. You can use --no-worker-threads on the command line, or workerThreads: false in your AVA configuration, to fall back to using child processes.

    Shared workers are no longer experimental 🎊

    Shared workers are no longer experimental. This is a powerful feature that loads a program in a worker thread in AVA's main process and then communicate with code running in the test workers. This enables your tests to better utilize shared resources during a test run, as well as providing opportunities to set up these resources before tests start (or clean them up after).

    When you use watch mode, shared workers remain loaded across runs.

    Improved test selection 🤳

    AVA selects test files based on your package.json or ava.config.* configuration files. When used on the CLI you can then provide patterns to select a subset of these files.

    You can now pass a folder and AVA will select the test files contained therein. Or you can provide a specific JavaScript file and AVA will run it even if it wasn’t selected by your configuration.

    If AVA finds files based on the configuration, but none of those were selected to the CLI arguments, it now prints a warning.

    Better monorepo support 🚝

    AVA now looks for ava.config.* files in parent directories, until it finds a directory with a .git directory (or file). This lets you specify AVA configuration at the top of your monorepo and still run AVA from within each package.

    New snapshot format 📸

    @ninevra has worked tirelessly on landing a new snapshot format. It contains all information necessary to regenerate the report file. This allows for snapshots to be updated even if tests or assertions are skipped.

    Previously failing test files run first 🏃

    AVA now records which test files failed in the previous run. It then prioritizes testing these files when you run AVA again. Thanks @bunysae!

    ESM support 🤾

    AVA 4 comes with full ES module support. Both ESM and CJS entrypoints are provided so that you can use it no matter how you manage your project.

    The ava.config.js file is now treated as CJS or ESM depending on module type configured in the package.json file. ava.config.mjs is now supported.

    If you use JavaScript files with non-standard extensions you can configure AVA to import them.

    Note that dependency tracking in watch mode does not yet work with ES modules.

    Dedicated macro factory with type inference 🏭

    test.macro() returns an object that can be used with test() and hooks. The t.context type is inherited from test. When used with TypeScript this gives much better type inference.

    Like with AVA 3, regular functions that also have a title property that is a string-returning function are supported. However the type checking won’t be as good.

    Source maps 🗺

    AVA now uses the source map support that’s built in to Node.js itself. This should give better stack traces. However we’re not sure yet what happens if you load a program that automatically modifies stack traces.

    Line number selection (where npx ava test.js:5 runs the test at line 5) now uses source maps and so should work better with TypeScript files.

    Assertions as type guards 💂

    Most assertions now return a boolean indicating whether they passed. If you use AVA with TypeScript, you can use this as a type guard. Thanks @jmarkham828!

    (This is not supported for t.snapshot() and the "throws" assertions.)

    Breaking changes 💥

    AVA 4 requires at least Node.js 12.22, 14.17, 16.4 or 17. Node.js 10 is no longer supported.

    If installed globally, AVA will no longer use any locally installed version. Install locally and run with npx ava instead. When running test files from another project that also has AVA installed, those test files will now fail to run (because they'll try and use that other AVA version).

    Ecosystem 🏞

    • Support for @ava/babel has been removed. We haven’t seen enough contributions to that package to recommend it for AVA 4. We’d be open to reinstating it in the future (just as we’d be open to support any other compilation provider).
    • As a consequence, “enhanced assertions” are no longer available.
    • AVA 4 requires avajs/[email protected] or newer.
    • Support for the esm package has been removed.

    Configuration 🗒

    • ava.config.js now follows the module type configured in package.json.
    • ava.config.* files may be found that are outside your project directory.

    Tests and assertions 🥼

    • By default test files execute in worker threads, not child processes.
    • test.meta.file and test.meta.snapshotDirectory are now file URL strings.
    • Whitespace in test titles is now normalized. This could result in two tests being treated as having the same title, even though they are different in code. Thanks @KillyMXI!
    • test() and t.try() no longer take an array of test implementations. Use a loop instead.
    • The t.throws() and t.throwAsync() assertions can no longer be called with a null value for the expectations argument.
    • test.cb() and t.end() have been removed. Use async functions and util.promisify() instead.
    • t.teardown() now executes in last-in-first-out order.

    Snapshots 📸

    • Snapshots recorded using earlier AVA versions are no longer recognized. Run npx ava -u to rebuild your snapshots after upgrading.
    • Snapshots no longer recognize React elements, instead we want to provide this functionality through a plugin interface
    • t.snapshot() no longer works in hooks.
    • t.snapshot() no longer takes an options argument allowing you to customize the snapshot ID.

    TypeScript 🪛

    • The instanceOf expectation of t.throws() and t.throwsAsync() assertions must now be an Error constructor.
    • You’re expected to use test.macro() when declaring macros.
    • Implementation arguments now default to unknown.
    • Types have been renamed. Meta replaces MetaInterface, other types with Interface suffixes now use the Fn suffix. There may be some other changes too. 4b4b2f63f184056b4038dfc692f99421038d3ec1
    • t.throws() and t.throwsAsync() return undefined when the assertion fails. The type definition now matches this behavior.
    • Our TypeScript definitions are now tested against TypeScript 4.4

    Other changes 🤓

    • We’ve removed the non-verbose reporter because it proved too hard to maintain two subtly different reporter outputs. We’d really like to rewrite the reporter.
    • AVA's configuration files may now export promises or asynchronous factory methods.
    • The --config argument may now point to a file that is not alongside the package.json file.
    • When you use t.timeout(), AVA itself won’t time out until your test does. Thanks @OhYash!
    • Multi-line snapshot labels now render correctly in Markdown. Thanks @KillyMXI!
    • The reporters now clean up .test and .spec extensions from file names, as well as test- prefixes.
    • Watch mode is better at detecting changes to snapshots and not rerunning tests.

    New Contributors

    • @Fem-Fem made their first contribution in https://github.com/avajs/ava/pull/2750
    • @OhYash made their first contribution in https://github.com/avajs/ava/pull/2758
    • @KillyMXI made their first contribution in https://github.com/avajs/ava/pull/2773
    • @mcecode made their first contribution in https://github.com/avajs/ava/pull/2794
    • @duncanfinney made their first contribution in https://github.com/avajs/ava/pull/2820
    • @asaid-0 made their first contribution in https://github.com/avajs/ava/pull/2788
    • @bompus made their first contribution in https://github.com/avajs/ava/pull/2843
    • @StefanoA1 made their first contribution in https://github.com/avajs/ava/pull/2849
    • @live627 made their first contribution in https://github.com/avajs/ava/pull/2851
    • @alessandroasm made their first contribution in https://github.com/avajs/ava/pull/2863
    • @eltociear made their first contribution in https://github.com/avajs/ava/pull/2870
    • @hamidbae made their first contribution in https://github.com/avajs/ava/pull/2878

    Full changelog since Alpha 2: https://github.com/avajs/ava/compare/v4.0.0-alpha.2...v4.0.0-rc.1

    Source code(tar.gz)
    Source code(zip)
  • v4.0.0-alpha.2(Apr 6, 2021)

    This is the second (pre)release of AVA 4 🎊 Please read the release notes for Alpha 1.

    Breaking changes 💥

    • Shared workers are available only in worker threads, not child processes. Thanks @dnlup! bdf2cf07
    • If installed globally, AVA will no longer use any locally installed version. Install locally and run with npx ava instead 1ee1e826
    • When running test files from another project that also has AVA installed, those test files will now fail to run (because they'll try and use that other AVA version) cc4e6229

    Other changes 🤓

    • Remove --preserve-symlink and npm link detection eef1a555
    • Correctly resolve ESLint plugin helper worker path 000c42e6
    • Time out ESLint config resolution after 10 seconds 3aac5e8f
    • Explicit and separate CJS and ESM entrypoints 5e084445

    https://github.com/avajs/ava/compare/v4.0.0-alpha.1...v4.0.0-alpha.2

    Source code(tar.gz)
    Source code(zip)
  • v4.0.0-alpha.1(Mar 21, 2021)

    This is the first (pre)release of AVA 4 🎊 There's some great new features, some cleanup of old interfaces, and some other smaller-but-still-breaking changes.

    You can install the latest AVA 4 prerelease using:

    npm install -D -E ava@next
    

    The cool new stuff

    Worker threads 🧑‍💼

    By default, test files are now run in worker threads! Huge thanks to @dnlup for landing this. 0e5cc7dc2b1512d0abe9bfba57b26888eedea0cf

    Test files should run a little quicker, since it's easier to spin up a worker thread than a child process. You can use --no-worker-threads on the command line, or workerThreads: false in your AVA configuration, to fall back to using child processes.

    New snapshot format 📸

    @ninevra has worked tirelessly on landing a new snapshot format. It contains all information necessary to regenerate the report file. This allows for snapshots to be updated even if tests or assertions are skipped. 14ec281dd6d71d46cf2b755e7451262dab6cbc64

    Asynchronous config loading & ESM support 🤾

    AVA's configuration files may now export promises or asynchronous factory methods. The ava.config.js file is now treated as CJS or ESM depending on module type configured in the package.json file. ava.config.mjs is now supported. f7cb1c7b038eba017bd77fc93d9921b1db962174 c7b782098dbaeaacfd671c12ffc5100bfb7be75d

    Previously failing test files run first 🏃

    AVA now records which test files failed in the previous run. It then prioritizes testing these files when you run AVA again. Thanks @bunysae! d7426720ad55ba387d86aaae3a3af06a8020c761

    Assertions as type guards 💂

    Most assertions now return a boolean indicating whether they passed. If you use AVA with TypeScript, you can use this as a type guard. Thanks @jmarkham828! 72a4e2fd4c931b13354ad9d10149c383b4ca48b3 5eea60836402ff0ca052cf1d017deabdf8a6fb36

    (This is not supported for t.snapshot() and the "throws" assertions.)

    The breaking changes 💥

    • AVA 4 requires Node.js 12.20, 14.15 or 15. Node.js 10 is no longer supported 5dd22c96324f527260840e26fce8100d9a37a309
    • By default test files execute in worker threads, not child processes 0e5cc7dc2b1512d0abe9bfba57b26888eedea0cf
    • ava.config.js now follows the module type configured in package.json f7cb1c7b038eba017bd77fc93d9921b1db962174 c7b782098dbaeaacfd671c12ffc5100bfb7be75d
    • Snapshots recorded using earlier AVA versions are no longer recognized. Run npx ava -u to rebuild your snapshots after upgrading 14ec281dd6d71d46cf2b755e7451262dab6cbc64
    • Snapshots no longer recognize React elements, instead we want to provide this functionality through a plugin interface 26999c4cca86b2f50343af2cb14834144c722297
    • t.snapshot() no longer works in hooks bcb750c1551cca380a0003ebc8f66987a6b16d6c
    • t.snapshot() no longer takes an options argument allowing you to customize the snapshot ID d8b1e89e6e8b88e1582cf02f4cf088c87c2e058f
    • test.cb() and t.end() have been removed. Use async functions and util.promisify() instead.
    • The t.throws() and t.throwAsync() assertions can no longer be called with a null value for the expectations argument 7f64f5c834e8fab29f4778705ee05b2a81867879
    • t.teardown() now executes in last-in-first-out order dc4483f440fe8736ff71226fd8b18c0e2cc86f51
    • Support for the esm package has been removed 2011b92b638df42b4d050a19e9b37cbb19659970
    • Our TypeScript definitions are now tested against TypeScript 4.2 6429581eb57232839895b6d727b32ae0dc4e12af 9cedc9770d5ac2a75c88f7f3b81c263c88989332
    • A whole host of experimental features have become default, and can no longer be opted into.

    Other changes 🗒

    Our TypeScript recipe has been updated with ts-node and ESM instructions. Thanks @mesqueeb! a0791529c18394d92224232cf9d1696426ada505

    We'd also like to thank @kiancross, @papb and @JerryGreen.

    https://github.com/avajs/ava/compare/v3.15.0...v4.0.0-alpha.1

    Source code(tar.gz)
    Source code(zip)
  • v3.15.0(Jan 1, 2021)

    Automatic snapshot file removal

    When you stop using snapshots in a test file, the next time you run ava --update-snapshots we'll remove the left-over snapshot files. Thanks @ninevra! 4f093ab

    TAP improvements

    @tymfear has been on a roll improving our TAP reporter. t.log() output is now compliant with the spec 99ab93a. Tests that did not run due to timeouts are now reported 98595dae58209a9062d0238c7a3dd7078a9962d1.

    Next-generation configuration

    AVA 4 will add full support for ESM configuration files as well as allowing you to have asynchronous factory functions a2f2614cc1e34fb9a7aa204b37b3b25559f203d9. If you're using Node.js 12 or later you can opt-in to these features in AVA 3 by enabling the nextGenConfig experiment. Say in an ava.config.mjs file:

    export default {
    	nonSemVerExperiments: {
    		nextGenConfig: true
    	},
    	files: ['unit-tests/**/*]
    };
    

    This also allows you to pass an .mjs file using the --config argument.

    With this experiment enabled, AVA will no longer have special treatment for ava.config.js files. Instead AVA follows Node.js' behavior, so if you've set "type": "module" you must use ESM, and otherwise you must use CommonJS.

    You mustn't have an ava.config.mjs file next to an ava.config.js or ava.config.cjs file.


    See https://github.com/avajs/ava/compare/v3.14.0...v3.15.0 for all changes.

    Source code(tar.gz)
    Source code(zip)
  • v3.14.0(Dec 7, 2020)

    Snapshot ordering

    With this release, snapshot files are now ordered based on test declaration, not completion. This makes it easier to compare the human-readable reports to your test file, and also stops the .snap from changing when the reports themselves don't. You'll want to rebuild snapshots after upgrading to this release to isolate any changes. Thanks @ninevra! e66b54ce61d8bb16bbcd15b7fb90893d02e5a65c

    Shared workers

    We’ve been working on making AVA more extensible. One major step on this path is our new shared worker support: run code in the main process, communicate with test workers and influence execution. Find out more in our shared workers recipe.


    See https://github.com/avajs/ava/compare/v3.13.0...v3.14.0 for all changes.

    Source code(tar.gz)
    Source code(zip)
  • v3.13.0(Sep 27, 2020)

    • t.passed can now be used in tests and teardown functions. Thanks @tymfear! 900dc6d46a1f8728dddfab1e42caef1fa8a51c85
    • In AVA 4, you'll no longer be able to pass null as the expectation for t.throws() & t.throwsAsync(). You can opt in to this early by enabling the disableNullExpectations experiment. Thanks @JSimoni42! f328a6933af7aca221b08f694bb14b03701eca68
    • The Enzyme recipe has been updated. Thanks @jonathansamines! db5d2c369178b78dfbd899d002a141a05655ccdc
    • The TypeScript recipe has been updated. Thanks @SephReed! a3379fad3893468309a43b4b56d290f94933f082

    See https://github.com/avajs/ava/compare/v3.12.1...v3.13.0 for all changes.

    Source code(tar.gz)
    Source code(zip)
  • v3.12.1(Aug 23, 2020)

    Configure how AVA loads test files

    Normally, AVA loads all files as CommonJS, except for mjs files and if you've configured "type": "module" in your package.json.

    As an experiment, you can now configure how AVA loads other file extensions. This is useful if you want to use Node.js' experimental loaders feature. Read more in our documentation. Thank you @macarie for working on this! 5c9dbb96ad0beb7521e5051390478493250ba6b0

    Comparison bugfix

    There was a bug in our comparison library which meant that negative-index properties on lists were not compared. This was fixed in a patch release, which will definitely be installed when you install AVA 3.12. Your tests may have been passing, even though they should have been failing. They'll fail now. Snapshots may also be different, causing tests to fail.

    All changes

    See https://github.com/avajs/ava/compare/v3.11.1...v3.12.1 for all changes.

    Thank you @AnthumChris for making sure our ESM example used ESM syntax (20bc7810536b3b968db5461ff4093bb5ae912050).

    Source code(tar.gz)
    Source code(zip)
  • v3.11.1(Aug 3, 2020)

    This release fixes corrupted output of the default reporter when test or program code writes to standard out. 5ddc9fda100205a5ca315a86e27a01be443b88b1

    Also, thanks to @jonathansamines we've taken another step to using AVA to test AVA. 1150991ba1921cbf888438d46350894484356078

    See https://github.com/avajs/ava/compare/v3.11.0...v3.11.1 for all changes.

    Source code(tar.gz)
    Source code(zip)
  • v3.11.0(Jul 27, 2020)

    New t.like() assertion

    Thanks to @futpib we now have a t.like() assertion 19c4f35fbae740268dedeeb4d450f813f2d5e85e:

    In the following example, the map property of value must be deeply equal to that of selector. However nested.qux is ignored, because it's not in selector.

    t.like({
    	map: new Map([['foo', 'bar']]),
    	nested: {
    		baz: 'thud',
    		qux: 'quux'
    	}
    }, {
    	map: new Map([['foo', 'bar']]),
    	nested: {
    		baz: 'thud',
    	}
    })
    

    Read more in the t.like() assertion documentation.

    This assertion was previously introduced as an experiment.

    VSCode 1.47 debugging improvements

    You can now debug tests using the new JavaScript Debug Terminal in VSCode 1.47. We've updated our debugging recipe accordingly. Thank you @connor4312 for the documentation updates and your work on VSCode! bc39bcc3ff92cb2979564ec2e69dc72be6509f78

    All changes

    See https://github.com/avajs/ava/compare/v3.10.1...v3.11.0 for all changes.

    Source code(tar.gz)
    Source code(zip)
  • v3.10.1(Jul 5, 2020)

    It's time for another AVA release 🎉

    Restricting when you can update snapshots

    When executing a subset of tests, through --match or or .only() or .skip(), you can no longer also update snapshots. This prevents you from accidentally deleting snapshots. Thank you @bunysae for putting this together. f72fab40160a413f4d7ab0208979fe3e721198ea

    If you are skipping a test that you can't immediately fix, but you still need to update snapshots, use .failing() instead.

    Support for message strings in t.timeout() calls

    Thanks to @jonathansamines you can now provide a message string when using t.timeout(). This can be useful if your test depends on some other setup that may not have been completed: ca8ea45587ebefa5584d6a7aa50adf90840701cf

    test('foo', t => {
    	t.timeout(100, 'make sure database has started');
    	// Write your assertions here
    });
    

    t.try() does not work in hooks

    t.try() has never worked in hooks, but thanks to @okyantoro it now fails properly instead of crashing. d01db61ee5e9785d9f80ad5683cac21db4b96509

    t.snapshot() does not really work in hooks either

    t.snapshot() sort of works in hooks, but we'll be removing this in AVA 4. You can opt in to this behavior by enabling the disableSnapshotsInHooks experiment. Again thank you @okyantoro d01db61ee5e9785d9f80ad5683cac21db4b96509.

    Fixed TypeScript definition for t.like()

    The experimental t.like() assertion should now work better with TypeScript.

    All changes

    See https://github.com/avajs/ava/compare/v3.9.0...v3.10.1 for all changes.

    Source code(tar.gz)
    Source code(zip)
  • v3.9.0(Jun 14, 2020)

    New experiments!

    Thanks to @futpib we now have an experimental t.like() assertion 19c4f35fbae740268dedeeb4d450f813f2d5e85e:

    In the following example, the map property of value must be deeply equal to that of selector. However nested.qux is ignored, because it's not in selector.

    t.like({
    	map: new Map([['foo', 'bar']]),
    	nested: {
    		baz: 'thud',
    		qux: 'quux'
    	}
    }, {
    	map: new Map([['foo', 'bar']]),
    	nested: {
    		baz: 'thud',
    	}
    })
    

    Read more in the t.like() assertion documentation and let us know what you think.

    @yjpa7145 has contributed an experiment to reverse the order in which t.teardown() functions are run, so that the last registered function is called first 952a0177758c5601a72c2b050fc0308e7fa774c7. This will be the behavior in AVA 4.

    To enable both these experiments update your AVA configuration:

    package.json:

    {
    	"ava": {
    		"nonSemVerExperiments": {
    			"likeAssertion": true,
    			"reverseTeardowns": true
    		}
    	}
    }
    

    ava.config.js:

    export default {
    	nonSemVerExperiments: {
    		likeAssertion: true,
    		reverseTeardowns: true
    	}
    }
    

    Reporter changes

    @Michael55555 has helped us combine our reporter code into a single file b3866b6b06c98862a19f6cb27ec28b643e2f00c7. We've also made some other tweaks and improvements baaf99a792eed586678a0cf88864f3f0aa16bd7a. Let us know if anything seems amiss.

    Improved diffs

    @bunysae made it so that missing or extraneous objects in diffs are printed with extra depth https://github.com/concordancejs/concordance/pull/62.

    Farewell Node.js 13

    Node.js 13 has reached end-of-life. Per our support statement we have removed it from our test matrix and supported version list.

    All changes

    See https://github.com/avajs/ava/compare/v3.8.2...v3.9.0 for all changes. Thank you @paulrobertlloyd and @Autre31415 for contributing documentation improvements.

    Source code(tar.gz)
    Source code(zip)
  • v3.8.2(May 8, 2020)

    • Fix bad dependency fd92b4a3
    • Use configured depth limit for diffs in assertion failures, thanks @bunysae! a5385a41

    https://github.com/avajs/ava/compare/v3.8.1...v3.8.2

    Source code(tar.gz)
    Source code(zip)
  • v3.8.1(Apr 26, 2020)

    Node.js 14 support

    Great news, this is a feature heavy release!

    First off, though, AVA now officially supports Node.js 14. Thank you @zackschuster! 2e7c76b85cb65a04605fed843ee2f571afc66c37

    Run tests at specific line numbers

    AVA can now run tests at specific line numbers! 🎉

    Given the following test file:

    test.js

    1: test('unicorn', t => {
    2:   t.pass();
    3: });
    4:
    5: test('rainbow', t => {
    6:  t.fail();
    7: });
    

    Running npx ava test.js:2 for would run the unicorn test. In fact you could use any line number between 1 and 3.

    This feature is only available from the command line. It won't work if you use tools like ts-node/register or @babel/register, and it does not currently work with @ava/babel and @ava/typescript. See https://github.com/avajs/ava/issues/2473.

    Thank you @ulken for your hard work and patience to get this shipped. 1222ce9538e4890c20af695e558e3ee490f5a41b

    Test-specific teardown functions

    Sometimes tests have side-effects you want to clean up. @ulken has implemented t.teardown() which lets you register teardown functions within your test. They'll run once your test has finished, even if it failed: 75cbc3b2a53d3b8530266b10bed71b838bc11fec

    test('read file', t => {
    	fs.writeFileSync('file.txt', '👋');
    	t.teardown(() => fs.unlinkSync('file.txt');
    
    	// Run assertions
    });
    

    Node.js internal in stack traces

    Thanks to @bunysae, stack traces now include Node.js internals. Previously we removed them because we wanted you to focus on your own code, but quite often they do provide context. Now they're displayed, but somewhat dimmed. 9a9351ddbee9c6c76601210c5dd8f5b0d81cc3b0

    Watch mode with the default reporter

    Watch mode with the default reporter once again accepts key input. Thanks @pcdevil! 59c227d9c5261117d99e8e84693b9c89c3438a92

    ICYMI

    • afterEach() and afterEach.always() hooks can now determine whether the test passed. Thank you @bunysae for contributing this! 8f312c0

      	test('passes', t => t.pass());
      
      	test.afterEach(t => {
      		if (t.passed) {
      			// Do something because the test passed
      		} else {
      			// Do something because the test failed
      		}
      	});
      
    • If you've ever wanted to save some files along with AVA's snapshots, you can now determine the directory path by accessing test.meta.snapshotDirectory. Thank you @ulken! cb5f9f7

    All changes

    See https://github.com/avajs/ava/compare/v3.7.1...v3.8.1 for all changes.

    Source code(tar.gz)
    Source code(zip)
  • v3.7.1(Apr 19, 2020)

    • Support parallel runs that do not need to run test files, courtesy of @micaelmbagira 26c8326b

    https://github.com/avajs/ava/compare/v3.7.0...v3.7.1

    Source code(tar.gz)
    Source code(zip)
  • v3.7.0(Apr 13, 2020)

    If you've ever wanted to save some files along with AVA's snapshots, you can now determine the directory path by accessing test.meta.snapshotDirectory. Thank you @ulken ! cb5f9f70879ee549837c31e577e01f87970164ed

    See https://github.com/avajs/ava/compare/v3.6.0...v3.7.0 for all changes.

    Source code(tar.gz)
    Source code(zip)
  • v3.6.0(Apr 5, 2020)

    afterEach() and afterEach.always() hooks can now determine whether the test passed. Thank you @bunysae for contributing this! 8f312c0f2c978ba39baae0f701015d79af18cbde:

    test('passes', t => t.pass());
    
    test.afterEach(t => {
    	if (t.passed) {
    		// Do something because the test passed
    	} else {
    		// Do something because the test failed
    	}
    });
    

    @mbiesiad has diligently translated our documentation to Polish. Thank you @kekuu for reviewing.

    Also thank you @timgates42 for fixing a typo in our documentation. ede4f322b4fa6263c8ae14ec04282ab06bb0afd4

    See https://github.com/avajs/ava/compare/v3.5.0...v3.6.0 for all changes.

    Source code(tar.gz)
    Source code(zip)
  • v3.5.0(Mar 1, 2020)

    When using ava debug, you can now specify the address or hostname the inspector is available through by using the --host option. Thanks to @DYefimov for contributing this! 13d66519

    See https://github.com/avajs/ava/compare/v3.4.0...v3.5.0 for all changes. Spoiler alert: it's just this one 😉

    Source code(tar.gz)
    Source code(zip)
  • v3.4.0(Feb 23, 2020)

    Introducing the t.try() assertion

    The new t.try() allows you to try assertions without causing the test to fail:

    test('do the thing', async t => {
      const attempt = () => t.try(async tt => {
        const result = await getResult()
        // getResult() can be flaky and sometimes throws :(
        tt.is(result, 'expected')
      })
      
      const firstAttempt = await attempt()
      if (firstAttempt.passed) return firstAttempt.commit()
      
      t.log('Retrying (just once)')
      firstAttempt.discard()
      const secondAttempt = await attempt()
      secondAttempt.commit()
    })
    

    You can use any test implementation with t.try(), including (arrays of) macros. You can decide what to do with attempts. You can even run attempts concurrently, so long as they don't use snapshot assertions.

    This is great building block for handling all kinds of advanced test scenarios. We can't wait to see what you'll do with it! Find out more in the assertion documentation.

    This feature was previously behind an experimental flag. That flag has now been removed. If you have enabled the flag you'll have to update your AVA config. Also note that as of this release, attempt titles are always prefixed with the title of the parent test 7ee3a0e5940a105dec447851c777ea44555e8220.

    Once again, thank you @qlonik for contributing this new assertion.

    In case you missed it: ESM support

    As of the 3.3.0 release, AVA can load ESM test files! Check our updated ES Modules recipe for details.

    Our ESM support is still incomplete. Progress is tracked in the ESM support project. Join us, won't you?

    Other changes

    • The t.throws() and t.throwsAsync() assertions can now be called with undefined as the second argument. Previously, if you wanted to set an assertion message but did not want to provide any expectations for the thrown error you had to pass null. That's still allowed, of course. d0e21612390d50f084f7062b051164624ef391ff @stavalfi
    • ava.config.js files once again work with our @ava/typescript package f4d4edd3379e51ac733b184e20dd0228be24245a
    • Our TypeScript definition no longer references @types/node 7a1dacf369a5857309effa42fc1638d7b8fe4ead
    • We've improved the error message shown when test.cb() is used with asynchronous functions or observables f5a8c2b2df757886247492ce3372f1e18da36ab7 @toddkcarlson
    • The Vue recipe has been updated to use jsdom-global instead of browser-env 3f9c616b44c7374404d75af63f393750160c6b84 @Scrum
    • @fisker optimized how we detect ESM support 8831f54d760bbcadf8924ef6b10899a6b786c3b5

    See https://github.com/avajs/ava/compare/v3.3.0...v3.4.0 for all changes.

    Source code(tar.gz)
    Source code(zip)
  • v3.3.0(Feb 9, 2020)

    AVA can now load ESM test files! 🎉Thank you @arlac77 for making this happen. Check our updated ES Modules recipe for details.

    Our ESM support is still incomplete. Progress is tracked in the ESM support project. Join us, won't you?

    Other changes

    See https://github.com/avajs/ava/compare/v3.2.0...v3.3.0 for all changes.

    Source code(tar.gz)
    Source code(zip)
  • v3.2.0(Feb 2, 2020)

    This release improves the integration with the new @ava/typescript package, which allows AVA to load pre-compiled TypeScript files.

    First, install the new @ava/typescript package:

    npm install --save-dev @ava/typescript@^1.1
    

    Now let's assume your TypeScript files are in a src directory, output to a build directory. Configure AVA like so:

    ava.config.js file:

    export default {
      typescript: {
        rewritePaths: {
          'src/': 'build/'
        }
      }
    }
    

    Compile your TypeScript files and run your tests! Or, to run a specific test file, run npx ava src/test.ts.

    For more examples see the @ava/typescript package.

    As exciting as this is, it's still early days. We need your help improving our TypeScript support. Check out the open issues.

    Other changes

    See https://github.com/avajs/ava/compare/v3.1.0...v3.2.0 for all changes.

    Source code(tar.gz)
    Source code(zip)
Owner
AVA
Node.js test runner that lets you develop with confidence 🚀
AVA
☕️ simple, flexible, fun javascript test framework for node.js & the browser

☕️ Simple, flexible, fun JavaScript test framework for Node.js & The Browser ☕️ Links Documentation Release Notes / History / Changes Code of Conduct

Mocha 21.8k Dec 30, 2022
tap-producing test harness for node and browsers

tape tap-producing test harness for node and browsers example var test = require('tape'); test('timing test', function (t) { t.plan(2); t.eq

James Halliday 5.7k Dec 18, 2022
E2E test framework for Angular apps

Protractor Protractor is an end-to-end test framework for Angular and AngularJS applications. Protractor is a Node.js program built on top of WebDrive

Angular 8.8k Jan 2, 2023
Politik Test

Politik Test Netlify Live Installation and Setup Instructions Clone down this repository. You will need node and npm installed globally on your machin

Yavuz Selim Şerifoğlu 6 Jun 13, 2021
Cypress Playback is a plugin and a set of commands that allows Cypress to automatically record responses to network requests made during a test run.

Cypress Playback ?? Automatically record and playback HTTP requests made in Cypress tests. Cypress Playback is a plugin and a set of commands that all

O’Reilly Media, Inc. 5 Dec 16, 2022
Simple JavaScript testing framework for browsers and node.js

A JavaScript Testing Framework Jasmine is a Behavior Driven Development testing framework for JavaScript. It does not rely on browsers, DOM, or any Ja

Jasmine 15.5k Jan 2, 2023
A Node.js tool to automate end-to-end web testing.

A Node.js tool to automate end-to-end web testing. Write tests in JS or TypeScript, run them and view results. Homepage • Documentation • FAQ • Suppor

Developer Express Inc. 9.5k Jan 9, 2023
null 8 Nov 11, 2022
🚀 The Node.js Framework highly focused on developer ergonomics, stability and confidence

Sponsored by FOSS United is a non-profit foundation that aims at promoting and strengthening the Free and Open Source Software (FOSS) ecosystem in Ind

AdonisJS Framework 13.4k Dec 31, 2022
Spectacular Test Runner for JavaScript

Karma A simple tool that allows you to execute JavaScript code in multiple real browsers. The main purpose of Karma is to make your test-driven develo

Karma 11.8k Dec 27, 2022
Test runner based on Tape and Browserify

prova Node & Browser Test runner based on Tape and Browserify. Screencasts: node.gif, browser.gif, both.gif, headless browser Slides: slides.com/azer/

Azer Koçulu 335 Oct 28, 2022
A new zero-config test runner for the true minimalists

Why User-friendly - zero-config, no API to learn, simple conventions Extremely lighweight - only 40 lines of code and no dependencies Super fast - wit

null 680 Dec 20, 2022
A low-feature, dependency-free and performant test runner inspired by Rust and Deno

minitest A low-feature, dependency-free and performant test runner inspired by Rust and Deno Simplicity: Use the mt test runner with the test function

Sondre Aasemoen 4 Nov 12, 2022
A leetcode workspace template with test case runner for JavaScript/TypeScript programmers.

leetcode-typescript-workspace English | 简体中文 A vscode workspace template with test case runner script for JavaScript/TypeScript programmers using exte

null 10 Dec 13, 2022
A simple tap test runner that can be used by any javascript interpreter.

just-tap A simple tap test runner that can be used in any client/server javascript app. Installation npm install --save-dev just-tap Usage import cre

Mark Wylde 58 Nov 7, 2022
Parse, validate and transform data with confidence in nuxt using zod

nuxt-parse A nuxt focused package to make data validation and parsing easy. This package follows the design philosophy of the article parse, don't val

sidebase 12 Jan 7, 2023
📓 The UI component explorer. Develop, document, & test React, Vue, Angular, Web Components, Ember, Svelte & more!

Build bulletproof UI components faster Storybook is a development environment for UI components. It allows you to browse a component library, view the

Storybook 75.8k Jan 4, 2023
📓 The UI component explorer. Develop, document, & test React, Vue, Angular, Web Components, Ember, Svelte & more!

Build bulletproof UI components faster Storybook is a development environment for UI components. It allows you to browse a component library, view the

Storybook 75.9k Jan 9, 2023
A Develop Tool to Test WebSocket, Socket.IO, Stomp, Bayeux, HTTP, TCP, UDP, WebRTC, DNS API.

A Develop Tool to Test WebSocket, Socket.IO, Stomp, Bayeux, HTTP, TCP, UDP, WebRTC, DNS API.

York Yao 24 Sep 6, 2022
📓 The UI component explorer. Develop, document, & test React, Vue, Angular, Web Components, Ember, Svelte & more!

Build bulletproof UI components faster Storybook is a development environment for UI components. It allows you to browse a component library, view the

Storybook 75.9k Jan 9, 2023