Skip to content
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

Allow CJS ava.config.js #1820

Closed
billyjanitsch opened this issue May 30, 2018 · 26 comments
Closed

Allow CJS ava.config.js #1820

billyjanitsch opened this issue May 30, 2018 · 26 comments
Labels

Comments

@billyjanitsch
Copy link
Contributor

Description

I noticed that #1761 landed requiring ava.config.js to use ESM (export default rather than module.exports =). I read through the thread, and I guess I can understand wanting to support ESM, but what was the motivation for making it a requirement?

Most other libraries only support CJS configs, and I don't know of any that only allow ESM. It seems odd to require AVA's config to be written differently than all other config files in a typical repo.

@novemberborn
Copy link
Member

It's an aversion from having too many ways of specifying config. Though perhaps odd at first, hopefully it's actually fine in practice. Let's use this issue to see if there are any problems and then we can add support for module.exports = {}.

@billyjanitsch
Copy link
Contributor Author

billyjanitsch commented May 30, 2018

It's an aversion from having too many ways of specifying config.

I have the same aversion, but from the perspective of a user using multiple tools in projects. I try to write my config files similarly to each other, so that they're easy to write, read, and modify. This becomes difficult when tools have divergent config formats.

So, from my perspective, ESM is a different way of specifying config, in that it's different from other tools, e.g. webpack, Babel, postcss, ESLint, stylelint, husky.

(That's why I'm a big fan of cosmiconfig, which is already used by many of the above -- by default, it supports a well-known, conventional set of formats which strike a good balance between user flexibility and complexity. It also reduces the burden on module authors to implement config lookup/loading, and provides consistent lookup/loading behavior between tools.)

I understand the tradeoff on simplicity, and I know that @sindresorhus has a strong preference for it. But if AVA is determined to support a single format, would you consider only supporting CJS? I'd think this would be the expected behavior at least until ESM is widely embraced in node (whether via esm, .mjs, or something else). Until then, this doesn't seem like a useful divergence.

@billyjanitsch
Copy link
Contributor Author

Thanks for the discussion, by the way -- thrilled to be getting file-based config in any case.

@sindresorhus
Copy link
Member

I don't really see the problem here. AVA has had built-in ESM support for years, so AVA users are used to using it. Extending it to the config makes sense in that way.

@cantremember
Copy link

cantremember commented Jul 7, 2018

on a possibly related note ... i nearly had had to downgrade my package.json's 'esm' configuration from { mode: "strict" } to "auto" because

  • (at least according to the documentation I have read) there is no ava --config <CONFIG-FILE> CLI option,
  • the file must be named 'ava.config.js'
  • "strict" enforces an '.mjs' extension on files which use ESM syntax

if a CSJ export was supported, this wouldn't be an issue. fortunately i have the fallback to use the { ava } configuration option in package.json -- and that allows me to keep "strict"

on a related but tangential note, i have (so far) had no success in telling ava to glob for 'test/ava/*.mjs'

[x] Couldn't find any files to test

i have just started to integrate ava, so i could be making foolish mistakes / not RTFM properly

@novemberborn
Copy link
Member

@cantremember thanks for the report. I suspect this is an issue with esm itself. I've opened standard-things/esm#501.

@vjpr
Copy link

vjpr commented Aug 5, 2018

I'm trying to use require.resolve in the config and getting require is not defined. Is this related, and is there a workaround?

@novemberborn
Copy link
Member

@vjpr I imagine it is, yea.

What are you hoping to achieve?

esm does expose an import.meta object I believe.

@vjpr
Copy link

vjpr commented Aug 5, 2018

I need to require.resolve a babel plugin, because its trying to resolve from the project root, and I want it to resolve in a monorepo subpackage.

@novemberborn
Copy link
Member

It's not ideal but perhaps you could use https://www.npmjs.com/package/resolve-from?

Or maybe it's possible to provide a relative path to the plugin? Assuming this goes into AVA's Babel pipeline, I'd expect it to be resolved relative to the project directory, so you should be able to reference the subpackage.

@vjpr
Copy link

vjpr commented Aug 5, 2018

I'll try resolve-from. Why is require.resolve not available though?

@novemberborn
Copy link
Member

@vjpr I reckon esm (which we use to load the ava.config.js files) masks it.

bors bot added a commit to IMA-WorldHealth/Tree that referenced this issue 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 &amp; weddings, work &amp; 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> &amp; <a href="https://twitter.com/sindresorhus" rel="nofollow">Sindre</a></p>
<h2>What's new &amp; improved</h2>
<h3>Assertions</h3>
<h4>New <code>t.throws()</code> behavior &amp; <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">=&gt;</span> {
  <span class="pl-smi">arr</span>.<span class="pl-c1">forEach</span>(<span class="pl-smi">value</span> <span class="pl-k">=&gt;</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">=&gt;</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">=&gt;</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 &amp; 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 &amp; 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>&lt;React.Fragment&gt;</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>&lt;[<span class="pl-en">Buffer</span>]&gt; <span class="pl-k">=</span> (<span class="pl-v">t</span>, <span class="pl-v">input</span>) <span class="pl-k">=&gt;</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">=&gt;</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 &amp; 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>&lt;React.Fragment&gt;</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">=&gt;</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">=&gt;</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">=&gt;</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">=&gt;</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> &amp; <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 &amp; 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>
@vjpr
Copy link

vjpr commented Jan 26, 2019

I'm still having a lot of trouble with this. I have an es5 library in my codebase that needs to run in the ava.config.js file, but it seems its not possible.

Why do we not allow cjs features when using esm to load the config?

@sindresorhus
Copy link
Member

@vjpr What is the exact problem/error?

@vjpr
Copy link

vjpr commented Jan 26, 2019

SyntaxError: The requested module 'file:///xxx/bar.js' does not provide an export named 'attempt'

ava.config.js

export {default} from './foo.js'

foo.js

import {attempt} from './bar'
export default 1

bar.js

exports.attempt = 1

@novemberborn
Copy link
Member

I agree that should work, @vjpr.

It's an interesting problem. Our default Babel pipeline supports importing from CJS, with __esModule interoperability. But, we don't want to apply that to loading the config file, especially if Babel is disabled through that file.

Between ESM, CJS and interoperability there's a lot of ways a config file could be written. At least ESM is more forward looking, and we can use the esm module to load the file without any other precompilation.

Currently esm is configured to only allow ESM modules. That way we don't introduce any non-standard behavior or rely on esm implementation details. It's great if you're already using esm in the rest of your codebase but of course that's not necessarily the case.

Looking at the esm options we could enable the cjs.vars option. That would expose __dirname, __filename and require to the ava.config.js file and other imported ESM modules. That'll allow you to use require() to load CJS modules.

Would this work for you?

Another option is to run esm in full compatibility mode, or just inherit the esm settings in your project. The downside is that it really couples us to esm's behavior.

@sindresorhus what do you think?

@vjpr
Copy link

vjpr commented Jan 27, 2019 via email

@ghost
Copy link

ghost commented Jan 29, 2019

I don't understand the advantages of using ESM. I was looking at the docs and it just looks like syntactic sugar. Am I missing something?

@sindresorhus
Copy link
Member

Looking at the esm options we could enable the cjs.vars option. That would expose __dirname, __filename and require to the ava.config.js file

Let's go with this.

@vjpr
Copy link

vjpr commented Jan 31, 2019

@novemberborn Could you make the change and then publish an alpha. I will test it on my setup.

@ehmicky
Copy link

ehmicky commented Feb 25, 2019

@novemberborn
Let's use this issue to see if there are any problems and then we can add support for module.exports = {}.

I am running into the following problem related to not being able to use module.exports:

I need to use an ava.config.js. It has some logic in it, i.e. I cannot use an ava property in package.json instead. My codebase is written with CJS. This leads me to run ESLint on my repositories JavaScript files with the sourceType option set to script (not module).

This results in the following problem: ava.config.js cannot be parsed by ESLint because it's written with ES modules while the other files are using CJS. My current workaround is to fire ESLint twice with different options, but this is not great and complicates my setup quite a bit when coupled with files watching.

Allowing the full compatibility mode of esm would solve this problem.

@novemberborn
Copy link
Member

My current workaround is to fire ESLint twice with different options, but this is not great and complicates my setup quite a bit when coupled with files watching.

You can use overrides to switch the source type:

{
  'overrides': [
    {
      'files': ['ava.config.js'],
      'parserOptions': {
        'sourceType': 'module',
      },
    },
}

@ehmicky
Copy link

ehmicky commented Feb 25, 2019

Thanks! This works.

@vjpr
Copy link

vjpr commented Mar 11, 2019

Just tried this out and it didn't solve all my problems.

When reading the config, it seems to be enforcing strict mode which is breaking my usage of the caller-id package.

TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them

It also doesn't seem to work with the module-alias plugin.

const moduleAlias = require('module-alias')
moduleAlias.addAlias('+config', join(getRepoRoot(), 'packages/config'))

...

require('+config/foo')
Error while loading config - Cannot find module '+config/foo'

@novemberborn Can you take a look?

@novemberborn
Copy link
Member

@vjpr could you share fuller samples of your config files?

vladimiry added a commit to vladimiry/ElectronMail that referenced this issue Jun 7, 2019
* unfortunately "ava" config is still in pacakge.json as it doesn't support "cosmiconfig" but only "ava.config.js" which is not an option:
- avajs/ava#1820
- avajs/ava#520
@novemberborn
Copy link
Member

As per #2293 we'll be adding support for ava.config.js files.

devDefiWeb added a commit to devDefiWeb/electron-mail-app that referenced this issue May 28, 2022
* unfortunately "ava" config is still in pacakge.json as it doesn't support "cosmiconfig" but only "ava.config.js" which is not an option:
- avajs/ava#1820
- avajs/ava#520
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants