-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update ava to the latest version 🚀 #8
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bors r+ |
bors bot
added a commit
that referenced
this pull request
Dec 15, 2018
8: Update ava to the latest version 🚀 r=jniles a=greenkeeper[bot] ## The devDependency [ava](https://github.com/avajs/ava) was updated from `0.25.0` to `1.0.1`. This version is **not covered** by your **current version range**. If you don’t accept this pull request, your project will work just like it did before. However, you might be missing out on a bunch of new features, fixes and/or performance improvements from the dependency update. --- <details> <summary>Release Notes for 1.0</summary> <h1>AVA 1.0 <g-emoji class="g-emoji" alias="rocket" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f680.png">🚀</g-emoji></h1> <p>Back in January we started work on the 1.0 release, taking the opportunity to upgrade to Babel 7 and follow its beta releases. It's been a year where we made massive improvements to AVA. It's also been a year with many exciting events in our personal lives. Be it honeymoons & weddings, work & friends, naturalizations and international relocations.</p> <p>So, we're done. Or, rather, we're just beginning. Testing can be a drag. AVA helps you get it done. Its concise API, detailed error output, embrace of new language features and process isolation let you write tests more effectively. So you can ship more awesome code or do non-programming things.</p> <p>Starting now we'll push out patches and new features more regularly. And, when the time comes, ship a 2.0 and a 3.0 and so forth. If you like what we're doing, why not try and contribute? We're a friendly bunch and we could use your help to make AVA even better.</p> <p>We couldn't have gotten here without the nearly one hundred people who've contributed more, and the many more who suggested improvements, reported bugs and provided feedback. And, of course, everyone who's used AVA. Thank you for your enthusiasm and support.</p> <p><a href="https://twitter.com/novemberborn" rel="nofollow">Mark</a> & <a href="https://twitter.com/sindresorhus" rel="nofollow">Sindre</a></p> <h2>What's new & improved</h2> <h3>Assertions</h3> <h4>New <code>t.throws()</code> behavior & <code>t.throwsAsync()</code></h4> <p>We've rewritten <code>t.throws()</code> so it behaves better, has better error output and lets you write better tests:</p> <ul> <li>The assertion takes a first <em>thrower</em> argument. It must throw an exception, or your test fails. Throwing other values like strings also causes your test to fail.</li> <li>The exception must be an error object.</li> <li>The assertion returns the exception.</li> </ul> <p>You have a few ways of asserting that the exception is as designed. You can pass a second argument:</p> <ul> <li>If you pass a function it should be a constructor: the exception must be an instance of it. Previously you could pass a validation function. This is no longer possible.</li> <li>If you pass a string: the exception's <code>message</code> should be equal to it.</li> <li>If you pass a regular expression: the exception's <code>message</code> should match it.</li> </ul> <p>The most exciting new feature though is that you can pass an expectation object. A combination of the following expectations is supported:</p> <div class="highlight highlight-source-js"><pre><span class="pl-smi">t</span>.<span class="pl-en">throws</span>(fn, {code<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>ENOTFOUND<span class="pl-pds">'</span></span>}) <span class="pl-c"><span class="pl-c">//</span> err.code === 'ENOTFOUND'</span> <span class="pl-smi">t</span>.<span class="pl-en">throws</span>(fn, {code<span class="pl-k">:</span> <span class="pl-c1">9</span>}) <span class="pl-c"><span class="pl-c">//</span> err.code === 9</span> <span class="pl-smi">t</span>.<span class="pl-en">throws</span>(fn, {instanceOf<span class="pl-k">:</span> <span class="pl-c1">SyntaxError</span>}) <span class="pl-c"><span class="pl-c">//</span> err instanceof SyntaxError</span> <span class="pl-smi">t</span>.<span class="pl-en">throws</span>(fn, {is<span class="pl-k">:</span> expectedErrorInstance}) <span class="pl-c"><span class="pl-c">//</span> err === expectedErrorInstance</span> <span class="pl-smi">t</span>.<span class="pl-en">throws</span>(fn, {message<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>expected error message<span class="pl-pds">'</span></span>}) <span class="pl-c"><span class="pl-c">//</span> err.message === 'expected error message'</span> <span class="pl-smi">t</span>.<span class="pl-en">throws</span>(fn, {message<span class="pl-k">:</span><span class="pl-sr"> <span class="pl-pds">/</span>expected error message<span class="pl-pds">/</span></span>}) <span class="pl-c"><span class="pl-c">//</span> /expected error message/.test(err.message)</span> <span class="pl-smi">t</span>.<span class="pl-en">throws</span>(fn, {name<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>SyntaxError<span class="pl-pds">'</span></span>}) <span class="pl-c"><span class="pl-c">//</span> err.name === 'SyntaxError'</span></pre></div> <p>This makes tests like these much easier to write:</p> <div class="highlight highlight-source-js"><pre><span class="pl-c"><span class="pl-c">//</span> Old assertion</span> <span class="pl-k">const</span> <span class="pl-c1">err</span> <span class="pl-k">=</span> <span class="pl-smi">t</span>.<span class="pl-en">throws</span>(fn, <span class="pl-c1">TypeError</span>) <span class="pl-smi">t</span>.<span class="pl-en">is</span>(<span class="pl-smi">err</span>.<span class="pl-smi">message</span>, <span class="pl-s"><span class="pl-pds">'</span>Expected a string<span class="pl-pds">'</span></span>) <span class="pl-c"><span class="pl-c">//</span> New assertion</span> <span class="pl-smi">t</span>.<span class="pl-en">throws</span>(fn, { instanceOf<span class="pl-k">:</span> <span class="pl-c1">TypeError</span>, message<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>Expected a string<span class="pl-pds">'</span></span> })</pre></div> <p>We've removed promise support from <code>t.throws()</code> and <code>t.notThrows()</code>. Use the new <code>t.throwsAsync()</code> and <code>t.notThrowsAsync()</code> assertions instead. Support for observables has been removed completey.</p> <p>The original behavior was both hard to explain and hard to express in Flow and TypeScript. Now, if you have a function that throws a <em>synchronous</em> error, use <code>t.throws()</code> (or <code>t.notThrows()</code>). If you have a <em>promise</em> that should reject, or an <em>asynchronous</em> function that should fail, use <code>await t.throwsAsync()</code> (or <code>await t.notThrowsAsync()</code>).</p> <p>Generally speaking, you should be able to replace every occurence of <code>await t.throws</code> with <code>await t.throwsAsync</code>, and <code>await t.notThrows</code> with <code>await t.notThrowsAsync</code>. A transform file for <a href="https://urls.greenkeeper.io/facebook/jscodeshift">jscodeshift</a> is <a href="https://gist.github.com/novemberborn/c2cdc94020083a1cafe3f41e8276f983">available in this Gist</a>. Run it like:</p> <div class="highlight highlight-text-shell-session"><pre>$ <span class="pl-s1">npx jscodeshift -t https://gist.githubusercontent.com/novemberborn/c2cdc94020083a1cafe3f41e8276f983/raw/eaa64c55dfcda8006fc760054055372bb3109d1c/transform.js test.js</span></pre></div> <p>Change <code>test.js</code> to a glob pattern that matches your test files. See the <a href="https://urls.greenkeeper.io/facebook/jscodeshift#usage-cli">jscodeshift CLI usage documentation</a> for further details.</p> <h4>Bound assertion methods</h4> <p>Assertion methods are now bound to the test, meaning you can provide them as direct arguments to other functions. A contrived example:</p> <div class="highlight highlight-source-js"><pre><span class="pl-k">const</span> <span class="pl-c1">assertEach</span> <span class="pl-k">=</span> (<span class="pl-smi">arr</span>, <span class="pl-smi">assert</span>) <span class="pl-k">=></span> { <span class="pl-smi">arr</span>.<span class="pl-c1">forEach</span>(<span class="pl-smi">value</span> <span class="pl-k">=></span> <span class="pl-en">assert</span>(value)); }; <span class="pl-en">test</span>(<span class="pl-s"><span class="pl-pds">'</span>all are true<span class="pl-pds">'</span></span>, <span class="pl-smi">t</span> <span class="pl-k">=></span> { <span class="pl-en">assertEach</span>(<span class="pl-en">getArray</span>(), <span class="pl-smi">t</span>.<span class="pl-smi">true</span>); });</pre></div> <p>Whilst not strictly assertions, <code>t.plan()</code> and <code>t.log()</code> are now also bound to the test.</p> <h4>BigInt</h4> <p>As part of our Node.js 10 support you can now use <a href="https://urls.greenkeeper.io/tc39/proposal-bigint"><code>BigInt</code></a> values in <code>t.deepEqual()</code> and <code>t.snapshot()</code>. Note that this is still a stage-3 proposal.</p> <h3>Babel 7</h3> <p>AVA now uses Babel 7, with support for <code>babel.config.js</code> files. We'll automatically use your project's Babel configuration. Babel options must now be specified in a <code>testOptions</code> object. This will allow us to add source related options in the future.</p> <p>Our <a href="https://urls.greenkeeper.io/avajs/babel-preset-stage-4"><code>@ava/stage-4</code> preset</a> is now accessible via <code>ava/stage-4</code>. We've added transforms for the latest <a href="http://2ality.com/2017/02/ecmascript-2018.html" rel="nofollow">ES2018 features</a> where available (and even <a href="https://urls.greenkeeper.io/tc39/proposal-optional-catch-binding">an ES2019 one!</a>). You can also disable <code>ava/stage-4</code> entirely:</p> <p><code>package.json</code>:</p> <div class="highlight highlight-source-json"><pre>{ <span class="pl-s"><span class="pl-pds">"</span>ava<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>babel<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>testOptions<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>presets<span class="pl-pds">"</span></span>: [ [<span class="pl-s"><span class="pl-pds">"</span>ava/stage-4<span class="pl-pds">"</span></span>, <span class="pl-c1">false</span>] ] } } } }</pre></div> <p>Or, you can disable just ES module compilation:</p> <p><code>package.json</code>:</p> <div class="highlight highlight-source-json"><pre>{ <span class="pl-s"><span class="pl-pds">"</span>ava<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>babel<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>testOptions<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>presets<span class="pl-pds">"</span></span>: [ [<span class="pl-s"><span class="pl-pds">"</span>ava/stage-4<span class="pl-pds">"</span></span>, {<span class="pl-s"><span class="pl-pds">"</span>modules<span class="pl-pds">"</span></span>: <span class="pl-c1">false</span>}] ] } } } }</pre></div> <p>The <code>powerAssert</code> option and command line flags have been removed. You can now disable AVA's test enhancements by setting <code>compileEnhancements</code> to <code>false</code>. You can also disable AVA's Babel pipeline entirely:</p> <p><code>package.json</code>:</p> <div class="highlight highlight-source-json"><pre>{ <span class="pl-s"><span class="pl-pds">"</span>ava<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>babel<span class="pl-pds">"</span></span>: <span class="pl-c1">false</span>, <span class="pl-s"><span class="pl-pds">"</span>compileEnhancements<span class="pl-pds">"</span></span>: <span class="pl-c1">false</span> } }</pre></div> <h3>Serial hooks and context</h3> <p>Hooks declared using <code>test.serial</code> will now execute serially. Only one of those hooks will run at a time. Other hooks run concurrently. Hooks still run in their declaration order.</p> <p>Note that concurrent tests run concurrently. This means that <code>.beforeEach()</code> and <code>.afterEach()</code> hooks for those tests may also run concurrently, even if you use <code>test.serial</code> to declare them.</p> <p><code>t.context</code> can now be used in <code>.before</code> and <code>.after</code> hooks.</p> <h3>CLI</h3> <h4>Pass flags to your test</h4> <p>AVA now forwards arguments, provided after an <code>--</code> argument terminator, to the worker processes. Arguments are available from <code>process.argv[2]</code> onwards.</p> <div class="highlight highlight-text-shell-session"><pre><span class="pl-c1">npx ava test.js -- hello world</span></pre></div> <p>There's a <a href="https://urls.greenkeeper.io/avajs/ava/blob/master/docs/recipes/passing-arguments-to-your-test-files.md">new recipe on how to use this</a>.</p> <p>Previously AVA populated <code>process.argv[2]</code> and <code>process.argv[3]</code> with some undocumented internal values. These are no longer available.</p> <h4>Resetting AVA's cache</h4> <p>The <code>--no-cache</code> CLI flag has been replaced by a <code>--reset-cache</code> command. The latter resets AVA's regular cache location. You can still disable the cache through the <code>cache</code> configuration option.</p> <div class="highlight highlight-text-shell-session"><pre><span class="pl-c1">npx ava --reset-cache</span></pre></div> <h3>Configuration</h3> <h4>Introducing <code>ava.config.js</code></h4> <p>You can now configure AVA through an <code>ava.config.js</code> file. It must be placed next to the <code>package.json</code>, and you mustn't have any <code>"ava"</code> options in the <code>package.json</code> file. Export the configuration as a default:</p> <div class="highlight highlight-source-js"><pre><span class="pl-k">export</span> <span class="pl-c1">default</span> { babel<span class="pl-k">:</span> { extensions<span class="pl-k">:</span> [<span class="pl-s"><span class="pl-pds">'</span>js<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>jsx<span class="pl-pds">'</span></span>] } };</pre></div> <p>Or export a factory function:</p> <div class="highlight highlight-source-js"><pre><span class="pl-k">export</span> <span class="pl-c1">default</span> ({projectDir}) <span class="pl-k">=></span> ({ babel<span class="pl-k">:</span> { extensions<span class="pl-k">:</span> [<span class="pl-s"><span class="pl-pds">'</span>js<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>jsx<span class="pl-pds">'</span></span>] } });</pre></div> <p>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 <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="327780723" data-permission-text="Issue title is private" data-url="avajs/ava#1820" data-hovercard-type="issue" data-hovercard-url="/avajs/ava/issues/1820/hovercard" href="https://urls.greenkeeper.io/avajs/ava/issues/1820">#1820</a>.</p> <h4>Configurable test & helper file extensions</h4> <p>You can now tell AVA to run test files with extensions other than <code>js</code>! For files that should be compiled using Babel you can specify <code>babel.extensions</code>:</p> <p><code>package.json</code>:</p> <div class="highlight highlight-source-json"><pre>{ <span class="pl-s"><span class="pl-pds">"</span>ava<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>babel<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>extensions<span class="pl-pds">"</span></span>: [<span class="pl-s"><span class="pl-pds">"</span>js<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>jsx<span class="pl-pds">"</span></span>] } } }</pre></div> <p>Or define generic extensions, e.g. for use with TypeScript:</p> <p><code>package.json</code>:</p> <div class="highlight highlight-source-json"><pre>{ <span class="pl-s"><span class="pl-pds">"</span>ava<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>compileEnhancements<span class="pl-pds">"</span></span>: <span class="pl-c1">false</span>, <span class="pl-s"><span class="pl-pds">"</span>extensions<span class="pl-pds">"</span></span>: [<span class="pl-s"><span class="pl-pds">"</span>ts<span class="pl-pds">"</span></span>], <span class="pl-s"><span class="pl-pds">"</span>require<span class="pl-pds">"</span></span>: [ <span class="pl-s"><span class="pl-pds">"</span>ts-node/register<span class="pl-pds">"</span></span> ] } }</pre></div> <p>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 <code>"compileEnhancements": false</code>.</p> <h3>Snapshots</h3> <p>Adding new snapshots no longer causes the Markdown files to become malformed. Snapshots are now consistent across operating systems. If you've previously generated snapshots on Windows, you should update them using this release.</p> <p>We now support <code>BigInt</code> and <code><React.Fragment></code> in <code>t.snapshot()</code>. We've also improved support for the <code>Symbol.asyncIterator</code> well-known symbol. Unfortunately these changes are not backwards compatible. You'll need to update your snapshots when upgrading to this release.</p> <p>We've improved how AVA builds snapshot files to better support precompiled projects. Say, if you compile your TypeScript test files using <code>tsc</code> before running AVA on the build output. AVA will now use the source map to figure out the original filename and use that as the basis for the snapshot files. You'll have to manually remove snapshots generated by previous AVA versions.</p> <h3>Type definitions</h3> <p>The TypeScript and Flow definitions have been rewritten and much improved. The <a href="https://urls.greenkeeper.io/avajs/ava/blob/master/docs/recipes/typescript.md">TypeScript recipe</a> has been updated to reflect the changes, and there's a new <a href="https://urls.greenkeeper.io/avajs/ava/blob/master/docs/recipes/flow.md">Flow recipe</a> too.</p> <h4>TypeScript</h4> <p>AVA recognizes TypeScript build errors when using <code>ts-node/register</code>.</p> <p>TypeScript now type-checks additional arguments used by macros. You must type the arguments used:</p> <div class="highlight highlight-source-ts"><pre><span class="pl-k">import</span> <span class="pl-smi">test</span>, {<span class="pl-smi">Macro</span>} <span class="pl-k">from</span> <span class="pl-s"><span class="pl-pds">'</span>ava<span class="pl-pds">'</span></span> <span class="pl-k"><span class="pl-k">const</span></span> failsToParse<span class="pl-k">:</span> <span class="pl-en">Macro</span><[<span class="pl-en">Buffer</span>]> <span class="pl-k">=</span> (<span class="pl-v">t</span>, <span class="pl-v">input</span>) <span class="pl-k">=></span> { <span class="pl-smi">t</span>.<span class="pl-en">throws</span>(<span class="pl-en">parse</span>(<span class="pl-smi">input</span>)) } <span class="pl-smi">failsToParse</span>.<span class="pl-c1">title</span> <span class="pl-k">=</span> (<span class="pl-v">providedTitle</span> <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">'</span>unexpected input<span class="pl-pds">'</span></span>) <span class="pl-k">=></span> <span class="pl-s"><span class="pl-pds">`</span>throws when parsing ${<span class="pl-smi">providedTitle</span>}<span class="pl-pds">`</span></span> <span class="pl-en">test</span>(<span class="pl-s"><span class="pl-pds">'</span>malformed<span class="pl-pds">'</span></span>, <span class="pl-smi">failsToParse</span>, <span class="pl-smi">fs</span>.<span class="pl-en">readFileSync</span>(<span class="pl-s"><span class="pl-pds">'</span>fixtures/malformed.txt<span class="pl-pds">'</span></span>)) <span class="pl-en">test</span>(<span class="pl-smi">failsToParse</span>, <span class="pl-s"><span class="pl-pds">'</span>}<span class="pl-pds">'</span></span>) <span class="pl-c"><span class="pl-c">//</span> ⬅️ fails to compile</span></pre></div> <h3>Other improvements</h3> <ul> <li>You can now specify helpers — that need to be compiled by AVA — in the <code>require</code> configuration.</li> <li><code>--fail-fast</code> behavior has been improved. AVA now makes sure not to <em>start</em> new tests. Tests that are already running though will finish. Hooks will also be called. AVA now prints the number of skipped test files if an error occurs and <code>--fail-fast</code> is enabled.</li> <li>AVA now uses its own <a href="https://urls.greenkeeper.io/chalk/chalk">Chalk</a> instance, so AVA's color settings no longer impact the code you're testing.</li> <li>Error serialization has been made smarter, especially if non-Error errors are encountered.</li> <li>Uncaught exceptions and unhandled rejections are now shown with a code excerpt.</li> <li>You should see fewer repeated test timeout messages.</li> <li>Error messages now link to the documentation appropriate for the version of AVA you're using.</li> <li>AVA now automatically detects whether your CI environment supports parallel builds. Each build will run a subset of all test files, while still making sure all tests get executed. See the <a href="https://www.npmjs.com/package/ci-parallel-vars" rel="nofollow"><code>ci-parallel-vars</code></a> package for a list of supported CI environments.</li> <li>AVA now detects when it's required from a Node.js REPL.</li> <li>We've improved the colors for use on light terminal themes.</li> <li>The <code>assert</code> module in Node.js 10 no longer crashes.</li> <li>Source maps, generated by AVA when compiling test & helper files, now contain correct paths to the source files.</li> <li>TTY support for <code>process.stderr</code> is now emulated in the worker processes.</li> <li>The default reporter now includes files that did not declare any tests in its final output.</li> <li>AVA now prints pending tests when timeouts occur, when using <code>--verbose</code>.</li> <li><code><React.Fragment></code> can be used in <code>t.deepEqual</code>.</li> <li><code>title</code> functions of macros now receive <code>undefined</code> rather than an empty string if no title was given in the test declaration. This means you can use default parameters.</li> </ul> <h2>Breaking changes since 0.25.0</h2> <h3>Supported Node.js versions</h3> <p>We've <a href="https://urls.greenkeeper.io/avajs/ava/blob/master/docs/support-statement.md">published a statement</a> with regards to which Node.js versions we intend to support. As of this release we're only supporting Node.js 6.12.3 or newer, 8.9.4 or newer, 10.0.0 or newer and 11.0.0 or newer. This does not include Node.js 7 and 9.</p> <h3>Tests must now have titles, and they must be unique</h3> <p>You can no longer do:</p> <div class="highlight highlight-source-js"><pre><span class="pl-en">test</span>(<span class="pl-smi">t</span> <span class="pl-k">=></span> <span class="pl-smi">t</span>.<span class="pl-en">pass</span>());</pre></div> <p>Instead all tests must have titles, and they must be unique within the test file:</p> <div class="highlight highlight-source-js"><pre><span class="pl-en">test</span>(<span class="pl-s"><span class="pl-pds">'</span>passes<span class="pl-pds">'</span></span>, <span class="pl-smi">t</span> <span class="pl-k">=></span> <span class="pl-smi">t</span>.<span class="pl-en">pass</span>());</pre></div> <p>This makes it easier to pinpoint test failures and makes snapshots better too.</p> <p>Note that AVA no longer infers a test title from a function name:</p> <div class="highlight highlight-source-js"><pre><span class="pl-en">test</span>(<span class="pl-k">function</span> <span class="pl-en">myTest</span> (<span class="pl-smi">t</span>) { <span class="pl-smi">t</span>.<span class="pl-en">pass</span>(); });</pre></div> <h3>Modifier chaining</h3> <p>AVA's various test modifiers (<code>.serial</code>, <code>.skip</code>) must now be used in the correct order:</p> <ul> <li><code>.serial</code> must be used at the beginning, e.g. <code>test.serial()</code>.</li> <li><code>.only</code> and <code>.skip</code> must be used at the end, e.g. <code>test.skip()</code>. You cannot combine them.</li> <li><code>.failing</code> must be used at the end, but can be followed by <code>.only</code> and <code>.skip</code>, e.g. <code>test.cb.failing()</code> and <code>test.cb.failing.only()</code>.</li> <li><code>.always</code> can only be used after <code>.after</code> and <code>.afterEach</code>, e.g. <code>test.after.always()</code>.</li> <li><code>.todo()</code> is only available on <code>test</code> and <code>test.serial</code>. No further modifiers can be applied.</li> </ul> <h3>Declaring tests</h3> <p>You must declare all tests and hooks at once. This was always the intent but previously AVA didn't enforce it very well. Now, once you declare a test or hook, all other tests and hooks must be declared synchronously. However you can perform some asynchronous actions <em>before</em> declaring your tests and hooks.</p> <h3><code>test</code> export</h3> <p>We're no longer exporting the <code>test()</code> method as a named export. Where before you could use <code>import {test} from 'ava'</code>, you should now write <code>import test from 'ava'</code>.</p> <h3>Set default title using parameters syntax</h3> <p>Macros can generate a test title. Previously, AVA would call the <code>title</code> function with an empty string if no title was given in the test declaration. Now, it'll pass <code>undefined</code> instead. This means you can use default parameters. Here's an example:</p> <div class="highlight highlight-source-js"><pre><span class="pl-k">import</span> <span class="pl-smi">test</span> <span class="pl-k">from</span> <span class="pl-s"><span class="pl-pds">'</span>ava<span class="pl-pds">'</span></span> <span class="pl-k">const</span> <span class="pl-c1">failsToParse</span> <span class="pl-k">=</span> (<span class="pl-smi">t</span>, <span class="pl-smi">input</span>) <span class="pl-k">=></span> { <span class="pl-smi">t</span>.<span class="pl-en">throws</span>(<span class="pl-en">parse</span>(input)) } <span class="pl-smi">failsToParse</span>.<span class="pl-en">title</span> <span class="pl-k">=</span> (<span class="pl-smi">providedTitle</span> <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">'</span>unexpected input<span class="pl-pds">'</span></span>) <span class="pl-k">=></span> <span class="pl-s"><span class="pl-pds">`</span>throws when parsing <span class="pl-s1"><span class="pl-pse">${</span>providedTitle<span class="pl-pse">}</span></span><span class="pl-pds">`</span></span> <span class="pl-en">test</span>(<span class="pl-s"><span class="pl-pds">'</span>malformed<span class="pl-pds">'</span></span>, failsToParse, <span class="pl-smi">fs</span>.<span class="pl-en">readFileSync</span>(<span class="pl-s"><span class="pl-pds">'</span>fixtures/malformed.txt<span class="pl-pds">'</span></span>)) <span class="pl-en">test</span>(failsToParse, <span class="pl-smi">Buffer</span>.<span class="pl-en">from</span>(<span class="pl-s"><span class="pl-pds">'</span>}<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>utf8<span class="pl-pds">'</span></span>))</pre></div> <p>This is a breaking change if you were concatenating the provided title, under the assumption that it was an empty string.</p> <h3>Assertions</h3> <h4><code>t.throws()</code> & <code>t.notThrows()</code></h4> <p>Thrown exceptions (or rejection reasons) <em>must</em> now be error objects.</p> <p><code>t.throws()</code> and <code>t.notThrows()</code> no longer support observables or promises. For the latter, use <code>await t.throwsAsync()</code> and <code>await t.notThrowsAsync()</code> instead.</p> <p>Generally speaking, you should be able to replace every occurence of <code>await t.throws</code> with <code>await t.throwsAsync</code>, and <code>await t.notThrows</code> with <code>await t.notThrowsAsync</code>. A transform file for <a href="https://urls.greenkeeper.io/facebook/jscodeshift">jscodeshift</a> is <a href="https://gist.github.com/novemberborn/c2cdc94020083a1cafe3f41e8276f983">available in this Gist</a>. Run it like:</p> <div class="highlight highlight-text-shell-session"><pre>$ <span class="pl-s1">npx jscodeshift -t https://gist.githubusercontent.com/novemberborn/c2cdc94020083a1cafe3f41e8276f983/raw/eaa64c55dfcda8006fc760054055372bb3109d1c/transform.js test.js</span></pre></div> <p>Change <code>test.js</code> to a glob pattern that matches your test files. See the <a href="https://urls.greenkeeper.io/facebook/jscodeshift#usage-cli">jscodeshift CLI usage documentation</a> for further details.</p> <h4>Skipping assertions</h4> <p>Assertions can be skipped by using <code>.skip</code> at the end of the assertion, e.g. <code>t.deepEqual.skip()</code>. You can now safely skip snapshot tests, though not whilst updating snapshots.</p> <h4><code>t.ifError()</code></h4> <p>We've removed the <code>t.ifError()</code> assertion. It worked the same as <code>t.falsy()</code>, so if you were using it please switch to <code>t.falsy()</code> instead.</p> <h3>Configuration changes</h3> <p>The <code>source</code> option <strong>has been renamed</strong> to <code>sources</code>. This is now consistent with <code>files</code>. AVA will exit with an error if it encounters the <code>source</code> option.</p> <p>We've also removed unintentional support for <code>init</code>, <code>watch</code> and <code>updateSnapshot</code> options.</p> <h4>Babel</h4> <p>The <code>"default"</code> and <code>"inherit"</code> configuration values have been removed. Babel options must now be specified in a <code>testOptions</code> object. This will allow us to add source related options in the future.</p> <p>The <code>powerAssert</code> option and command line flags have been removed. You can now disable AVA's test enhancements by setting <code>compileEnhancements</code> to <code>false</code>.</p> <p>The <a href="https://urls.greenkeeper.io/avajs/ava/blob/master/docs/recipes/babel.md">Babel recipe</a> has been updated with the latest details.</p> <h3>Updated type definitions</h3> <p>The TypeScript and Flow definitions have been rewritten. The definitions export different interfaces so you may need to update your test code as well.</p> <p>TypeScript now type-checks additional arguments used by macros. You must type the arguments used.</p> <h3>Internals</h3> <p>Some other internals have changed. You shouldn't have been relying on these, though if you did we're interested in hearing about it so we can better support your use case.</p> <ul> <li>The private <code>t._test</code> value has been removed</li> <li>Some of the communication between the main process and the test workers has changed</li> <li>Access to the options object from inside a worker process has changed</li> </ul> <h3>Other potential breaking changes</h3> <ul> <li>We've removed support for <code>@std/esm</code>, in favor of the plain <code>esm</code> package.</li> <li>The <code>ava/stage-4</code> preset is applied after all other plugins and presets.</li> <li>Test implementations are now called with <code>null</code> as the <code>this</code> value.</li> <li>All reporters write to <code>stdout</code>. The <code>stdout</code> and <code>stderr</code>output from workers is written to <code>process.stderr</code>. AVA will insert linebreaks in <code>process.stdout</code> after writing a chunk to <code>process.stderr</code>that does not end in a line break.</li> <li>The <code>--no-cache</code> CLI flag has been replaced by a <code>--reset-cache</code> command. The latter resets AVA's regular cache location. You can still disable the cache through the <code>cache</code> configuration option.</li> <li>We've dropped support for using generator functions as test implementations. This was a remnant of the dark days before <code>async</code>/<code>await</code> support.</li> <li>Snapshots need to be regenerated.</li> <li>If you pre-compile your test files, the snapshot files may be created at new file paths. You'll have to manually remove any old files.</li> </ul> <h2>New recipes</h2> <p>There's a new recipe on using <a href="https://urls.greenkeeper.io/avajs/ava/blob/master/docs/recipes/es-modules.md">ES modules</a>. We've also added a recipe on <a href="https://urls.greenkeeper.io/avajs/ava/blob/master/docs/recipes/test-setup.md">setting up tests</a> and <a href="https://urls.greenkeeper.io/avajs/ava/blob/master/docs/recipes/puppeteer.md">how test webapps using AVA and Puppeteer</a>.</p> <h2>All changes <g-emoji class="g-emoji" alias="books" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f4da.png">📚</g-emoji></h2> <p><a href="https://urls.greenkeeper.io/avajs/ava/compare/v0.25.0...v1.0.1"><code>v0.25.0...v1.0.1</code></a></p> <h2>Thanks <g-emoji class="g-emoji" alias="love_letter" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f48c.png">💌</g-emoji></h2> <p><g-emoji class="g-emoji" alias="sparkling_heart" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f496.png">💖</g-emoji> Huge thanks to <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=5095882" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/okyantoro">@okyantoro</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=2144273" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/JasonRitchie">@JasonRitchie</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=163352" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/forresst">@forresst</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=217407" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/mdvorscak">@mdvorscak</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=3274087" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/kugtong33">@kugtong33</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=10607759" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/motss">@motss</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=14985016" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/BusbyActual">@BusbyActual</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=1158733" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/billyjanitsch">@billyjanitsch</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=33760983" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/Briantmorr">@Briantmorr</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=4303" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/jdalton">@jdalton</a>, @malimichael, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=478864" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/martypdx">@martypdx</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=42060922" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/clemtrek">@clemtrek</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=787668" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/samuelli">@samuelli</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=3474233" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/emilyschultz">@emilyschultz</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=9622" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/hallettj">@hallettj</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=1788245" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/isnifer">@isnifer</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=5057468" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/Jaden-Giordano">@Jaden-Giordano</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=11514928" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/good-idea">@good-idea</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=952783" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/jamiebuilds">@jamiebuilds</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=1257954" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/tobil">@tobil</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=25923790" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/TheDancingCode">@TheDancingCode</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=3385679" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/btkostner">@btkostner</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=5196971" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/CanRau">@CanRau</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=903597" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/coreyfarrell">@coreyfarrell</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=14309483" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/ivanschwarz">@ivanschwarz</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=655686" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/jagoda">@jagoda</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=2865858" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/padmaia">@padmaia</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=125620" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/ronen">@ronen</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=19504461" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/sh7dm">@sh7dm</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=10238474" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/sharkykh">@sharkykh</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=3723666" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/Phrynobatrachus">@Phrynobatrachus</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=23017380" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/grant37">@grant37</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=22645979" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/xxczaki">@xxczaki</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=19639860" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/robertbernardbrown">@robertbernardbrown</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=169170" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/lo1tuma">@lo1tuma</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=3503252" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/goooseman">@goooseman</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=14758939" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/wmik">@wmik</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=923939" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/vancouverwill">@vancouverwill</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=1373271" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/qlonik">@qlonik</a>, <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=3994645" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/vlajos">@vlajos</a> and <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=7334570" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://urls.greenkeeper.io/itskolli">@itskolli</a> for helping us with this release. We couldn’t have done it without you!</p> <h2>Get involved <g-emoji class="g-emoji" alias="v" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/270c.png">✌️</g-emoji></h2> <p>We welcome new contributors. AVA is a friendly place to get started in open source. We have a <a href="https://medium.com/@vadimdemedes/making-your-first-contribution-de6576ddb190#.umxr7id07" rel="nofollow">great article</a> on getting started contributing and a comprehensive <a href="https://urls.greenkeeper.io/avajs/ava/blob/master/contributing.md">contributing guide</a>.</p> </details> <details> <summary>Commits</summary> <p>The new version differs by 218 commits.</p> <ul> <li><a href="https://urls.greenkeeper.io/avajs/ava/commit/783944f2a0609c654c6e0f4762f1be965448a17a"><code>783944f</code></a> <code>1.0.1</code></li> <li><a href="https://urls.greenkeeper.io/avajs/ava/commit/024bab72dee2eb4887d026b5451b79a50e1a20d3"><code>024bab7</code></a> <code>1.0.0</code></li> <li><a href="https://urls.greenkeeper.io/avajs/ava/commit/aac41dcb6662042956ffe4ccbe244dddcb71000f"><code>aac41dc</code></a> <code>Reword introduction</code></li> <li><a href="https://urls.greenkeeper.io/avajs/ava/commit/84d8fff84cbf01a994a8f2ce520a2742dc79b14f"><code>84d8fff</code></a> <code>Bump dependencies & update documentation</code></li> <li><a href="https://urls.greenkeeper.io/avajs/ava/commit/c1364a1cfa821a22fd059a61cbc5b19c4a1808fd"><code>c1364a1</code></a> <code>Update the tagline and readme intro (#1983)</code></li> <li><a href="https://urls.greenkeeper.io/avajs/ava/commit/eed2e7a9bc7a8bcdd6917206e6685feeda325e14"><code>eed2e7a</code></a> <code>Clarify that not all configuration options can be overridden by CLI flags</code></li> <li><a href="https://urls.greenkeeper.io/avajs/ava/commit/93e91c9ad09d89ab876d870130e42ad71ecabaf4"><code>93e91c9</code></a> <code>Fix 'sources' option in configuration docs</code></li> <li><a href="https://urls.greenkeeper.io/avajs/ava/commit/3bc80b0595f7e3d44c93a1f44d2724b52f95e911"><code>3bc80b0</code></a> <code>Remove moot ESLint disable comment</code></li> <li><a href="https://urls.greenkeeper.io/avajs/ava/commit/311c197d71cecbd3f43e547014edd8cb6b6ecd8a"><code>311c197</code></a> <code>Fix snapshot skip interface</code></li> <li><a href="https://urls.greenkeeper.io/avajs/ava/commit/0e82b044a1a5af35286df344275ef779431aac3a"><code>0e82b04</code></a> <code>1.0.0-rc.2</code></li> <li><a href="https://urls.greenkeeper.io/avajs/ava/commit/f97e277df70f56ee68fba8a63f736db1736b6f18"><code>f97e277</code></a> <code>Bump dependencies</code></li> <li><a href="https://urls.greenkeeper.io/avajs/ava/commit/6f54db84199473edcd169059acbd0bebc7427f04"><code>6f54db8</code></a> <code>Type additional arguments used by macros</code></li> <li><a href="https://urls.greenkeeper.io/avajs/ava/commit/a82fee56ffefb3fd433664f236150f62c55feeb5"><code>a82fee5</code></a> <code>Documentation updates</code></li> <li><a href="https://urls.greenkeeper.io/avajs/ava/commit/afe028a0a05c8b8bb0b33e12b557ff455e47355d"><code>afe028a</code></a> <code>CI updates</code></li> <li><a href="https://urls.greenkeeper.io/avajs/ava/commit/1ba31d8f3e1b6aa645f10ee5fc5b8c84a366c40d"><code>1ba31d8</code></a> <code>Reorganize documentation</code></li> </ul> <p>There are 218 commits in total.</p> <p>See the <a href="https://urls.greenkeeper.io/avajs/ava/compare/a051d3e18dba92c893fddb08490a8627f586c231...783944f2a0609c654c6e0f4762f1be965448a17a">full diff</a></p> </details> <details> <summary>FAQ and help</summary> There is a collection of [frequently asked questions](https://greenkeeper.io/faq.html). If those don’t help, you can always [ask the humans behind Greenkeeper](https://github.com/greenkeeperio/greenkeeper/issues/new). </details> --- Your [Greenkeeper](https://greenkeeper.io) bot 🌴 Co-authored-by: greenkeeper[bot] <greenkeeper[bot]@users.noreply.github.com>
Build succeeded |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The devDependency ava was updated from
0.25.0
to1.0.1
.This version is not covered by your current version range.
If you don’t accept this pull request, your project will work just like it did before. However, you might be missing out on a bunch of new features, fixes and/or performance improvements from the dependency update.
Release Notes for 1.0
AVA 1.0 🚀
Back in January we started work on the 1.0 release, taking the opportunity to upgrade to Babel 7 and follow its beta releases. It's been a year where we made massive improvements to AVA. It's also been a year with many exciting events in our personal lives. Be it honeymoons & weddings, work & friends, naturalizations and international relocations.
So, we're done. Or, rather, we're just beginning. Testing can be a drag. AVA helps you get it done. Its concise API, detailed error output, embrace of new language features and process isolation let you write tests more effectively. So you can ship more awesome code or do non-programming things.
Starting now we'll push out patches and new features more regularly. And, when the time comes, ship a 2.0 and a 3.0 and so forth. If you like what we're doing, why not try and contribute? We're a friendly bunch and we could use your help to make AVA even better.
We couldn't have gotten here without the nearly one hundred people who've contributed more, and the many more who suggested improvements, reported bugs and provided feedback. And, of course, everyone who's used AVA. Thank you for your enthusiasm and support.
Mark & Sindre
What's new & improved
Assertions
New
t.throws()
behavior &t.throwsAsync()
We've rewritten
t.throws()
so it behaves better, has better error output and lets you write better tests:You have a few ways of asserting that the exception is as designed. You can pass a second argument:
message
should be equal to it.message
should match it.The most exciting new feature though is that you can pass an expectation object. A combination of the following expectations is supported:
This makes tests like these much easier to write:
We've removed promise support from
t.throws()
andt.notThrows()
. Use the newt.throwsAsync()
andt.notThrowsAsync()
assertions instead. Support for observables has been removed completey.The original behavior was both hard to explain and hard to express in Flow and TypeScript. Now, if you have a function that throws a synchronous error, use
t.throws()
(ort.notThrows()
). If you have a promise that should reject, or an asynchronous function that should fail, useawait t.throwsAsync()
(orawait t.notThrowsAsync()
).Generally speaking, you should be able to replace every occurence of
await t.throws
withawait t.throwsAsync
, andawait t.notThrows
withawait t.notThrowsAsync
. A transform file for jscodeshift is available in this Gist. Run it like:$ npx jscodeshift -t https://gist.githubusercontent.com/novemberborn/c2cdc94020083a1cafe3f41e8276f983/raw/eaa64c55dfcda8006fc760054055372bb3109d1c/transform.js test.js
Change
test.js
to a glob pattern that matches your test files. See the jscodeshift CLI usage documentation for further details.Bound assertion methods
Assertion methods are now bound to the test, meaning you can provide them as direct arguments to other functions. A contrived example:
Whilst not strictly assertions,
t.plan()
andt.log()
are now also bound to the test.BigInt
As part of our Node.js 10 support you can now use
BigInt
values int.deepEqual()
andt.snapshot()
. Note that this is still a stage-3 proposal.Babel 7
AVA now uses Babel 7, with support for
babel.config.js
files. We'll automatically use your project's Babel configuration. Babel options must now be specified in atestOptions
object. This will allow us to add source related options in the future.Our
@ava/stage-4
preset is now accessible viaava/stage-4
. We've added transforms for the latest ES2018 features where available (and even an ES2019 one!). You can also disableava/stage-4
entirely:package.json
:Or, you can disable just ES module compilation:
package.json
:The
powerAssert
option and command line flags have been removed. You can now disable AVA's test enhancements by settingcompileEnhancements
tofalse
. You can also disable AVA's Babel pipeline entirely:package.json
:Serial hooks and context
Hooks declared using
test.serial
will now execute serially. Only one of those hooks will run at a time. Other hooks run concurrently. Hooks still run in their declaration order.Note that concurrent tests run concurrently. This means that
.beforeEach()
and.afterEach()
hooks for those tests may also run concurrently, even if you usetest.serial
to declare them.t.context
can now be used in.before
and.after
hooks.CLI
Pass flags to your test
AVA now forwards arguments, provided after an
--
argument terminator, to the worker processes. Arguments are available fromprocess.argv[2]
onwards.npx ava test.js -- hello world
There's a new recipe on how to use this.
Previously AVA populated
process.argv[2]
andprocess.argv[3]
with some undocumented internal values. These are no longer available.Resetting AVA's cache
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.npx ava --reset-cache
Configuration
Introducing
ava.config.js
You can now configure AVA through an
ava.config.js
file. It must be placed next to thepackage.json
, and you mustn't have any"ava"
options in thepackage.json
file. Export the configuration as a default:Or export a factory function:
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.
Configurable test & helper file extensions
You can now tell AVA to run test files with extensions other than
js
! For files that should be compiled using Babel you can specifybabel.extensions
:package.json
:Or define generic extensions, e.g. for use with TypeScript:
package.json
: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
.Snapshots
Adding new snapshots no longer causes the Markdown files to become malformed. Snapshots are now consistent across operating systems. If you've previously generated snapshots on Windows, you should update them using this release.
We now support
BigInt
and<React.Fragment>
int.snapshot()
. We've also improved support for theSymbol.asyncIterator
well-known symbol. Unfortunately these changes are not backwards compatible. You'll need to update your snapshots when upgrading to this release.We've improved how AVA builds snapshot files to better support precompiled projects. Say, if you compile your TypeScript test files using
tsc
before running AVA on the build output. AVA will now use the source map to figure out the original filename and use that as the basis for the snapshot files. You'll have to manually remove snapshots generated by previous AVA versions.Type definitions
The TypeScript and Flow definitions have been rewritten and much improved. The TypeScript recipe has been updated to reflect the changes, and there's a new Flow recipe too.
TypeScript
AVA recognizes TypeScript build errors when using
ts-node/register
.TypeScript now type-checks additional arguments used by macros. You must type the arguments used:
Other improvements
require
configuration.--fail-fast
behavior has been improved. AVA now makes sure not to start new tests. Tests that are already running though will finish. Hooks will also be called. AVA now prints the number of skipped test files if an error occurs and--fail-fast
is enabled.ci-parallel-vars
package for a list of supported CI environments.assert
module in Node.js 10 no longer crashes.process.stderr
is now emulated in the worker processes.--verbose
.<React.Fragment>
can be used int.deepEqual
.title
functions of macros now receiveundefined
rather than an empty string if no title was given in the test declaration. This means you can use default parameters.Breaking changes since 0.25.0
Supported Node.js versions
We've published a statement with regards to which Node.js versions we intend to support. As of this release we're only supporting Node.js 6.12.3 or newer, 8.9.4 or newer, 10.0.0 or newer and 11.0.0 or newer. This does not include Node.js 7 and 9.
Tests must now have titles, and they must be unique
You can no longer do:
Instead all tests must have titles, and they must be unique within the test file:
This makes it easier to pinpoint test failures and makes snapshots better too.
Note that AVA no longer infers a test title from a function name:
Modifier chaining
AVA's various test modifiers (
.serial
,.skip
) must now be used in the correct order:.serial
must be used at the beginning, e.g.test.serial()
..only
and.skip
must be used at the end, e.g.test.skip()
. You cannot combine them..failing
must be used at the end, but can be followed by.only
and.skip
, e.g.test.cb.failing()
andtest.cb.failing.only()
..always
can only be used after.after
and.afterEach
, e.g.test.after.always()
..todo()
is only available ontest
andtest.serial
. No further modifiers can be applied.Declaring tests
You must declare all tests and hooks at once. This was always the intent but previously AVA didn't enforce it very well. Now, once you declare a test or hook, all other tests and hooks must be declared synchronously. However you can perform some asynchronous actions before declaring your tests and hooks.
test
exportWe're no longer exporting the
test()
method as a named export. Where before you could useimport {test} from 'ava'
, you should now writeimport test from 'ava'
.Set default title using parameters syntax
Macros can generate a test title. Previously, AVA would call the
title
function with an empty string if no title was given in the test declaration. Now, it'll passundefined
instead. This means you can use default parameters. Here's an example:This is a breaking change if you were concatenating the provided title, under the assumption that it was an empty string.
Assertions
t.throws()
&t.notThrows()
Thrown exceptions (or rejection reasons) must now be error objects.
t.throws()
andt.notThrows()
no longer support observables or promises. For the latter, useawait t.throwsAsync()
andawait t.notThrowsAsync()
instead.Generally speaking, you should be able to replace every occurence of
await t.throws
withawait t.throwsAsync
, andawait t.notThrows
withawait t.notThrowsAsync
. A transform file for jscodeshift is available in this Gist. Run it like:$ npx jscodeshift -t https://gist.githubusercontent.com/novemberborn/c2cdc94020083a1cafe3f41e8276f983/raw/eaa64c55dfcda8006fc760054055372bb3109d1c/transform.js test.js
Change
test.js
to a glob pattern that matches your test files. See the jscodeshift CLI usage documentation for further details.Skipping assertions
Assertions can be skipped by using
.skip
at the end of the assertion, e.g.t.deepEqual.skip()
. You can now safely skip snapshot tests, though not whilst updating snapshots.t.ifError()
We've removed the
t.ifError()
assertion. It worked the same ast.falsy()
, so if you were using it please switch tot.falsy()
instead.Configuration changes
The
source
option has been renamed tosources
. This is now consistent withfiles
. AVA will exit with an error if it encounters thesource
option.We've also removed unintentional support for
init
,watch
andupdateSnapshot
options.Babel
The
"default"
and"inherit"
configuration values have been removed. Babel options must now be specified in atestOptions
object. This will allow us to add source related options in the future.The
powerAssert
option and command line flags have been removed. You can now disable AVA's test enhancements by settingcompileEnhancements
tofalse
.The Babel recipe has been updated with the latest details.
Updated type definitions
The TypeScript and Flow definitions have been rewritten. The definitions export different interfaces so you may need to update your test code as well.
TypeScript now type-checks additional arguments used by macros. You must type the arguments used.
Internals
Some other internals have changed. You shouldn't have been relying on these, though if you did we're interested in hearing about it so we can better support your use case.
t._test
value has been removedOther potential breaking changes
@std/esm
, in favor of the plainesm
package.ava/stage-4
preset is applied after all other plugins and presets.null
as thethis
value.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.--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.async
/await
support.New recipes
There's a new recipe on using ES modules. We've also added a recipe on setting up tests and how test webapps using AVA and Puppeteer.
All changes 📚
v0.25.0...v1.0.1
Thanks 💌
💖 Huge thanks to @okyantoro, @JasonRitchie, @forresst, @mdvorscak, @kugtong33, @motss, @BusbyActual, @billyjanitsch, @Briantmorr, @jdalton, @malimichael, @martypdx, @clemtrek, @samuelli, @emilyschultz, @hallettj, @isnifer, @Jaden-Giordano, @good-idea, @jamiebuilds, @tobil, @TheDancingCode, @btkostner, @CanRau, @coreyfarrell, @ivanschwarz, @jagoda, @padmaia, @ronen, @sh7dm, @sharkykh, @Phrynobatrachus, @grant37, @xxczaki, @robertbernardbrown, @lo1tuma, @goooseman, @wmik, @vancouverwill, @qlonik, @vlajos and @itskolli 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.
Commits
The new version differs by 218 commits.
783944f
1.0.1
024bab7
1.0.0
aac41dc
Reword introduction
84d8fff
Bump dependencies & update documentation
c1364a1
Update the tagline and readme intro (#1983)
eed2e7a
Clarify that not all configuration options can be overridden by CLI flags
93e91c9
Fix 'sources' option in configuration docs
3bc80b0
Remove moot ESLint disable comment
311c197
Fix snapshot skip interface
0e82b04
1.0.0-rc.2
f97e277
Bump dependencies
6f54db8
Type additional arguments used by macros
a82fee5
Documentation updates
afe028a
CI updates
1ba31d8
Reorganize documentation
There are 218 commits in total.
See the full diff
FAQ and help
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper bot 🌴