ava v3.4.0 Release Notes

Release Date: 2020-02-23 // about 4 years ago
  • Introducing the t.try() assertion

    The new t.try() allows you to try assertions without causing the test to fail:

    test('do the thing', async t =\> { const attempt = () =\> t.try(tt =\> { const result = await getResult() // getResult() can be flaky and sometimes throws :(tt.is(result, 'expected') }) const firstAttempt = await attempt() if (firstAttempt.passed) return firstAttempt.commit() t.log('Retrying (just once)') firstAttempt.discard() const secondAttempt = await attempt() secondAttempt.commit() })
    

    โœ… You can use any test implementation with t.try(), including (arrays of) macros. You can decide what to do with attempts. You can even run attempts concurrently, so long as they don't use snapshot assertions.

    ๐Ÿ“š This is great building block for handling all kinds of advanced test scenarios. We can't wait to see what you'll do with it! Find out more in the assertion documentation.

    ๐Ÿš€ This feature was previously behind an experimental flag. That flag has now been removed. If you have enabled the flag you'll have to update your AVA config. Also note that as of this release, attempt titles are always prefixed with the title of the parent test 7ee3a0e.

    Once again, thank you @qlonik for contributing this new assertion.

    ๐Ÿ‘ In case you missed it: ESM support

    ๐Ÿš€ As of the 3.3.0 release, AVA can load ESM test files! Check our updated ES Modules recipe for details.

    ๐Ÿ‘ Our ESM support is still incomplete. Progress is tracked in the ESM support project. Join us, won't you?

    Other changes

    • The t.throws() and t.throwsAsync() assertions can now be called with undefined as the second argument. Previously, if you wanted to set an assertion message but did not want to provide any expectations for the thrown error you had to pass null. That's still allowed, of course. d0e2161 @stavalfi
    • ๐Ÿ“ฆ ava.config.js files once again work with our @ava/typescript package f4d4edd
    • Our TypeScript definition no longer references @types/node 7a1dacf
    • โœ… We've improved the error message shown when test.cb() is used with asynchronous functions or observables f5a8c2b @toddkcarlson
    • โšก๏ธ The Vue recipe has been updated to use jsdom-global instead of browser-env 3f9c616 @Scrum
    • โšก๏ธ @fisker optimized how we detect ESM support 8831f54

    ๐Ÿ‘€ See v3.3.0...v3.4.0 for all changes.