ava

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

MIT License

Downloads
1.2M
Stars
20.6K
Committers
326

Bot releases are hidden (Show)

ava - 3.1.0

Published by novemberborn over 4 years ago

AVA can now load pre-compiled TypeScript files!

First, install the new @ava/typescript package:

npm install --save-dev @ava/typescript

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

Thanks to @jhechtf for fixing our TypeScript recipe after the changes in AVA 3.0 91a00864f7f113dd63a2c4ecc383fc8c45f79665

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

ava - 3.0.0

Published by novemberborn over 4 years ago

We're proud to introduce AVA 3! 🚀

When we began AVA, JavaScript was very different. Most syntax you find familiar today was not supported by Node.js. Instead we relied on Babel to support that syntax before it made its way to Node.js itself.

These days most new stage-4 syntax is adopted quickly. It's often not necessary to transpile anything. Therefore we're removing our built-in Babel support from AVA itself.

Without Babel you'll have to resort to using require() functions in your JavaScript files. But, you say, Node.js 13 supports ECMAScript Modules!

Well, we're getting there. For a start, AVA now also looks for .cjs files. And .mjs files are recognized too, but can't be loaded just yet. This also impacts ava.config.js files. If you'd like to help out delivering full .mjs support check out the issues in the ESM support project.

Removing Babel allowed us to simplify how test files are selected. Likely non-test files, inside "fixture" or "helper" directories are ignored. The same for files that are inside an underscore-prefixed directory. We've made some other breaking changes in this area so please do read the full release notes.

You can again pass glob patterns on the CLI. However these now filter the test files that AVA already selected based on the configuration. In other words you can't run files that wouldn't be run by invoking npx ava.

AVA now interrupts your tests if there's no progress for 10 seconds. Use the timeout configuration or --timeout CLI option to change this.

New features

Built-in debug mode

You can now debug individual test files using the V8 Inspector:

npx ava debug test.js

Connect to the debugger with Chrome DevTools. Or set up a debugger in VSCode.

Configurable Node.js arguments

You can now configure the arguments passed to Node.js itself when AVA starts its worker processes. Use the nodeArguments configuration or combine with the --node-arguments CLI option.

All breaking changes

Supported Node.js versions

We now support Node.js 10, 12 and 13. The minimal versions are 10.18.0, 12.14.0 and 13.5.0 respectively.

Removing Babel

Utilize Babel with AVA by installing our @ava/babel package and then enabling Babel by setting babel: true in the AVA configuration. Having this as a separate package means it can evolve independently.

The compileEnhancements setting has been moved into the babel configuration. Consequently, the t.assert() assertion will only print its detailed information when you use Babel. And we won't be able to catch typical mistakes with t.throws() as well as we could before.

The ava/stage-4 preset is now available from @ava/babel/stage-4. Our old @ava/babel-preset-transform-test-files and @ava/babel-preset-stage-4 packages are no longer maintained and not installed with AVA itself.

ECMAScript Module Support

AVA now also looks for .cjs and .mjs test files. That said, .mjs files cannot be loaded just yet.

Also, when you add "type": "module" , AVA would really like to treat .js files as ECMAScript Modules, but can't just yet.

Similarly,ava.config.cjs configuration files are now supported. ava.config.mjs files not just yet.

With AVA 2, we loaded ava.config.js files using the esm package. To avoid confusion between the different module formats we now only support export default statements. No import, no __filename. Configuration files that have dependencies should be written as a .cjs file for now.

Configuration files can only have .cjs, .js and .mjs extensions.

The remaining work is tracked in the ESM support project.

File selection

When you use the default configuration AVA will no longer select files matching the following glob patterns:

  • **/__tests__/**/__helper__/**/*
  • **/__tests__/**/__helpers__/**/*
  • **/__tests__/**/__fixture__/**/*
  • **/__tests__/**/__fixtures__/**/*
  • **/test/**/helper/**/*
  • **/test/**/helpers/**/*
  • **/test/**/fixture/**/*
  • **/test/**/fixtures/**/*
  • **/tests/**/helper/**/*
  • **/tests/**/helpers/**/*
  • **/tests/**/fixture/**/*
  • **/tests/**/fixtures/**/*

Additionally, when a file has a parent directory that starts with a single underscore, it can never be a test file.

test.js files are only selected if they're next to the package.json file, or inside top-level src and source directories.

We've removed the configuration of helpers. Previously, files selected by the helpers glob patterns were never considered test files. Now that this configuration is no longer supported you'll need to ensure the files patterns exclude your helper files. If you're using Babel, you can configure the compilation of additional files .

The sources configuration has also been removed. Instead, use the ignoredByWatcher configuration. Changes to files matched by these glob patterns will not cause the watcher to rerun tests.

Negated sources patterns must be used without the negation in ignoredByWatcher:

 export default {
-  sources: ['!examples/**/*']
+  ignoredByWatcher: ['examples/**/*']
 }

CLI changes

Internally we've replaced meow by yargs. We're not expecting things to break because of this, but you never know.

Resetting the cache

The --reset-cache argument has been replaced by a proper reset-cache command:

npx ava reset-cache

File selection (again!)

AVA again accepts glob patterns via the CLI:

npx ava '**/api/**/*'

The way this work is that AVA first finds all test files, according to the configuration, and then filters to select just the files that also match the glob patterns passed via the CLI.

You can still pass paths to specific files:

npx ava src/api/test/my-api-test.js

However unlike with AVA 2, you can no longer specify test files that aren't already selected by AVA's configuration.

t.throws() and t.throwsAsync() assertions

The second argument passed to these assertions must now be an expectation object. You can no longer pass the expected constructor, error message or regular expression.

Other breaking changes

  • Support for old esm versions has been removed.
  • We've set a default test timeout of 10 seconds. This means that if no test results are received for 10 seconds, AVA forces its worker processes to quit.
  • The NODE_PATH environment variable is no longer rewritten to ensure values are absolute paths.
  • AVA longer fakes the TTY in worker processes.

Other changes

  • We've simplified how we identify observables. Any object returned by a test implementation that has a subscribe function is assumed to be an observable. AVA's type definition has been updated accordingly.
  • The TAP reporter now reports hook failures as test failures.
  • We've added an example of module path mapping to our TypeScript recipe.
  • We've added a Selenium WebDriver JS recipe.

All changes

https://github.com/avajs/ava/compare/v2.4.0...v3.0.0

Thanks

Thank you @tymfear, @HeathNaylor, @grnch, @alexdrans, @MoppetX, @jimmywarting, @micaelmbagira, @aptester, @theashraf, @sramam and @maximelkin. We couldn't have done this without you!

ava - 3.0.0 Beta 2

Published by novemberborn almost 5 years ago

We've been busy building AVA 3. It comes with a fair amount of breaking changes but also some exciting features, like a built-in debug mode!

You can install the latest beta today:

npm install -D -E ava@next

This is the second beta release. It addresses the known issues from the first beta.

Please read the 3.0.0 Beta 1 release notes first

Fixes

  • t.assert() once again counts as a passed assertion
  • --update-snapshots works again
  • console and process are available in ava.config.js files

Enhancements

All changes

https://github.com/avajs/ava/compare/v3.0.0-beta.1...v3.0.0-beta.2

Thanks

Thank you @aptester, @theashraf and @sramam. We couldn't have done this without you!

ava - 3.0.0 Beta 1

Published by novemberborn almost 5 years ago

We've been busy building AVA 3. This is the first beta release. It comes with a fair amount of breaking changes but also some exciting features, like a built-in debug mode!

That said there are some known issues:

You can install the latest beta today:

npm install -D -E ava@next

Breaking changes

Removing Babel

When we began AVA, JavaScript was very different. Most syntax you find familiar today was not supported by Node.js. Instead we relied on Babel to support that syntax before it made its way to Node.js itself.

These days most new stage-4 syntax is adopted quickly. It's often not necessary to transpile anything. Therefore we're removing our built-in Babel support.

Instead you can utilize Babel with AVA by installing our @ava/babel package and then enabling Babel by setting babel: true in the AVA configuration. Having this as a separate package means it can evolve independently.

The compileEnhancements setting has been moved into the babel configuration. Consequently, the t.assert() assertion will only print its detailed information when you use Babel. And we won't be able to catch typical mistakes with t.throws() as well as we could before.

The ava/stage-4 preset is now available from @ava/babel/stage-4. Our old @ava/babel-preset-transform-test-files and @ava/babel-preset-stage-4 packages are no longer maintained and not installed with AVA itself.

ECMAScript Module Support

Without Babel you'll have to resort to using require() functions in your JavaScript files. But, you say, Node.js 13 supports ECMAScript Modules!

Well, we're getting there. For a start, AVA now also looks for .cjs and .mjs test files. That said, .mjs files cannot be loaded just yet.

Also, when you add "type": "module" , AVA would really like to treat .js files as ECMAScript Modules, but can't just yet.

Similarly,ava.config.cjs configuration files are now supported. ava.config.mjs files not just yet.

With AVA 2, we loaded ava.config.js files using the esm package. To avoid confusion between the different module formats we now only support export default statements. No import, no __filename. Configuration files that have dependencies should be written as a .cjs file for now.

Configuration files can only have .cjs, .js and .mjs extensions.

The remaining work is tracked in the ESM support project.

File selection

Removing Babel allowed us to simplify how test files are selected. First of all, when you use the default configuration AVA will no longer select files matching the following glob patterns:

  • **/__tests__/**/__helper__/**/*
  • **/__tests__/**/__helpers__/**/*
  • **/__tests__/**/__fixture__/**/*
  • **/__tests__/**/__fixtures__/**/*
  • **/test/**/helper/**/*
  • **/test/**/helpers/**/*
  • **/test/**/fixture/**/*
  • **/test/**/fixtures/**/*
  • **/tests/**/helper/**/*
  • **/tests/**/helpers/**/*
  • **/tests/**/fixture/**/*
  • **/tests/**/fixtures/**/*

Additionally, when a file has a parent directory that starts with a single underscore, it can never be a test file.

test.js files are only selected if they're next to the package.json file, or inside top-level src and source directories.

We've removed the configuration of helpers. Previously, files selected by the helpers glob patterns were never considered test files. Now that this configuration is no longer supported you'll need to ensure the files patterns exclude your helper files. If you're using Babel, you can configure the compilation of additional files .

The sources configuration has also been removed. Instead, use the ignoredByWatcher configuration. Changes to files matched by these glob patterns will not cause the watcher to rerun tests.

Negated sources patterns must be used without the negation in ignoredByWatcher:

 export default {
-  sources: ['!examples/**/*']
+  ignoredByWatcher: ['examples/**/*']
 }

CLI changes

Internally we've replaced meow by yargs. We're not expecting things to break because of this, but you never know.

Resetting the cache

The --reset-cache argument has been replaced by a proper reset-cache command:

npx ava reset-cache

File selection (again!)

AVA again accepts glob patterns via the CLI:

npx ava '**/api/**/*'

The way this work is that AVA first finds all test files, according to the configuration, and then filters to select just the files that also match the glob patterns passed via the CLI.

You can still pass paths to specific files:

npx ava src/api/test/my-api-test.js

However unlike with AVA 2, you can no longer specify test files that aren't already selected by AVA's configuration.

t.throws() and t.throwsAsync() assertions

The second argument passed to these assertions must now be an expectation object. You can no longer pass the expected constructor, error message or regular expression.

Supported Node.js versions

We now support Node.js 10, 12 and 13. The minimal versions are 10.18.0, 12.14.0 and 13.5.0 respectively.

Other breaking changes

  • Support for old esm versions has been removed.
  • We've set a default test timeout of 10 seconds. This means that if no test results are received for 10 seconds, AVA forces its worker processes to quit.
  • The NODE_PATH environment variable is no longer rewritten to ensure values are absolute paths.
  • AVA longer fakes the TTY in worker processes.

Built-in debug mode

You can now debug individual test files using the V8 Inspector:

npx ava debug test.js

Connect to the debugger with Chrome DevTools. Or set up a debugger in VSCode.

Other changes

  • We've simplified how we identify observables. Any object returned by a test implementation that has a subscribe function is assumed to be an observable. AVA's type definition has been updated accordingly.
  • The TAP reporter now reports hook failures as test failures.
  • We've added an example of module path mapping to our TypeScript recipe.

All changes

https://github.com/avajs/ava/compare/v2.4.0...v3.0.0-beta.1

Thanks

Thank you @tymfear, @HeathNaylor, @grnch, @alexdrans, @MoppetX, @jimmywarting and @micaelmbagira. We couldn't have done this without you!

ava - 2.4.0

Published by novemberborn about 5 years ago

Experimental t.try() assertions

Thanks to the amazing work and patience of @qlonik we're shipping a new assertion! t.try() lets you perform assertions and decide whether to commit or discard their outcome. All kinds of interesting things can be built on top of this, from fuzzy testers to new test interfaces and more.

We're excited to get this out there, but it's not quite done yet. For now you have to opt in to this new feature. Being opt-in, we may make changes (breaking ones even!) until we feel this is stable.

To opt in, configure AVA with the following:

package.json:

{
  "ava": {
    "nonSemVerExperiments": {
      "tryAssertion": true
    }
  }
}

ava.config.js:

export default {
	nonSemVerExperiments: {
		tryAssertion: true
	}
};

We'd love to hear your feedback. Please join us in this issue: https://github.com/avajs/ava/issues/2250

Also, if you're looking to help out with the remaining issues so that we can ship this without the opt-in, have a look at this project: https://github.com/orgs/avajs/projects/1

Thanks again @qlonik!

Other changes

  • We've added the common pitfall of sharing variables across asynchronous tests 49b202fb5c376e71c1400f6c35043280cf417140
  • We've updated the endpoint testing recipe to focus on the concept, not specific libraries 67e4deac2857503e5fac7d38da2d23014eb29724

All changes

v2.3.0...v2.4.0

Thanks

Thank you @jeremenichelli, @jamesgeorge007, @dongjae93, @qlonik and @tryzniak. We couldn't have done this without you!

Get involved

We welcome new contributors. AVA is a friendly place to get started in open source. We have a great article on getting started contributing and a comprehensive contributing guide.

ava - 2.3.0

Published by novemberborn about 5 years ago

Changes

  • We've fixed some bugs to improve watch mode. ffa62ce94dec43f18a0c66623fa604036ef8dc48 9e8d28f4408b2e218e6a315d454dd68f66351351
  • AVA now prints an error when it receives non-existent test files on the command line. f01d05f0c8373ff3fe8134364031fb36cba2850e
  • When using the TAP reporter, remaining tests are now included in failed test count. Failed hooks are no longer treated as test failures, and logs are printed. 8628976e1ddd8fea2ff8177f8ab47c80410b424f
  • Internal errors that may occur for some edge cases are now printed. b27cb8d538c58743ba3f5d46e0523e7a0ca5982c
  • TTY in the worker processes should follow the new APIs in Node.js 12.7.0 (when used with those Node.js versions). 7dcb473d90d9415c691da90df75a0452d846cc29
  • AVA now handles stage-4 syntax like dynamic import, and stage-3 syntax like BigInt, numeric separators and class properties that are supported by V8. 9baca8ca4dcbf9512c1f7a33adaeedd37fc8eda2
  • AVA now supports dynamic import through our stage-4 preset.
  • AVA now uses import-local@^3.0.2 which fixes issues with Lerna projects.
  • For our TypeScript users, we've changed the default type of t.context to unknown, in line with TypeScript's changes in their 3.5 release. 2fc7d56475ca1d77078abc3e08390341bedda58f

All changes

v2.2.0...v2.3.0

Thanks

Thank you @MarchWorks, @yovasx2 and @bobthekingofegypt. We couldn't have done this without you!

Get involved

We welcome new contributors. AVA is a friendly place to get started in open source. We have a great article on getting started contributing and a comprehensive contributing guide.

ava - 2.2.0

Published by novemberborn over 5 years ago

Enhancements

You can now specify an alternative config file, using the --config CLI argument. This is useful if you want to run unit tests separately from integration tests, since you can have a config file specific to your integration tests which specifies different glob patterns. 2dae2bfaf4b4ae53700fa439f34923b5a2c35a83

Bug fixes

We're now faking the new hasColors() method for better compatibility with Node.js 12. d3997971a42a6c8e5599d16c8c457c792ce943c6

Node.js 11

We've removed Node.js 11 from our test matrix. You should upgrade to Node.js 12. 90acbb93ca0d92aeedd2b8101a3692ef3b864dc7

All changes

v2.1.0...v2.2.0

Thanks

Thank you @langri-sha, @keyspress, @cdaringe and @okyantoro. We couldn't have done this without you!

Get involved

We welcome new contributors. AVA is a friendly place to get started in open source. We have a great article on getting started contributing and a comprehensive contributing guide.

ava - 2.1.0

Published by novemberborn over 5 years ago

Bug fixes

  • AVA's TypeScript definition now explicitly references the Node.js definition bb44da714bf8c1d7f18ae581aeb292b3cd0d0cf0

Enhancements

  • Did you know you can provide human-readable timeout values? We've now documented this. 486acaf41aa632a2672722f62bc4edfa55a2931c
  • We're now including all stack trace lines in the TAP output (though we still pre-process them). ac212ba1a16d3506bbd8362c511fb3fa00253e17
  • Logs from successful hooks are now included in the TAP output. 007c7af55a65983cb2ebd6170f31b43f468216ea
  • Our ESLint plugin helper has been updated to allow extensions and glob patterns to be overridden b3c9ea7161bd94b77f3ca25b9a51d9d9c402741b

All changes

v2.0.0...v2.1.0

Thanks

Thank you @anishkny, @yovasx2 and @mihai-dinu. We couldn't have done this without you!

Get involved

We welcome new contributors. AVA is a friendly place to get started in open source. We have a great article on getting started contributing and a comprehensive contributing guide.

ava - 2.0.0

Published by novemberborn over 5 years ago

Breaking changes

AVA now requires at least Node.js 8.9.4

Per the Node.js release schedule, the 6.x releases reach end of live on April 30th. Consequently we've removed support in AVA. We are now testing with Node.js 12 though. 3a4afc6cf35aeffb6b019c6b75fa9b8e071bb53d

Test file and helper selection

We've been working on simplifying how test files and helpers are selected. First off, the files option now only accepts glob patterns. If you configured it with directories before, please add /**/* to get the previous behavior.

The files and sources options must now be arrays containing at least one pattern. It's no longer possible to override a default exclusion pattern, but we're looking at making these configurable separately.

AVA used to treat all files inside a helpers directory as test helpers. Finding these files could be really slow, however, and it also meant you couldn't have tests inside a helpers directory. Instead you can now specify glob paterns to find these helpers:

{
  "ava": {
    "helpers": [
      "**/helpers/**/*"
    ]
  }
}

Test files starting with an underscore are still recognized as helpers.

Files inside fixtures directories are no longer ignored, and will now be treated as test files. The watcher now also watches ava.config.js files.

AVA now also selects files ending with .spec.js when looking for tests, as well as looking in tests directories. 08e99e516e13af75d3ebe70f12194a89b610217c b1e54b1a02ba7220571a06e4d324d460ea7ece54

The CLI now only takes file paths, not glob patterns.

We'd like some help updating our ESLint plugin as well.

Snapshots in CI

When you run tests locally and add a new snapshot, AVA automatically updates the .snap file. However if you forget to commit this file and then run your CI tests, they won't fail because AVA quietly updates the .snap file, just like it does locally.

With this release, AVA will fail the t.snapshot() assertion if it is run in CI and no snapshot could be found. 0804107b49ef3bb43656cd48d27b0d54ea080d71

Assertion messages must be strings

AVA now enforces assertion messages to be strings. The message is only used when the assertion fails, and non-string values may cause AVA to crash. You may see test failures if you were accidentally passing a non-string message. 49120aafd40c96bbe8196d3da8898d05006588d8

Flow type definitions

We've decided to remove the Flow type definitions from AVA itself. We don't have anybody to maintain them and consequently they've become a blocker when adding features to AVA. c633cf08891abaf7649d490642eef38b8150bfe0

We've set up a new repository from which we'll publish the definitions, but we need your help setting it up. If you use AVA and Flow, please join us in https://github.com/avajs/flow-typed/issues/1.

Observable typing

Test implementations may return observables. We've updated our TypeScript definition to require these to have a Symbol.observable function. c2d8218ba78b26fe1368df183924757cd27555e4

New features

Configurable printing depth

AVA now uses the util.inspect.defaultOptions.depth option when printing objects, so you can configure the depth. 98034fbb661bcc6cb882e1ae007a7877a803b3a4

Specify environment variables in your AVA config

You can now specify environment variables in your config, using the environmentVariables object. a53ea157367c9cec91184cfbb226487c81229513

Other changes

  • We've added UntitledMacro and UntitledCbMacro types, for macro functions that will never have a .title function. Though really this just helped simplify the type definition. Thanks @qlonik! ebf480779b826dcccc86376caf8ca5af4273e912
  • The dependency tracking in watch mode now respects custom require hooks you install in the worker processes. Thanks @lo1tuma! cb4c8095952a970fb9bf5d1620810d5e172080ae
  • The TypeScript definition once again allows test.skip(macro) ba5cd804845517b1a5c4b04d1c08253ef27133d3
  • AVA now exposes some methods to our ESLint plugin, allowing our plugin to support the new test & helper file selection. 51433bed947d31e5f3df26bdf6eee10ad4344efa

All changes

v1.4.1...v2.0.0

Thanks

Thank you @StoneCypher, @LukasHechenberger, @lo1tuma, @htor, @alexisfontaine and @grnch. We couldn't have done this without you!

Get involved

We welcome new contributors. AVA is a friendly place to get started in open source. We have a great article on getting started contributing and a comprehensive contributing guide.

ava - 2.0.0 Release Candidate 1

Published by novemberborn over 5 years ago

⚠️ If you're looking to upgrade from 1.4.1, make sure to read the Beta 1 and Beta 2 release notes.

Support for the new test & helper file selection in our ESLint plugin

AVA now exposes some methods to our ESLint plugin, allowing our plugin to support the new test & helper file selection. 51433bed947d31e5f3df26bdf6eee10ad4344efa

Configurable object printing depth

AVA now uses the util.inspect.defaultOptions.depth option when printing objects. 98034fbb661bcc6cb882e1ae007a7877a803b3a4

All changes

v2.0.0-beta.2...v2.0.0-rc.1

Thanks

Thank you @grnch. We couldn't have done this without you!

Get involved

We welcome new contributors. AVA is a friendly place to get started in open source. We have a great articleon getting started contributing and a comprehensive contributing guide.

ava - 2.0.0 Beta 2

Published by novemberborn over 5 years ago

⚠️ If you're looking to upgrade from 1.4.1, make sure to read the Beta 1 release notes.

Breaking changes

  • Test implementations may return observables. We've updated our TypeScript definition to require these to have a Symbol.observable function. c2d8218ba78b26fe1368df183924757cd27555e4

Test file and helper selection

AVA now also selects files ending with .spec.js when looking for tests. 08e99e516e13af75d3ebe70f12194a89b610217c

You can now specify custom globs to select helper files:

{
  "ava": {
    "helpers": [
      "**/helpers/**/*"
    ]
  }
}

Bugfixes

  • The dependency tracking in watch mode now respects custom require hooks you install in the worker processes. Thanks @lo1tuma! cb4c8095952a970fb9bf5d1620810d5e172080ae
  • The TypeScript definition once again allows test.skip(macro) ba5cd804845517b1a5c4b04d1c08253ef27133d3

All changes

v2.0.0-beta.1...v2.0.0-beta.2

Thanks

Thank you @StoneCypher, @LukasHechenberger, @lo1tuma, @htor and @alexisfontaine. We couldn't have done this without you!

Get involved

We welcome new contributors. AVA is a friendly place to get started in open source. We have a great articleon getting started contributing and a comprehensive contributing guide.

ava - 2.0.0 Beta 1

Published by novemberborn over 5 years ago

Breaking changes

AVA now requires at least Node.js 8.9.4

Per the Node.js release schedule, the 6.x releases reach end of live on April 30th. Consequently we've removed support in AVA. We are now testing with Node.js 12 though. 3a4afc6cf35aeffb6b019c6b75fa9b8e071bb53d

Test file and helper selection

We've been working on simplifying how test files and helpers are selected. First off, the files option now only accepts glob patterns. If you configured it with directories before, please add /**/* to get the previous behavior.

The files and sources options must now be arrays containing at least one pattern. It's no longer possible to override a default exclusion pattern, but we're looking at making these configurable separately.

AVA used to treat all files inside a helpers directory as test helpers. Finding these files could be really slow, however, and it also meant you couldn't have tests inside a helpers directory. Instead we're going to let you specify glob patterns to find these helpers. That work hasn't landed yet. For now, if you have such helpers we'd advise to not upgrade to this release.

Test files starting with an underscore are still recognized as helpers.

Files inside fixtures directories are no longer ignored, and will now be treated as test files. The watcher now also watches ava.config.js files.

The CLI now only takes file paths, not glob patterns.

We'd like some help updating our ESLint plugin as well.

Snapshots in CI

When you run tests locally and add a new snapshot, AVA automatically updates the .snap file. However if you forget to commit this file and then run your CI tests, they won't fail because AVA quietly updates the .snap file, just like it does locally.

With this release, AVA will fail the t.snapshot() assertion if it is run in CI and no snapshot could be found. 0804107b49ef3bb43656cd48d27b0d54ea080d71

Assertion messages must be strings

AVA now enforces assertion messages to be strings. The message is only used when the assertion fails, and non-string values may cause AVA to crash. You may see test failures if you were accidentally passing a non-string message. 49120aafd40c96bbe8196d3da8898d05006588d8

Flow type definitions

We've decided to remove the Flow type definitions from AVA itself. We don't have anybody to maintain them and consequently they've become a blocker when adding features to AVA. c633cf08891abaf7649d490642eef38b8150bfe0

We've set up a new repository from which we'll publish the definitions, but we need your help setting it up. If you use AVA and Flow, please join us in https://github.com/avajs/flow-typed/issues/1.

Other changes

  • We've added UntitledMacro and UntitledCbMacro types, for macro functions that will never have a .title function. Though really this just helped simplify the type definition. Thanks @qlonik! ebf480779b826dcccc86376caf8ca5af4273e912

All changes

v1.4.1...v2.0.0-beta.1

Get involved

We welcome new contributors. AVA is a friendly place to get started in open source. We have a great article on getting started contributing and a comprehensive contributing guide.

ava - 1.4.1

Published by novemberborn over 5 years ago

Focusing power-assert

AVA comes with power-assert built-in, giving you more descriptive assertion messages. However it's been confusing to understand which assertions come with power-assert. To address this we've added the new t.assert() assertion. It's now the only assertion that is power-assert enabled. The assertion passes if called with a truthy value. Consider this example:

test('enhanced assertions', t => {
	const a = /foo/;
	const b = 'bar';
	const c = 'baz';
	t.assert(a.test(b) || b === c);
});

Value is not truthy:

false

a.test(b) || b === c
=> false

b === c
=> false

c
=> 'baz'

b
=> 'bar'

a.test(b)
=> false

b
=> 'bar'

a
=> /foo/

Our ESLint plugin has been updated to support this new assertion. Many thanks to @eemed for implementing this! 94064702837583f1cd3920142c5d0ce50e71e255

Watch mode

Watch mode now prints the available commands. Thanks @KompKK! cd256ac53c975d51ddabd3d80a9f909424f5d7e3

Bug fixes

  • Filtered tests (when using --match, .skip() or .only()) are no longer included in the list of pending tests when timeouts occur or when you interrupt a test run. Thanks @vancouverwill! 23e302a8dc35d03ba82916bd6591822a28d499d1
  • We're now shimming all TTY methods in the worker processes, thanks to @okyantoro. c1f6fdfed61c99c1144cff56b58d113810c630c8

Documentation updates

  • We've added a note to say that, by default, AVA does not have a default test timeout. Thanks @amokmen! 99a10a16a3e3037326c91fb23c2a052acd3abef9

All changes

v1.3.1...v1.4.1

Thanks

Thank you @eemed, @KompKK, @vancouverwill, @okyantoro and @amokmen. We couldn't have done this without you!

Get involved

We welcome new contributors. AVA is a friendly place to get started in open source. We have a great article on getting started contributing and a comprehensive contributing guide.

ava - 1.3.1

Published by novemberborn over 5 years ago

Bug fixes

  • We've fixed a rather embarrasing bug with t.throws() and t.throwsAsync(). If you'd set a code expectation to a number we never actually checked that the thrown error had such a code! Thanks to @qlonik for both spotting and fixing this. 82daa5e373ef0587693927acc63ce5590e8d8eb2
  • 1.2.0 contained a regression which meant that if you faked clearTimeout(), you'd break AVA. That's now been fixed. 40f331c27e70690e724f9ddc893fed0556058987
  • Snapshot files are now recognized as source files, so if you're using watch mode and you delete one, AVA won't rerun all your test files. d066f6fbc06ab2fa2d391ff373f5f09b2585b900

New features

You can now use require() in ava.config.js files to load non-ES modules. 334e15b4af06492c9aed2800a0764f245d6a908b

All changes

v1.2.1...v1.3.1

Thanks

Thank you @itaisteinherz, @jdalton, @kagawagao, @KompKK, @SleeplessByte, @Chrisyee22 and @qlonik for helping us with this release. We couldn't have done this without you!

Get involved

We welcome new contributors. AVA is a friendly place to get started in open source. We have a great article on getting started contributing and a comprehensive contributing guide.

ava - 1.2.1

Published by novemberborn over 5 years ago

This is a bug fix release. In very large projects, the options send to worker processes would exceed limits on process argument size. We're now sending the options via the inter-process communication channel. 3078892236c4f78409cc8475ed88f07d1141c0f0

All changes 📚

v1.2.0...v1.2.1

Get involved ✌️

We welcome new contributors. AVA is a friendly place to get started in open source. We have a great article on getting started contributing and a comprehensive contributing guide.

ava - 1.2.0

Published by novemberborn over 5 years ago

New features

You can now set a timeout for test themselves. The test will fail if this timeout is exceeded. The timeout is reset each time an assertion is made:

test('foo', t => {
	t.timeout(100); // 100 milliseconds
	// Write your assertions here
});

b65c6d7da8ba3c7274f36dbcbcff26485f27d36f

AVA also has a global timeout feature. The mini reporter now logs tests that were pending when those timeouts occur. Additionally, if you interrupt a test using ctrl+c we'll now also show the pending tests. 2b60556360bb3b434ee5b4bb3486acb8a32b7aa7

Thank you @dflupu for your hard work on this!

Bug fixes and other improvements

  • We're no longer truncating multi-line error messages 72e0762d9accb937b7b32f9151fe4088d194c710
  • Unexpected errors in the throws assertions are now reported with the correct stack trace ad087f250fe22878ab40f7855a079cf005818464
  • The Debugging with VSCode recipe has been updated with the correct workspaceFolder variable 0a5fe429ca37c025a15c5af919827436cc413abc and --serial argument placement edfc0055fea4fc204ac98c391baaa2ad60b41079

All changes 📚

v1.1.0...v1.2.0

Thanks 💌

💖 Huge thanks to @anishkny, @CrispusDH, @dflupu and @niktekusho for helping us with this release. We couldn’t have done it without you!

Get involved ✌️

We welcome new contributors. AVA is a friendly place to get started in open source. We have a great article on getting started contributing and a comprehensive contributing guide.

ava - 1.1.0

Published by novemberborn almost 6 years ago

New features

AVA now exports a meta object. Currently, you can retrieve the path of the test file being run:

import test from 'ava';

console.log('Test currently being run: ', test.meta.file);
import {meta} from 'ava';

console.log('Test currently being run: ', meta.file);

This is useful in helpers that need to know the test file. bccd297f38c9f4cf6dbb16dffa7ee8753dbbd12f

Bug fixes and other improvements

  • t.log() now works in hooks d1877122cea7ce54455d9dcc2bca046612dbd628

  • Error output for improper usage of t.throws() once again links to the correct documentation dc552bcb57181d9b6d9c39711013f9813ddc2c51

  • We've added a section on webpack aliases to the Babel recipe c3bcbf2a568c12017fe0da041dc247a226019001

  • We've updated the Vue recipe for Babel 7, and added a section on webpack aliases c3bcbf2a568c12017fe0da041dc247a226019001

All changes 📚

v1.0.1...v1.1.0

Thanks 💌

💖 Huge thanks to @fitztrev, @forresst, @astrob0t, @pearofducks, @coreyfarrell and @dflupu for helping us with this release. We couldn’t have done it without you!

Get involved ✌️

We welcome new contributors. AVA is a friendly place to get started in open source. We have a great article on getting started contributing and a comprehensive contributing guide.

ava - 1.0

Published by novemberborn almost 6 years ago

AVA 1.0 🚀

Back in January we started work on the 1.0 release, taking the opportunity to upgrade to Babel 7 and follow its beta releases. It's been a year where we made massive improvements to AVA. It's also been a year with many exciting events in our personal lives. Be it honeymoons & weddings, work & friends, naturalizations and international relocations.

So, we're done. Or, rather, we're just beginning. Testing can be a drag. AVA helps you get it done. Its concise API, detailed error output, embrace of new language features and process isolation let you write tests more effectively. So you can ship more awesome code or do non-programming things.

Starting now we'll push out patches and new features more regularly. And, when the time comes, ship a 2.0 and a 3.0 and so forth. If you like what we're doing, why not try and contribute? We're a friendly bunch and we could use your help to make AVA even better.

We couldn't have gotten here without the nearly one hundred people who've contributed more, and the many more who suggested improvements, reported bugs and provided feedback. And, of course, everyone who's used AVA. Thank you for your enthusiasm and support.

Mark & Sindre

What's new & improved

Assertions

New t.throws() behavior & t.throwsAsync()

We've rewritten t.throws() so it behaves better, has better error output and lets you write better tests:

  • The assertion takes a first thrower argument. It must throw an exception, or your test fails. Throwing other values like strings also causes your test to fail.
  • The exception must be an error object.
  • The assertion returns the exception.

You have a few ways of asserting that the exception is as designed. You can pass a second argument:

  • If you pass a function it should be a constructor: the exception must be an instance of it. Previously you could pass a validation function. This is no longer possible.
  • If you pass a string: the exception's message should be equal to it.
  • If you pass a regular expression: the exception's message should match it.

The most exciting new feature though is that you can pass an expectation object. A combination of the following expectations is supported:

t.throws(fn, {code: 'ENOTFOUND'}) // err.code === 'ENOTFOUND'
t.throws(fn, {code: 9}) // err.code === 9
t.throws(fn, {instanceOf: SyntaxError}) // err instanceof SyntaxError
t.throws(fn, {is: expectedErrorInstance}) // err === expectedErrorInstance
t.throws(fn, {message: 'expected error message'}) // err.message === 'expected error message'
t.throws(fn, {message: /expected error message/}) // /expected error message/.test(err.message)
t.throws(fn, {name: 'SyntaxError'}) // err.name === 'SyntaxError'

This makes tests like these much easier to write:

// Old assertion
const err = t.throws(fn, TypeError)
t.is(err.message, 'Expected a string')

// New assertion
t.throws(fn, {
	instanceOf: TypeError,
    message: 'Expected a string'
})

We've removed promise support from t.throws() and t.notThrows(). Use the new t.throwsAsync() and t.notThrowsAsync() assertions instead. Support for observables has been removed completey.

The original behavior was both hard to explain and hard to express in Flow and TypeScript. Now, if you have a function that throws a synchronous error, use t.throws() (or t.notThrows()). If you have a promise that should reject, or an asynchronous function that should fail, use await t.throwsAsync() (or await t.notThrowsAsync()).

Generally speaking, you should be able to replace every occurence of await t.throws with await t.throwsAsync, and await t.notThrows with await t.notThrowsAsync. A transform file for jscodeshift is available in this Gist. Run it like:

$ npx jscodeshift -t https://gist.githubusercontent.com/novemberborn/c2cdc94020083a1cafe3f41e8276f983/raw/eaa64c55dfcda8006fc760054055372bb3109d1c/transform.js test.js

Change test.js to a glob pattern that matches your test files. See the jscodeshift CLI usage documentation for further details.

Bound assertion methods

Assertion methods are now bound to the test, meaning you can provide them as direct arguments to other functions. A contrived example:

const assertEach = (arr, assert) => {
  arr.forEach(value => assert(value));
};

test('all are true', t => {
  assertEach(getArray(), t.true);
});

Whilst not strictly assertions, t.plan() and t.log() are now also bound to the test.

BigInt

As part of our Node.js 10 support you can now use BigInt values in t.deepEqual() and t.snapshot(). Note that this is still a stage-3 proposal.

Babel 7

AVA now uses Babel 7, with support for babel.config.js files. We'll automatically use your project's Babel configuration. Babel options must now be specified in a testOptions object. This will allow us to add source related options in the future.

Our @ava/stage-4 preset is now accessible via ava/stage-4. We've added transforms for the latest ES2018 features where available (and even an ES2019 one!). You can also disable ava/stage-4 entirely:

package.json:

{
  "ava": {
    "babel": {
      "testOptions": {
        "presets": [
          ["ava/stage-4", false]
        ]
    }
    }
  }
}

Or, you can disable just ES module compilation:

package.json:

{
  "ava": {
    "babel": {
      "testOptions": {
        "presets": [
          ["ava/stage-4", {"modules": false}]
        ]
      }
    }
  }
}

The powerAssert option and command line flags have been removed. You can now disable AVA's test enhancements by setting compileEnhancements to false. You can also disable AVA's Babel pipeline entirely:

package.json:

{
  "ava": {
    "babel": false,
    "compileEnhancements": false
  }
}

Serial hooks and context

Hooks declared using test.serial will now execute serially. Only one of those hooks will run at a time. Other hooks run concurrently. Hooks still run in their declaration order.

Note that concurrent tests run concurrently. This means that .beforeEach() and .afterEach() hooks for those tests may also run concurrently, even if you use test.serial to declare them.

t.context can now be used in .before and .after hooks.

CLI

Pass flags to your test

AVA now forwards arguments, provided after an -- argument terminator, to the worker processes. Arguments are available from process.argv[2] onwards.

npx ava test.js -- hello world

There's a new recipe on how to use this.

Previously AVA populated process.argv[2] and process.argv[3] with some undocumented internal values. These are no longer available.

Resetting AVA's cache

The --no-cache CLI flag has been replaced by a --reset-cache command. The latter resets AVA's regular cache location. You can still disable the cache through the cache configuration option.

npx ava --reset-cache

Configuration

Introducing ava.config.js

You can now configure AVA through an ava.config.js file. It must be placed next to the package.json, and you mustn't have any "ava" options in the package.json file. Export the configuration as a default:

export default {
    babel: {
        extensions: ['js', 'jsx']
    }
};

Or export a factory function:

export default ({projectDir}) => ({
    babel: {
        extensions: ['js', 'jsx']
    }    
});

Following our convention to use ES modules in test files, we're expecting ES modules to be used in the configuration file. If this is causing difficulties please let us know in https://github.com/avajs/ava/issues/1820.

Configurable test & helper file extensions

You can now tell AVA to run test files with extensions other than js! For files that should be compiled using Babel you can specify babel.extensions:

package.json:

{
  "ava": {
    "babel": {
      "extensions": ["js", "jsx"]
    }
  }
}

Or define generic extensions, e.g. for use with TypeScript:

package.json:

{
  "ava": {
    "compileEnhancements": false,
    "extensions": ["ts"],
    "require": [
      "ts-node/register"
    ]
  }
}

Note that AVA still assumes test & helper files to be valid JavaScript. They're still precompiled to enable some AVA-specific enhancements. You can disable this behavior by specifying "compileEnhancements": false.

Snapshots

Adding new snapshots no longer causes the Markdown files to become malformed. Snapshots are now consistent across operating systems. If you've previously generated snapshots on Windows, you should update them using this release.

We now support BigInt and <React.Fragment> in t.snapshot(). We've also improved support for the Symbol.asyncIterator well-known symbol. Unfortunately these changes are not backwards compatible. You'll need to update your snapshots when upgrading to this release.

We've improved how AVA builds snapshot files to better support precompiled projects. Say, if you compile your TypeScript test files using tsc before running AVA on the build output. AVA will now use the source map to figure out the original filename and use that as the basis for the snapshot files. You'll have to manually remove snapshots generated by previous AVA versions.

Type definitions

The TypeScript and Flow definitions have been rewritten and much improved. The TypeScript recipe has been updated to reflect the changes, and there's a new Flow recipe too.

TypeScript

AVA recognizes TypeScript build errors when using ts-node/register.

TypeScript now type-checks additional arguments used by macros. You must type the arguments used:

import test, {Macro} from 'ava'

const failsToParse: Macro<[Buffer]> = (t, input) => {
	t.throws(parse(input))
}

failsToParse.title = (providedTitle = 'unexpected input') => `throws when parsing ${providedTitle}`

test('malformed', failsToParse, fs.readFileSync('fixtures/malformed.txt'))
test(failsToParse, '}') // ⬅️ fails to compile

Other improvements

  • You can now specify helpers — that need to be compiled by AVA — in the require configuration.
  • --fail-fast behavior has been improved. AVA now makes sure not to start new tests. Tests that are already running though will finish. Hooks will also be called. AVA now prints the number of skipped test files if an error occurs and --fail-fast is enabled.
  • AVA now uses its own Chalk instance, so AVA's color settings no longer impact the code you're testing.
  • Error serialization has been made smarter, especially if non-Error errors are encountered.
  • Uncaught exceptions and unhandled rejections are now shown with a code excerpt.
  • You should see fewer repeated test timeout messages.
  • Error messages now link to the documentation appropriate for the version of AVA you're using.
  • AVA now 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.
  • AVA now detects when it's required from a Node.js REPL.
  • We've improved the colors for use on light terminal themes.
  • The assert module in Node.js 10 no longer crashes.
  • Source maps, generated by AVA when compiling test & helper files, now contain correct paths to the source files.
  • TTY support for process.stderr is now emulated in the worker processes.
  • The default reporter now includes files that did not declare any tests in its final output.
  • AVA now prints pending tests when timeouts occur, when using --verbose.
  • <React.Fragment> can be used in t.deepEqual.
  • title functions of macros now receive undefined rather than an empty string if no title was given in the test declaration. This means you can use default parameters.

Breaking changes since 0.25.0

Supported Node.js versions

We've published a statement with regards to which Node.js versions we intend to support. As of this release we're only supporting Node.js 6.12.3 or newer, 8.9.4 or newer, 10.0.0 or newer and 11.0.0 or newer. This does not include Node.js 7 and 9.

Tests must now have titles, and they must be unique

You can no longer do:

test(t => t.pass());

Instead all tests must have titles, and they must be unique within the test file:

test('passes', t => t.pass());

This makes it easier to pinpoint test failures and makes snapshots better too.

Note that AVA no longer infers a test title from a function name:

test(function myTest (t) {
  t.pass();
});

Modifier chaining

AVA's various test modifiers (.serial, .skip) must now be used in the correct order:

  • .serial must be used at the beginning, e.g. test.serial().
  • .only and .skip must be used at the end, e.g. test.skip(). You cannot combine them.
  • .failing must be used at the end, but can be followed by .only and .skip, e.g. test.cb.failing() and test.cb.failing.only().
  • .always can only be used after .after and .afterEach, e.g. test.after.always().
  • .todo() is only available on test and test.serial. No further modifiers can be applied.

Declaring tests

You must declare all tests and hooks at once. This was always the intent but previously AVA didn't enforce it very well. Now, once you declare a test or hook, all other tests and hooks must be declared synchronously. However you can perform some asynchronous actions before declaring your tests and hooks.

test export

We're no longer exporting the test() method as a named export. Where before you could use import {test} from 'ava', you should now write import test from 'ava'.

Set default title using parameters syntax

Macros can generate a test title. Previously, AVA would call the title function with an empty string if no title was given in the test declaration. Now, it'll pass undefined instead. This means you can use default parameters. Here's an example:

import test from 'ava'

const failsToParse = (t, input) => {
	t.throws(parse(input))
}

failsToParse.title = (providedTitle = 'unexpected input') => `throws when parsing ${providedTitle}`

test('malformed', failsToParse, fs.readFileSync('fixtures/malformed.txt'))
test(failsToParse, Buffer.from('}', 'utf8'))

This is a breaking change if you were concatenating the provided title, under the assumption that it was an empty string.

Assertions

t.throws() & t.notThrows()

Thrown exceptions (or rejection reasons) must now be error objects.

t.throws() and t.notThrows() no longer support observables or promises. For the latter, use await t.throwsAsync() and await t.notThrowsAsync() instead.

Generally speaking, you should be able to replace every occurence of await t.throws with await t.throwsAsync, and await t.notThrows with await t.notThrowsAsync. A transform file for jscodeshift is available in this Gist. Run it like:

$ npx jscodeshift -t https://gist.githubusercontent.com/novemberborn/c2cdc94020083a1cafe3f41e8276f983/raw/eaa64c55dfcda8006fc760054055372bb3109d1c/transform.js test.js

Change test.js to a glob pattern that matches your test files. See the jscodeshift CLI usage documentation for further details.

Skipping assertions

Assertions can be skipped by using .skip at the end of the assertion, e.g. t.deepEqual.skip(). You can now safely skip snapshot tests, though not whilst updating snapshots.

t.ifError()

We've removed the t.ifError() assertion. It worked the same as t.falsy(), so if you were using it please switch to t.falsy() instead.

Configuration changes

The source option has been renamed to sources. This is now consistent with files. AVA will exit with an error if it encounters the source option.

We've also removed unintentional support for init, watch and updateSnapshot options.

Babel

The "default" and "inherit" configuration values have been removed. Babel options must now be specified in a testOptions object. This will allow us to add source related options in the future.

The powerAssert option and command line flags have been removed. You can now disable AVA's test enhancements by setting compileEnhancements to false.

The Babel recipe has been updated with the latest details.

Updated type definitions

The TypeScript and Flow definitions have been rewritten. The definitions export different interfaces so you may need to update your test code as well.

TypeScript now type-checks additional arguments used by macros. You must type the arguments used.

Internals

Some other internals have changed. You shouldn't have been relying on these, though if you did we're interested in hearing about it so we can better support your use case.

  • The private t._test value has been removed
  • Some of the communication between the main process and the test workers has changed
  • Access to the options object from inside a worker process has changed

Other potential breaking changes

  • We've removed support for @std/esm, in favor of the plain esm package.
  • The ava/stage-4 preset is applied after all other plugins and presets.
  • Test implementations are now called with null as the this value.
  • All reporters write to stdout. The stdout and stderroutput from workers is written to process.stderr. AVA will insert linebreaks in process.stdout after writing a chunk to process.stderrthat does not end in a line break.
  • The --no-cache CLI flag has been replaced by a --reset-cache command. The latter resets AVA's regular cache location. You can still disable the cache through the cache configuration option.
  • We've dropped support for using generator functions as test implementations. This was a remnant of the dark days before async/await support.
  • Snapshots need to be regenerated.
  • If you pre-compile your test files, the snapshot files may be created at new file paths. You'll have to manually remove any old files.

New recipes

There's a new recipe on using ES modules. We've also added a recipe on setting up tests and how test webapps using AVA and Puppeteer.

All changes 📚

v0.25.0...v1.0.1

Thanks 💌

💖 Huge thanks to @okyantoro, @JasonRitchie, @forresst, @mdvorscak, @kugtong33, @motss, @BusbyActual, @billyjanitsch, @Briantmorr, @jdalton, @malimichael, @martypdx, @clemtrek, @samuelli, @emilyschultz, @hallettj, @isnifer, @Jaden-Giordano, @good-idea, @jamiebuilds, @tobil, @TheDancingCode, @btkostner, @CanRau, @coreyfarrell, @ivanschwarz, @jagoda, @padmaia, @ronen, @sh7dm, @sharkykh, @Phrynobatrachus, @grant37, @xxczaki, @robertbernardbrown, @lo1tuma, @goooseman, @wmik, @vancouverwill, @qlonik, @vlajos and @itskolli for helping us with this release. We couldn’t have done it without you!

Get involved ✌️

We welcome new contributors. AVA is a friendly place to get started in open source. We have a great article on getting started contributing and a comprehensive contributing guide.

ava - 1.0.0-rc.2

Published by novemberborn almost 6 years ago

Release Candidate Two 🎷

Okay then, barring any surprises, the next release is the 1.0. But first, there's some changes we want to get out while we work on the celebratory blog post 😉

Please give this release a try and let us know of any problems. And as always with pre-releases, be sure to install an exact dependency. However unlikely, there may still be breaking changes between now and the final 1.0 release:

npm install --save-dev --save-exact ava@next

Please see the release notes for the previous betas:

Highlights

Better snapshot files for pre-built files

We've improved how AVA builds snapshot files to better support precompiled projects. Say, if you compile your TypeScript test files using tsc before running AVA on the build output. AVA will now use the source map to figure out the original filename and use that as the basis for the snapshot files. You'll have to manually remove snapshots generated by previous AVA versions. a130a9e3d9729e746b1ad9882ffc20de5b434750

Set default title using parameters syntax

Macros can generate a test title. Previously, AVA would call the title function with an empty string if no title was given in the test declaration. Now, it'll pass undefined instead. This means you can use default parameters. Here's an example:

import test from 'ava'

const failsToParse = (t, input) => {
	t.throws(parse(input))
}

failsToParse.title = (providedTitle = 'unexpected input') => `throws when parsing ${providedTitle}`

test('malformed', failsToParse, fs.readFileSync('fixtures/malformed.txt'))
test(failsToParse, Buffer.from('}', 'utf8'))

This is a breaking change if you were concatenating the provided title, under the assumption that it was an empty string. aa35f154e7cd3685f705dd07419f55af7b7440e5

TypeScript now type-checks additional arguments used by macros

When using TypeScript, you must now type the arguments used by the macro 6f54db84199473edcd169059acbd0bebc7427f04:

import test, {Macro} from 'ava'

const failsToParse: Macro<[Buffer]> = (t, input) => {
	t.throws(parse(input))
}

failsToParse.title = (providedTitle = 'unexpected input') => `throws when parsing ${providedTitle}`

test('malformed', failsToParse, fs.readFileSync('fixtures/malformed.txt'))
test(failsToParse, '}') // ⬅️ fails to compile

Bug fixes and other improvements

  • Correctly insert a trailing newline when appending new snapshot entries. bf00d79a39ba447919807081bf20690940fc778d
  • Better error messages when used with esm 37390e6e8fbb911a52838926910973229f7a02af
  • Support Node.js 11 afe028a0a05c8b8bb0b33e12b557ff455e47355d
  • New recipe on how test webapps using AVA and Puppeteer 6ab6d35d9b8c4652a672b804016aa22c9e4f5983

All changes 📚

v1.0.0-rc.1...v1.0.0-rc.2

Thanks 💌

💖 Huge thanks to @forresst, @sh7dm and @qlonik for helping us with this release. We couldn’t have done it without you!

Get involved ✌️

We welcome new contributors. AVA is a friendly place to get started in open source. We have a great article on getting started contributing and a comprehensive contributing guide.

ava - 1.0.0-rc.1

Published by novemberborn about 6 years ago

Release Candidate One 🥁

With this release AVA supports babel.config.js files. We've also improved our cache invalidation when you change your Babel configuration, so we're just about ready to ship the final 1.0 release 🎉

Please give this release a try and let us know of any problems. And as always with pre-releases, be sure to install an exact dependency. There may still be breaking changes between now and the 1.0 release:

$ npm install --save-dev --save-exact ava@next

Please see the release notes for the previous betas:

Highlights

  • babel.config.js support. ff09749e936fb005155fff715b0325a0b02a36c1 We're still looking for some help with updating the documentation, see https://github.com/avajs/ava/issues/1816.
  • Improved Babel cache invalidation. ff5523616d51df77205c0f6a38021937120eced4
  • AVA now prints pending tests when timeouts occur, when using --verbose. 6d12abfdff4478a1b6f4e87237764b89eb05f18d

Deep-equal and (breaking) snapshot changes

We now support BigInt and <React.Fragment> in t.deepEqual() and t.snapshot(). We've also improved support for the Symbol.asyncIterator well-known symbol. Unfortunately these changes are not backwards compatible. You'll need to update your snapshots when upgrading to this release. 71eede72c4984fa7bf8f7655a0088aa5615e8c39

Bug fixes and other improvements

  • profile.js now handles extensions configuration. 30a80b6e2fb90cdb0d7ce9a5878ea985d4ede7bd
  • When using t.throws() with asynchronous functions, AVA now suggests you use t.throwsAsync() instead. f125b4df36ea0e6c552b9ac61278a8fa93521a6e
  • AVA now detects when you attempt to wrap ava.config.js configuration in an ava property. f93b341d2a7c3d7b86f64f366722353f484a4e90

All changes 📚

v1.0.0-beta.8...v1.0.0-rc.1

Thanks 💌

💖 Huge thanks to @grant37, @xxczaki, @jamiebuilds, @robertbernardbrown, @lo1tuma, @goooseman, @wmik and @vancouverwill for helping us with this release. We couldn’t have done it without you!

Get involved ✌️

We welcome new contributors. AVA is a friendly place to get started in open source. We have a great article on getting started contributing and a comprehensive contributing guide.