Skip to content

Releases: avajs/ava

0.17.0

17 Nov 08:59
Compare
Choose a tag to compare

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 to t.notThrows(). It was deprecated far back in AVA 0.12.0. e448798
  • Deprecated t.error() alias for t.ifError(). It will be removed in AVA 1.0.0. Just use t.ifError(). 28bb0d5 (We have an automatic migration script if you're using t.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

v0.16.0...v0.17.0

0.16.0

06 Aug 15:14
Compare
Choose a tag to compare

Hope you all are having a great summer! 😎

Highlights

All Changes

v0.15.2...v0.16.0

0.15.2

05 Jun 03:20
Compare
Choose a tag to compare

Avoids deprecation warning from loud-rejection.

0.15.1

26 May 00:50
Compare
Choose a tag to compare

Bug fix: The new test naming conventions introduced in 0.15.0 were not being honored.

0.15.0

25 May 03:49
Compare
Choose a tag to compare

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’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!

v0.14.0...v0.15.0

0.14.0

07 Apr 01:59
Compare
Choose a tag to compare

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() (formerly t.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 to clean-yaml-object (better compatibility with node-tap). cd5767e
  • Rewrite require("babel-runtime") in tests to absolute path (allows module resolution for npm@2 without modifying NODE_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

v0.13.0...v0.14.0

Shout-out to @kentcdodds @sotojuan @SamVerschueren @mattkrick for their awesome contributions to this release! ✨🎉

0.13.0

10 Mar 15:39
Compare
Choose a tag to compare

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

Changes

v0.12.0...v0.13.0

Huge thanks to @sotojuan @naptowncode @kasperlewau @BarryThePenguin @spudly @Carnubak @ivogabe @forresst @SamVerschueren @bachstatter!

0.12.0

18 Feb 10:39
Compare
Choose a tag to compare

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 to t.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 added t.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 use NODE_PATH unless you really have to!) 0675d34

Changes

v0.11.0...v0.12.0

0.11.0

23 Jan 12:38
Compare
Choose a tag to compare

Highlights

  • Performance improvements (つ◕౪◕)つ━☆゚.*・。゚#461
  • Default to the verbose reporter on CI servers. 21a60f9
  • Add shortflags to the CLI. 5d36a80
  • Fix undefined skip count. 24b234d
  • Allow files with only skipped tests. 3739d4b
  • Remove Bluebird deprecation notice. 385c48d

Changes

v0.10.0...v0.11.0

0.10.0

15 Jan 06:19
Compare
Choose a tag to compare

Highlights

Customize the default behavior in package.json

All of the CLI options can be configured in the AVA section of your package.json. This allows you to modify the default behavior of the AVA command, so you don't have to repeatedly type the same options on the command prompt.

{
  "ava": {
    "files": [
      "my-test-folder/*.js",
      "!**/not-this-file.js"
    ],
    "failFast": true,
    "serial": true,
    "tap": true,
    "verbose": true,
    "require": ["babel-core/register", "coffee-script/register"]
  }
}

16c7282

Clean stack traces

Unrelated lines are now removed from stack traces, allowing you to find the source of an error much faster.

af37305

Improved performance

Babel transpilation of test files now happens in the main process. This avoids requiring Babel in every child process and greatly improves performance. This is an especially important improvement for people still running npm@2.

614eb12

New power-assert updates reduce the size of it's dependency graph. Offering improvements to both download times and performance.

70dd2a7

Clean console.log output.

The test status output and console.log statements from within your own code will no longer interfere with each other. The test status remains fixed at the bottom of the output.

3d7f036

Other Changes

  • New Spanish translation of the documentation. 37cd685
  • Started a collection of recipes for common scenarios / best practices. 4d96a3e
  • All assertion methods now return a promise. 821436a
  • Long stack traces are turned on in forked processes. da6a2f4
  • Skippable assertions are now documented. 879e036
  • [Breaking] .babelrc files will now be ignored when transpiling tests. This will be a breaking change for some, and fix major problems for others. The ability to configure test transpilation will be restored in a future update. 5f5be31
  • Multiple tweaks of test reporter output. a2b282e 7b764ea
  • Added a Code of Conduct b76f3d5

Changes

v0.9.1...v0.10.0