Releases: avajs/ava
0.18.0
This release is one of the biggest, most feature-packed release we’ve had in a long time. We have prepared lots of tasty things for you - snapshot testing, magic assert, precompiling test helpers, improvements to Babel transpilation, and more. Our team and contributors have been working hard to deliver all this goodness. We can’t wait to hear your feedback and don’t hesitate to suggest new ideas and report bugs!
Highlights
Dropped support for Node.js 0.10 and 0.12
As mentioned in the 0.17.0 release notes, we’re dropping support for Node.js 0.10 and 0.12 in this release. They’re both out of maintenance mode. Time to upgrade!
Magic assert
We completely overhauled the error output to make it as easy and fast as possible to detect the source of the failure. Magic assert, as we call it internally, adds code excerpts and clean diffs for actual and expected values. If values in the assertion are objects or arrays, only a difference is displayed to remove the noise and focus on the problem. Oh, and 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. Last but not least, you don’t have to update any of your tests to take advantage of this! Third-party assertion libraries, like expect, chai and others, are supported out-of-the-box as well.
Snapshot testing
We now have snapshot testing, thanks to @lithin ✨
Snapshot testing simply saves a stringified state of some data structure and compares it on the next run. It was popularized with React component testing, but you can use it with anything that can be stringified. For example, ensuring API responses stay the same.
ee65b6d
Precompile helper files
Previously, AVA transpiled your test files, but not your test helpers. Now we transpile helper files too! Helpers are files starting with _
or any files in a helpers
directory inside the test directory. These are usually used for utilities and shared logic between test files.
410cb8d
Improving language support
We’ve come up with a specification for how AVA handles Babel projects and may better support other languages like TypeScript. Customizing transpilation of test and helper files will be easier, and AVA will start transpiling source files too. We’ve started work on this, but there are no user-facing changes yet.
076eb81
Miscellaneous
- Removed deprecated assertions (
t.ok
,t.notOk
,t.same
,t.notSame
). If you haven’t migrated yet, you can do so automagically with our codemod. c010fd7 - Removed the
--source
flag. Use the package.json config instead. 34bebc4 - Support symlinked test files. 033d4dc
- No longer using
babel-runtime
. Built-ins likeMap
andPromise
are no longer replaced with polyfills. ad5122d - Prints a warning when
test.only()
is used, so you don’t mistakenly think you’re running all the tests. 22a6081 - Prints a warning when
--fail-fast
is enabled, so you’re aware AVA didn’t run all your tests. 09d23f5 - Exits with an error when
--watch
is used in CI, as otherwise the process would never exit, since watch mode is persistent. 0606ff7 - Only transpile what’s needed on Node.js 6. We already did that for Node.js 4. 5158ac8
- Flow type definition improvements: ce42fcb 314f7a0
- TypeScript type definition improvement: 0603edc
All changes
Thanks
💖 Huge thanks to @lithin, @ThomasBem, @leebyron, @rnkdev, @sebald, @gconaty, @jarlehansen, @LasaleFamine, @asafigan, 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.
0.17.0
The current working directory in test files changed (BREAKING)
We made the hard decision of changing the current working directory (process.cwd()
) in test files to be the same directory as package.json
. It was previously the same as __dirname
(the directory of the test file). Having process.cwd()
equal __dirname
felt like a good idea at the time, but as the popularity of AVA grew, people started hitting issues with it.
This affects users that have test files in a sub-folder and are using relative paths. If you have your test files in the same directory as package.json
, you're fine.
The fix is to wrap all relative paths in path.join(__dirname, 'relative-path')
to make them absolute.
Here's an example of what needs changing. The below file and unicorn.txt
are both in ./test/
.
-t.true(fs.existsSync('unicorn.txt'));
+t.true(fs.existsSync(path.join(__dirname, 'unicorn.txt')));
Let us know if anything is unclear or if you're having problems.
Commit: 476c653
Node.js version support
The next minor version of AVA, 0.18.0, will drop support for Node.js v0.10 and v0.12. We'll continue fixing critical issues for this version until the end of the year. Time to upgrade if you haven't. (Discussion: #1051)
Highlights
- We now have a script to automatically migrate from tape to AVA.
- Our ESLint plugin received two new rules:
- Reduced transpilation on Node.js >=4. AVA now only transpiles what's needed for Node.js 4 when on it or higher, which should result in better performance and stacktraces. 4025d81
- Removed the
--require
CLI flag. Configure it in package.json instead. 17119bc - Switched to
lodash.isEqual
for deep equality checking (t.deepEqual()
&t.notDeepEqual()
). This might make your test fail if our previous deep equality check was too loose. 8856684 - Improvements to the test failure output. e4f90e0 (We're currently working on many more improvements in this area. Stay tuned.)
- Added option to disable
power-assert
. 24a38ac - Correctly clean up stacktraces on Node.js 6 and higher. 26bcab0
- Removed
t.doesNotThrow()
as it was renamed tot.notThrows()
. It was deprecated far back in AVA 0.12.0. e448798 - Deprecated
t.error()
alias fort.ifError()
. It will be removed in AVA 1.0.0. Just uset.ifError()
. 28bb0d5 (We have an automatic migration script if you're usingt.error()
) - Ensures test files load correct AVA installation. This means you can now run AVA with an absolute path and it will still use the local AVA installation at that path if available. 3ea2ba1
- Added support for debugging tests with WebStorm and added a recipe. c268c8d
- Added Flow type defintion. 6458454
- Improvements to the TypeScript type definition. 4baa170 8816faf c40477a
- We started exploring browser support. 204f2be
All Changes
0.16.0
Hope you all are having a great summer! 😎
Highlights
- Add
t.notRegex()
. c740202 - Provide clear error message when users attempt nested or async calls to
test()
. 8edd9c2 - TypeScript definition improvements. 1dd6d5b 2e98438
- Document common pitfalls when using AVA. 187b8b4
- New JSPM and SystemJS recipe. c3539c1
All Changes
0.15.2
Avoids deprecation warning from loud-rejection
.
0.15.1
0.15.0
In this release we've added some very useful features we think you'll like. There are no known breaking changes. We have worked hard on fixing bugs and improving performance. Going forward stability and performance will be our top priority as we're progressing towards a stable release. Finally, we're delighted to welcome @sotojuan to the team! 🎉
Test file conventions
When you run AVA without any arguments, it tries to find your test files based on some conventions. The previous release had the following default patterns:
test.js test-*.js test/**/*.js
In this release we added additional default patterns based on community conventions:
test.js test-*.js test/**/*.js **/__tests__/**/*.js **/*.test.js
This means AVA will now also run test files in __tests__
directories and test files ending in .test.js
anywhere in your project.
Known failing tests
A big part of open source maintenance is triaging issues. This can be a tedious task, involving a lot of back and forth with the person reporting the issue. Submitting a PR with a failing test makes the whole process much more efficient. It helps maintainers by providing a quality reproduction, allowing them to focus on code over triaging. Users benefit as their bugs get fixed faster.
To make it easier to submit failing tests, we're introducing a new test modifier: test.failing()
. These tests are run just like normal ones, but they are expected to fail, and will not break your build when they do. If a test marked as failing actually passes, the build will break with a helpful message instructing you to remove the .failing
modifier.
test.failing('demonstrate some bug', t => {
t.fail(); // test will count as passed
});
This allows you to merge .failing
tests before a fix is implemented without breaking CI. It is also a great way to recognize good bug reports with a commit credit, even if the reporter is unable to fix the problem.
Test macros
Sometimes you want to run a series of very similar tests, each with different inputs and expected results. The traditional solution is to use test generator functions. However, this makes it difficult to perform static analysis on the tests, which is especially important for linting. In this release, we are introducing test macros as the official way to create reusable tests.
Test macros let you reuse test implementations. Additional arguments passed in the test declaration are forwarded to the macro:
function macro(t, input, expected) {
t.is(eval(input), expected);
}
test('2 + 2 === 4', macro, '2 + 2', 4);
test('2 * 3 === 6', macro, '2 * 3', 6);
If you are generating lots of tests from a single macro, you may want to generate the test title programmatically:
macro.title = (providedTitle, input, expected) => {
return `${input} === ${expected}`
};
Always modifiers for after and afterEach hooks
By default after
and afterEach
hooks will not be run if the preceding test fails. This is undesirable if the hooks contain cleanup code that you want run regardless. You can change that behavior using the .always
chaining modifier.
test.after.always(t => {
// always runs at the end. Regardless of test pass/fail state.
});
test.afterEach.always(t => {
// always runs after each test. Regardless of test pass/fail state.
});
Note that the --fail-fast
switch will disable this behavior, and AVA will exit at the first encountered failure without waiting for the always
hooks.
Limited concurrency [EXPERIMENTAL]
Concurrency is awesome! It's what makes AVA so fast. Our default behavior is to spin up an isolated process for every test file immediately, and then run all your tests. However, for users with lots of test files, this was eating up too many system resources, causing memory and IO thrashing. We are experimenting with an option to let you limit how many tests files AVA runs at the same time. If you have a lot of test files, try running AVA with the --concurrency
flag. For example, run $ ava --concurrency=5
and see if the performance improves. Please let us know how it works for you! We need feedback on the feature.
Note: This is an experimental feature and might change or be removed in the future.
Highlights
- Improve
t.deepEqual()
. 973624d - Improve watch logging. 95a5c97
- Disable TAP-reporter in watch mode. 02b0aae
- Throwing synchronously inside a callback-style test now fail it immediately. d6acdde
- Detect improper use of
t.throws
. 3201b1b - Protect against bad argument passed to
t.throws
. 60bd8a5 - Improve
power-assert
output. 84c05fe - Add spinner fallback for Windows. c4e58e3
- Warn about
npm link
usage on Node.js 6. a543b9f - Remember failures from previous tests in watch mode. aab2207
- Fix crash in 'fake' browser environment. 0fa229e
- Fix warning when no files are found. ee76aa9
- Strip ANSI escape codes in the TAP output. 3c4babd
- React recipe. 4c69c79
- Italian translation of the docs. 195390e
All Changes
We’ve merged 92 commits from 23 contributors since 0.14.0
. This only scratches the surface, as lots of additional work has gone into our linter, localized docs and countless other projects that make AVA possible. To everyone who’s reported bugs, contributed to design discussions, and filed PR’s with documentation or code - Thank You!
0.14.0
The biggest change in this release is the deprecation of t.ok
, t.notOk
, t.same
, and t.notSame
assertions. We have published a codemod (automatic migration script) which should make switching to the new assertion methods very easy.
Also, we've added a --timeout
flag that will stop test execution after a certain period of inactivity.
Highlights
- A number of assertion methods have been renamed for clarity. The old methods still exist, but have been deprecated, and will be removed in a future release (e9c6cc2, a7f50eb). We have published
ava-codemods
to assist in automatically renaming these assertions in your tests.t.ok()
→t.truthy()
t.notOk()
→t.falsy()
t.same()
→t.deepEqual()
t.notSame()
→t.notDeepEqual()
- Added an idle timeout option to prevent test runs from hanging indefinitely. The test run is considered timed out when no test results have been received for the specified interval. d1a3669
- Published a recipe on various ways to configure Babel. bcda753
- Updated Russian, Chinese, and Spanish translations. Big thanks to our translation team!
Of Note
t.deepEqual()
(formerlyt.same()
) no longer compares constructors. a7826cf- Truncate test titles in the mini reporter. 6d5f322
- Fix
t.throws()
not returning error for synchronous methods. 26d2291 - Now throws a meaningful error if
--require
dependency is not found. c78e736 - Watch mode will now rerun all
.only
tests regardless of dependency graph. e57908a - Print the planned and actual assertion count when there is a plan failure. 07febb2
- Workaround for Node.js bug which could kill main process. cd6961a
- Mini reporter no longer flashes test titles for
skip
/todo
tests. ecc87cb - Display a helpful error message for invalid Babel config. febbaa2
- Switch from
serialize-error
toclean-yaml-object
(better compatibility withnode-tap
). cd5767e - Rewrite
require("babel-runtime")
in tests to absolute path (allows module resolution fornpm@2
without modifyingNODE_PATHS
). 382e50d - Ensure source maps can be resolved from cached code. 592ff13
- Produces a helpful failure method when users incorrectly provide an implementation method to
test.todo()
. 8d6490a
All Changes
Shout-out to @kentcdodds @sotojuan @SamVerschueren @mattkrick for their awesome contributions to this release! ✨🎉
0.13.0
The most exciting changes in this release are support for using your own Babel config with AVA and an intelligent watch mode that watches for test and source changes and runs only tests that are affected.
We now have an awesome list. Our ESLint plugin got some new rules. And @novemberborn is a team member!
Highlights
- Added support for Babel config in the
ava
config package.json. This will let you configure AVA to use your own Babel config (.babelrc orbabel
in package.json). a03f826 - Added intelligent watch mode. f0f4f34
- Added
todo
test modifier. e697629 - Added ability to run only tests with matching titles. c928cb5
t.throws()
now returns error or rejection reason of promise. e03b82c- Don't coerce non-Error promise rejection to an error. 5e02387
test.only()
now works across all test files. 6b1617a- Fixed AVA hanging when
test
is used incorrectly. 94c03f6 - Added TypeScript typings. 0e18865
- Added TypeScript recipe. 20c66fe
- Added browser testing recipe. 2f10448
Changes
Huge thanks to @sotojuan @naptowncode @kasperlewau @BarryThePenguin @spudly @Carnubak @ivogabe @forresst @SamVerschueren @bachstatter!
0.12.0
This release is mostly focused on improving performance and doing some hopefully final breaking changes. We've also started work on an ESLint plugin and editor plugins for AVA, where we could use some help and feedback.
Highlights
- [breaking]
t.doesNotThrow()
is renamed tot.notThrows()
to be consistent with the other assert methods.t.doesNotThrow()
will be removed in AVA 1.0.0. a35d130 - [maybe breaking] We removed the undocumented
t.regexTest()
assert method and addedt.regex()
.t.regexTest()
had the wrong argument order.t.regex()
follows the same argument order as other assert methods. a10b9e8 - More performance improvements! (∩`-´)⊃━☆゚.*・。゚ e010816 341c84b 9b0d5f7
- Add recipe "When to use
t.plan()
". 39982a5 - Improve error determination, which fixes some issues with the output when non-errors or errors without a message are thrown. #555
- Reporter tweaks. e38c56a 308b09e e9cb25d
- Support
NODE_PATH
(Please don't useNODE_PATH
unless you really have to!) 0675d34