1.0.0-beta.5
Pre-releaseBeta Five 🖐
It's time for another beta release for AVA 1.0. As you may recall we're now using Babel 7, so whilst Babel is in beta, so is AVA. You may want to read the previous release notes to get up to speed.
And despite the release saying Beta, you really should be using this version. There won't be any fixes for the 0.x
releases. Just be sure to install an exact dependency, as SemVer doesn't really apply to these betas:
$ npm install --save-dev --save-exact ava@next
Babel updates ✨ a5de369
AVA now supports [email protected]
. There've been significant changes to Babel's config resolution, both in beta 45 and in earlier releases. As you may be aware, AVA tries hard to detect when your Babel config changes, or when you update your plugins and presets. It's proven too difficult to maintain our existing code path for this. With this release we're using Babel's new APIs to construct AVA's Babel configuration, but unfortunately this has caused drastic regressions in our ability to invalidate AVA's precompilation cache.
For now, when you update your Babel config, plugins or presets, first reset AVA's cache. Luckily we've made this a lot easier:
$ npx ava --reset-cache
We have some ideas on how to detect most changes like we did before. Please join us in #1817 if you want to help.
Babel now supports babel.config.js
files. We're looking for help to update our documentation, add integration tests and ensure we use that configuration file by default. Come join #1816 to help out.
AVA now applies the ava/stage-4
preset last. If you're customizing or disabling the ava/stage-4
preset, you must do so in the testOptions
configuration. AVA now also supports Babel configurations that exclude specific files from compilation.
Configurable test & helper file extensions 🎈 3533aba
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
:
{
"ava": {
"babel": {
"extensions": ["js", "jsx"]
}
}
}
Or define generic extensions, e.g. for use with TypeScript:
{
"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
.
Introducing ava.config.js
🍹 16f4742
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 #1820.
Optional catch
binding ⚾️ ad2d96d
The Optional catch
binding proposal just reached stage 4 in the TC39 process. You can use it in AVA today 🎉
try {
t.truthy(someFunc());
} catch { /* ignore */ }
t.throws()
supports a code
expectation 🍯 179f26a
Node.js' built-in errors come with a code
property. You can now easily test for them:
t.throws(() => {
fs.readFileSync('./example.txt');
}, {code: 'EACCES'});
Other breaking changes 💥
- Test implementations are now called with
null
as thethis
value. a681ecf - All reporters write to
stdout
. Thestdout
andstderr
output from workers is written toprocess.stderr
. AVA will insert linebreaks inprocess.stdout
after writing a chunk toprocess.stderr
that does not end in a line break. 57d180a - 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 thecache
configuration option. 8c9c474 ebb3948
Other changes 🚲
- AVA now uses its own Chalk instance, so AVA's color settings no longer impact the code you're testing. 2bd570e
- Error serialization has been made smarter, especially if non-Error errors are encountered. 0dc141d
- Uncaught exceptions and unhandled rejections are now shown with a code excerpt. 57d180a
- In watch mode, files being rerun are now excluded from the previous failure count. 57d180a
- You should see fewer repeated test timeout messages. d8349f5
- Better compatibility with recent Flow versions. a76d462
All changes 📚
Thanks 💌
💖 Huge thanks to @emilyschultz, @hallettj, @isnifer, @Jaden-Giordano, @good-idea and @jamiebuilds 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.