Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: avajs/ava
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.2.1
Choose a base ref
...
head repository: avajs/ava
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.3.1
Choose a head ref
  • 14 commits
  • 22 files changed
  • 9 contributors

Commits on Feb 10, 2019

  1. Recognize snapshot files as source files

    Fixes #1511.
    itaisteinherz authored and novemberborn committed Feb 10, 2019

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    d066f6f View commit details

Commits on Feb 11, 2019

  1. Remove the typings field in package.json

    It's not needed as TypeScript infers the file just like Node.js does for `index.js`.
    sindresorhus authored and novemberborn committed Feb 11, 2019

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    2fce19f View commit details

Commits on Feb 14, 2019

  1. Update esm package detection

    jdalton authored and novemberborn committed Feb 14, 2019
    1

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    565822e View commit details
  2. Fix link to Babel recipe

    kagawagao authored and novemberborn committed Feb 14, 2019
    1

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    7d10446 View commit details

Commits on Feb 25, 2019

  1. Added few tests for lib/chalk.js

    Stanisław Jaros authored and novemberborn committed Feb 25, 2019

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    5751226 View commit details

Commits on Mar 3, 2019

  1. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    334e15b View commit details
  2. Fix unbound reference to clearTimeout

    Test code should be able to stuck the global clearTimeout() without breaking AVA.
    novemberborn committed Mar 3, 2019

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    40f331c View commit details
  3. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    d97f11d View commit details
  4. Document timeout configuration

    Fixes #2025.
    Chrisyee22 authored and novemberborn committed Mar 3, 2019

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    1e3b072 View commit details
  5. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    82daa5e View commit details

Commits on Mar 5, 2019

  1. Bump dependencies

    `tap@^12.5` caused test failures on my machine, so I'm selecting `~12.4` for now.
    
    A dependency update means Node.js 11 now writes experimental warnings. I haven't tracked it down yet but in order not to break the reporter tests I'm now discarding those from the recorded logs.
    
    The mini reporter tests break in Node.js 11 since it now writes output a little differently. I've disabled that test for Node.js 11.
    novemberborn authored Mar 5, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9600966 View commit details
  2. 1.3.0

    novemberborn committed Mar 5, 2019

    Verified

    This commit was signed with the committer’s verified signature.
    novemberborn Mark Wubben
    Copy the full SHA
    b0fadb4 View commit details
  3. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    9beb600 View commit details
  4. 1.3.1

    novemberborn committed Mar 5, 2019
    1

    Verified

    This commit was signed with the committer’s verified signature.
    novemberborn Mark Wubben
    Copy the full SHA
    960f4cd View commit details
8 changes: 5 additions & 3 deletions docs/06-configuration.md
Original file line number Diff line number Diff line change
@@ -60,17 +60,19 @@ Arguments passed to the CLI will always take precedence over the CLI options con
- `compileEnhancements`: if `false`, disables [power-assert](https://github.com/power-assert-js/power-assert) — which otherwise helps provide more descriptive error messages — and detection of improper use of the `t.throws()` assertion
- `extensions`: extensions of test files that are not precompiled using AVA's Babel presets. Note that files are still compiled to enable power-assert and other features, so you may also need to set `compileEnhancements` to `false` if your files are not valid JavaScript. Setting this overrides the default `"js"` value, so make sure to include that extension in the list, as long as it's not included in `babel.extensions`
- `require`: extra modules to require before tests are run. Modules are required in the [worker processes](./01-writing-tests.md#process-isolation)
- `babel`: test file specific Babel options. See our [Babel recipe] for more details
- `babel`: test file specific Babel options. See our [Babel recipe](./recipes/babel.md#configuring-babel) for more details
- `babel.extensions`: extensions of test files that will be precompiled using AVA's Babel presets. Setting this overrides the default `"js"` value, so make sure to include that extension in the list
- `timeout`: Timeouts in AVA behave differently than in other test frameworks. AVA resets a timer after each test, forcing tests to quit if no new test results were received within the specified timeout. This can be used to handle stalled tests. See our [timeout documentation](./07-test-timeouts.md) for more options.

Note that providing files on the CLI overrides the `files` option. If you've configured a glob pattern, for instance `test/**/*.test.js`, you may want to repeat it when using the CLI: `ava 'test/integration/*.test.js'`.

## Using `ava.config.js`

To use an `ava.config.js` file:

1. It must be in the same directory as your `package.json`
2. Your `package.json` must not contain an `ava` property (or, if it does, it must be an empty object)
1. It must be in the same directory as your `package.json`
2. Your `package.json` must not contain an `ava` property (or, if it does, it must be an empty object)
3. You must use `export default`, though [`require()`](https://nodejs.org/api/modules.html#modules_require_id) is available to load non-ES modules

The config file must have a default export, using ES modules. It can either be a plain object or a factory function which returns a plain object:

2 changes: 1 addition & 1 deletion docs/recipes/flow.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ Translations: [Français](https://github.com/avajs/ava-docs/blob/master/fr_FR/do

AVA comes bundled with a Flow definition file. This allows developers to leverage Flow for writing tests.

This guide assumes you've already set up Flow for your project. Note that AVA's definition as been tested with version 0.91.0.
This guide assumes you've already set up Flow for your project. Note that AVA's definition as been tested with version 0.94.0.

We recommend you use AVA's built-in Babel pipeline to strip Flow type annotations and declarations. AVA automatically applies your project's Babel configuration, so everything may just work without changes. Alternatively install [`@babel/plugin-transform-flow-strip-types`](https://www.npmjs.com/package/@babel/plugin-transform-flow-strip-types) and customize AVA's configuration in the `package.json` file (or the `ava.config.js` file) as follows.

2 changes: 1 addition & 1 deletion docs/recipes/typescript.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ Translations: [Español](https://github.com/avajs/ava-docs/blob/master/es_ES/doc

AVA comes bundled with a TypeScript definition file. This allows developers to leverage TypeScript for writing tests.

This guide assumes you've already set up TypeScript for your project. Note that AVA's definition has been tested with version 3.2.4.
This guide assumes you've already set up TypeScript for your project. Note that AVA's definition has been tested with version 3.3.3333.

## Configuring AVA to compile TypeScript files on the fly

2 changes: 1 addition & 1 deletion lib/assert.js
Original file line number Diff line number Diff line change
@@ -215,7 +215,7 @@ function assertExpectations({assertion, actual, expectations, message, prefix, s
});
}

if (typeof expectations.code === 'string' && actual.code !== expectations.code) {
if (typeof expectations.code !== 'undefined' && actual.code !== expectations.code) {
throw new AssertionError({
assertion,
message,
2 changes: 1 addition & 1 deletion lib/ava-files.js
Original file line number Diff line number Diff line change
@@ -171,7 +171,7 @@ class AvaFiles {

// Same defaults as used for Chokidar
if (!hasPositivePattern) {
mixedPatterns = ['package.json', '**/*.js'].concat(mixedPatterns);
mixedPatterns = ['package.json', '**/*.js', '**/*.snap'].concat(mixedPatterns);
}

filePath = matchable(filePath);
10 changes: 9 additions & 1 deletion lib/load-config.js
Original file line number Diff line number Diff line change
@@ -15,7 +15,15 @@ function loadConfig(defaults = {}) {
let fileConf;
try {
({default: fileConf = MISSING_DEFAULT_EXPORT} = esm(module, {
cjs: false,
cjs: {
cache: false,
extensions: false,
interop: false,
mutableNamespace: false,
namedExports: false,
paths: false,
vars: true
},
force: true,
mode: 'all'
})(path.join(projectDir, 'ava.config.js')));
2 changes: 1 addition & 1 deletion lib/test.js
Original file line number Diff line number Diff line change
@@ -278,7 +278,7 @@ class Test {
}

clearTimeout() {
clearTimeout(this.timeoutTimer);
nowAndTimers.clearTimeout(this.timeoutTimer);
this.timeoutTimer = null;
}

3 changes: 2 additions & 1 deletion lib/worker/subprocess.js
Original file line number Diff line number Diff line change
@@ -111,7 +111,8 @@ ipc.options.then(options => {
const required = require(mod);

try {
if (required[Symbol.for('esm\u200D:package')]) {
if (required[Symbol.for('esm:package')] ||
required[Symbol.for('esm\u200D:package')]) {
require = required(module); // eslint-disable-line no-global-assign
}
} catch (_) {}
5,287 changes: 1,127 additions & 4,160 deletions package-lock.json

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ava",
"version": "1.2.1",
"version": "1.3.1",
"description": "Testing can be a drag. AVA helps you get it done.",
"license": "MIT",
"repository": "avajs/ava",
@@ -63,21 +63,21 @@
"@ava/babel-preset-stage-4": "^2.0.0",
"@ava/babel-preset-transform-test-files": "^4.0.1",
"@ava/write-file-atomic": "^2.2.0",
"@babel/core": "^7.2.2",
"@babel/generator": "^7.3.0",
"@babel/core": "^7.3.4",
"@babel/generator": "^7.3.4",
"@babel/plugin-syntax-async-generators": "^7.2.0",
"@babel/plugin-syntax-object-rest-spread": "^7.2.0",
"@babel/plugin-syntax-optional-catch-binding": "^7.2.0",
"@concordance/react": "^2.0.0",
"ansi-escapes": "^3.1.0",
"ansi-escapes": "^3.2.0",
"ansi-styles": "^3.2.1",
"arr-flatten": "^1.1.0",
"array-union": "^1.0.1",
"array-uniq": "^2.0.0",
"arrify": "^1.0.0",
"bluebird": "^3.5.3",
"chalk": "^2.4.2",
"chokidar": "^2.0.4",
"chokidar": "^2.1.2",
"chunkd": "^1.0.0",
"ci-parallel-vars": "^1.0.0",
"clean-stack": "^2.0.0",
@@ -90,16 +90,16 @@
"convert-source-map": "^1.6.0",
"currently-unhandled": "^0.4.1",
"debug": "^4.1.1",
"del": "^3.0.0",
"del": "^4.0.0",
"dot-prop": "^4.2.0",
"emittery": "^0.4.1",
"empower-core": "^1.2.0",
"equal-length": "^1.0.0",
"escape-string-regexp": "^1.0.5",
"esm": "^3.1.3",
"esm": "^3.2.10",
"figures": "^2.0.0",
"find-up": "^3.0.0",
"get-port": "^4.1.0",
"get-port": "^4.2.0",
"globby": "^7.1.1",
"ignore-by-default": "^1.0.0",
"import-local": "^2.0.0",
@@ -116,16 +116,16 @@
"lodash.difference": "^4.3.0",
"lodash.flatten": "^4.2.0",
"loud-rejection": "^1.2.0",
"make-dir": "^1.3.0",
"make-dir": "^2.1.0",
"matcher": "^1.1.1",
"md5-hex": "^2.0.0",
"meow": "^5.0.0",
"ms": "^2.1.1",
"multimatch": "^3.0.0",
"observable-to-promise": "^0.5.0",
"ora": "^3.0.0",
"ora": "^3.2.0",
"package-hash": "^3.0.0",
"pkg-conf": "^2.1.0",
"pkg-conf": "^3.0.0",
"plur": "^3.0.1",
"pretty-ms": "^4.0.0",
"require-precompiled": "^0.1.0",
@@ -144,37 +144,37 @@
},
"devDependencies": {
"cli-table3": "^0.5.1",
"codecov": "^3.1.0",
"codecov": "^3.2.0",
"delay": "^4.1.0",
"execa": "^1.0.0",
"flow-bin": "^0.91.0",
"flow-bin": "^0.94.0",
"get-stream": "^4.1.0",
"git-branch": "^2.0.1",
"has-ansi": "^3.0.0",
"lolex": "^3.0.0",
"nyc": "^13.1.0",
"lolex": "^3.1.0",
"nyc": "^13.3.0",
"proxyquire": "^2.1.0",
"react": "^16.7.0",
"react-test-renderer": "^16.7.0",
"react": "^16.8.3",
"react-test-renderer": "^16.8.3",
"replace-string": "^2.0.0",
"signal-exit": "^3.0.0",
"sinon": "^7.2.3",
"sinon": "^7.2.7",
"source-map-fixtures": "^2.1.0",
"tap": "^12.4.0",
"tap": "~12.4.1",
"temp-write": "^3.4.0",
"touch": "^3.1.0",
"ts-node": "^8.0.2",
"typescript": "^3.2.4",
"typescript": "^3.3.3333",
"xo": "^0.24.0",
"zen-observable": "^0.8.13"
},
"typings": "index.d.ts",
"xo": {
"ignores": [
"media/**",
"test/fixture/ava-paths/target/test.js",
"test/fixture/{source-map-initial,syntax-error}.js",
"test/fixture/snapshots/test-sourcemaps/build/**",
"test/fixture/power-assert.js",
"**/*.ts",
"test/flow-types/*"
],
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -184,7 +184,7 @@ In contrast AVA is highly opinionated and runs tests concurrently, with a separa

### How is the name written and pronounced?

AVA, not Ava or ava. Pronounced [/ˈeɪvə/ ay-və](media/pronunciation.m4a?raw=true).
AVA, not Ava or ava. Pronounced [`/ˈeɪvə/`](media/pronunciation.m4a?raw=true): Ay (f**a**ce, m**a**de) V (**v**ie, ha**v**e) A (comm**a**, **a**go)

### What is the header background?

8 changes: 8 additions & 0 deletions test/assert.js
Original file line number Diff line number Diff line change
@@ -858,6 +858,14 @@ test('.throws()', gather(t => {
throw err;
}, {code: 'ERR_TEST'});
});

fails(t, () => {
assertions.throws(() => {
const err = new TypeError();
err.code = 1;
throw err;
}, {code: 42});
});
}));

test('.throws() returns the thrown error', t => {
3 changes: 3 additions & 0 deletions test/ava-files.js
Original file line number Diff line number Diff line change
@@ -73,6 +73,9 @@ test('sourceMatcher - defaults', t => {
isSource('fixtures/foo.js');
isSource('helpers/foo.js');

isSource('snapshots/foo.js.snap');
isSource('snapshots/bar.js.snap');

// TODO: Watcher should probably track any required file that matches the source pattern and has a require extension installed for the given extension.
notSource('foo-bar.json');
notSource('foo-bar.coffee');
14 changes: 14 additions & 0 deletions test/chalk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';
const {test} = require('tap');
const chalk = require('../lib/chalk');

test('throws an error when trying to access chalk config and chalk config is not configured', t => {
t.throws(chalk.get, 'Chalk has not yet been configured');
t.end();
});

test('throws an error when trying to set chalk config and chalk config is configured', t => {
chalk.set({});
t.throws(chalk.set, 'Chalk has already been configured');
t.end();
});
3 changes: 3 additions & 0 deletions test/fixture/load-config/require/ava.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const config = require('./cjs');

export default config;
3 changes: 3 additions & 0 deletions test/fixture/load-config/require/cjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
files: 'config-file-cjs-test-value'
};
1 change: 1 addition & 0 deletions test/fixture/load-config/require/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions test/helper/report.js
Original file line number Diff line number Diff line change
@@ -64,6 +64,7 @@ exports.assert = (t, logFile, buffer, stripOptions) => {

exports.sanitizers = {
cwd: str => replaceString(str, process.cwd(), '~'),
experimentalWarning: str => str.replace(/^\(node:\d+\) ExperimentalWarning.+\n/g, ''),
lineEndings: str => replaceString(str, '\r\n', '\n'),
posix: str => replaceString(str, '\\', '/'),
slow: str => str.replace(/(slow.+?)\(\d+m?s\)/g, '$1 (000ms)'),
7 changes: 7 additions & 0 deletions test/load-config.js
Original file line number Diff line number Diff line change
@@ -52,6 +52,13 @@ test('loads config from factory function', t => {
t.end();
});

test('supports require() inside config file', t => {
changeDir('require');
const conf = loadConfig();
t.is(conf.files, 'config-file-cjs-test-value');
t.end();
});

test('throws an error if a config factory returns a promise', t => {
changeDir('factory-no-promise-return');
t.throws(loadConfig);
7 changes: 6 additions & 1 deletion test/reporters/mini.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,11 @@
require('../helper/report').captureStdIOReliability();
require('../helper/fix-reporter-env')();

// Excessive writes occur in Node.js 11. These don't have a visual impact but prevent the integration tests from passing.
if (process.version.startsWith('v11')) {
process.exit(0); // eslint-disable-line unicorn/no-process-exit
}

const path = require('path');
const {test} = require('tap');
const TTYStream = require('../helper/tty-stream');
@@ -15,7 +20,7 @@ const run = (type, sanitizers = []) => t => {

const tty = new TTYStream({
columns: 200,
sanitizers: [...sanitizers, report.sanitizers.cwd, report.sanitizers.posix, report.sanitizers.unreliableProcessIO, report.sanitizers.version]
sanitizers: [...sanitizers, report.sanitizers.cwd, report.sanitizers.experimentalWarning, report.sanitizers.posix, report.sanitizers.unreliableProcessIO, report.sanitizers.version]
});
const reporter = new MiniReporter({
spinner: {
2 changes: 1 addition & 1 deletion test/reporters/tap.js
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ const run = (type, sanitizers = []) => t => {

const tty = new TTYStream({
columns: 200,
sanitizers: [...sanitizers, report.sanitizers.cwd, report.sanitizers.posix, report.sanitizers.unreliableProcessIO]
sanitizers: [...sanitizers, report.sanitizers.cwd, report.sanitizers.experimentalWarning, report.sanitizers.posix, report.sanitizers.unreliableProcessIO]
});
const reporter = new TapReporter({
reportStream: tty,
2 changes: 1 addition & 1 deletion test/reporters/verbose.js
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ const run = (type, sanitizers = []) => t => {

const tty = new TTYStream({
columns: 200,
sanitizers: [...sanitizers, report.sanitizers.cwd, report.sanitizers.posix, report.sanitizers.slow, report.sanitizers.unreliableProcessIO, report.sanitizers.version]
sanitizers: [...sanitizers, report.sanitizers.cwd, report.sanitizers.experimentalWarning, report.sanitizers.posix, report.sanitizers.slow, report.sanitizers.unreliableProcessIO, report.sanitizers.version]
});
const reporter = new VerboseReporter({
reportStream: tty,