Skip to content

0.15.0

Compare
Choose a tag to compare
@jamestalmage jamestalmage released this 25 May 03:49

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.

9ceeb11

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.

0410a03

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}`
};

a454128

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.

61f0958

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.

1c3c86c

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鈥檝e 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鈥檚 reported bugs, contributed to design discussions, and filed PR鈥檚 with documentation or code - Thank You!

v0.14.0...v0.15.0