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: v0.24.0
Choose a base ref
...
head repository: avajs/ava
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.25.0
Choose a head ref
  • 15 commits
  • 28 files changed
  • 12 contributors

Commits on Nov 28, 2017

  1. Update npm, test Node.js 9, detect package-lock churn in CI (#1601)

    * Use npm@5.6.0 in CI
    
    * Detect package-lock.json churn during CI
    
    * Add Node.js 9 to CI matrix
    
    * Used npx to run codecov
    novemberborn authored and sindresorhus committed Nov 28, 2017

    Unverified

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

Commits on Dec 17, 2017

  1. Use supertap to generate TAP output (#1610)

    Vadim Demedes authored Dec 17, 2017

    Verified

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

Commits on Dec 28, 2017

  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
    4e8f827 View commit details

Commits on Jan 3, 2018

  1. Copy the full SHA
    c1faf95 View commit details

Commits on Jan 8, 2018

  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
    29e5dfd View commit details
  2. support @std/esm (#1618)

    * support @std/esm
    
    * fix path test for windows
    
    * fix linter error
    
    * Stricter regex. Use shorthand .esmrc file in fixture.
    
    * update package-lock.json
    jamestalmage authored Jan 8, 2018
    2

    Verified

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

Commits on Jan 16, 2018

  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
    aaddc37 View commit details

Commits on Jan 17, 2018

  1. Copy the full SHA
    4a13966 View commit details

Commits on Jan 20, 2018

  1. Update code-excerpt to ^2.1.1

    kugtong33 authored and novemberborn committed Jan 20, 2018

    Unverified

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

Commits on Jan 21, 2018

  1. Copy the full SHA
    cd8c91b View commit details

Commits on Jan 22, 2018

  1. Recommend skipFiles for VSCode debugging

    VSCode steps into native code at each `await` statement.  using skipFiles on node_internals yields a more dev-expected debug experience.
    cdaringe authored and novemberborn committed Jan 22, 2018

    Unverified

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

Commits on Jan 24, 2018

  1. Mention #1319 as a pitfall

    jy95 authored and novemberborn committed Jan 24, 2018

    Unverified

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

Commits on Jan 25, 2018

  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
    f00f3c4 View commit details
  2. Unverified

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

Commits on Jan 26, 2018

  1. 0.25.0

    novemberborn committed Jan 26, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    novemberborn Mark Wubben
    Copy the full SHA
    a051d3e View commit details
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -3,3 +3,4 @@ node_modules
coverage
bench/.results
types/generated.d.ts
/package-lock.json.md5
20 changes: 16 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: node_js
node_js:
- 9
- 8
- 6
- 4
@@ -8,6 +9,8 @@ env:
- FRESH_DEPS=true
matrix:
exclude:
- node_js: 9
env: FRESH_DEPS=true
- node_js: 6
env: FRESH_DEPS=true
- node_js: 4
@@ -16,8 +19,17 @@ cache:
directories:
- $HOME/.npm
before_install:
- npm install --global npm@5.4.2
- npm install --global npm@5.6.0
- npm --version
install:
- if [[ ${FRESH_DEPS} == "true" ]]; then npm install --no-shrinkwrap --prefer-online; else npm install --prefer-offline; fi
after_success: ./node_modules/.bin/codecov --file=./coverage/lcov.info
- md5sum package-lock.json > package-lock.json.md5
install: |
if [[ ${FRESH_DEPS} == "true" ]]; then
npm install --no-shrinkwrap --prefer-online;
else
npm install --prefer-offline;
if ! md5sum --quiet -c package-lock.json.md5; then
echo "package-lock.json was modified unexpectedly. Please rebuild it using npm@$(npm -v) and commit the changes.";
exit 1;
fi
fi
after_success: npx codecov --file=./coverage/lcov.info
5 changes: 4 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -11,19 +11,22 @@ configuration:
- LockedDeps
environment:
matrix:
- nodejs_version: 9
- nodejs_version: 8
- nodejs_version: 6
- nodejs_version: 4
matrix:
fast_finish: true
exclude:
- configuration: FreshDeps
nodejs_version: 9
- configuration: FreshDeps
nodejs_version: 6
- configuration: FreshDeps
nodejs_version: 4
install:
- ps: Install-Product node $env:nodejs_version
- npm install --global npm@5.4.2
- npm install --global npm@5.6.0
- npm --version
- git config core.symlinks true
- git reset --hard
2 changes: 1 addition & 1 deletion cli.js
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ if (importLocal(__filename)) {
debug('Using local install of AVA');
} else {
if (debug.enabled) {
require('time-require'); // eslint-disable-line import/no-unassigned-import
require('@ladjs/time-require'); // eslint-disable-line import/no-unassigned-import
}

try {
2 changes: 2 additions & 0 deletions contributing.md
Original file line number Diff line number Diff line change
@@ -40,6 +40,8 @@ You may find an issue is assigned, or has the [`assigned` label](https://github.

We'd like to fix [`priority` issues](https://github.com/avajs/ava/labels/priority) first. We'd love to see progress on [`low-priority` issues](https://github.com/avajs/ava/labels/low%20priority) too. [`future` issues](https://github.com/avajs/ava/labels/future) are those that we'd like to get to, but not anytime soon. Please check before working on these since we may not yet want to take on the burden of supporting those features.

If you're updating dependencies, please make sure you use npm@5.6.0 and commit the updated `package-lock.json` file.

### Hang out in our chat

We have a [chat](https://gitter.im/avajs/ava). Jump in there and lurk, talk to us, and help others.
4 changes: 4 additions & 0 deletions docs/common-pitfalls.md
Original file line number Diff line number Diff line change
@@ -75,6 +75,10 @@ test(t => {
});
```

### Helpers are not compiled when using a non-default test folder

This is a [known issue](https://github.com/avajs/ava/issues/1319). You should put your tests in a folder called `test` or `__tests__`.

---

Is your problem not listed here? Submit a pull request or comment on [this issue](https://github.com/avajs/ava/issues/404).
2 changes: 2 additions & 0 deletions docs/recipes/babelrc.md
Original file line number Diff line number Diff line change
@@ -36,6 +36,8 @@ You can override the default Babel configuration AVA uses for test transpilation
}
```

Note that this only affects how AVA transpiles your tests. If you use `babel-register` you'll still need to add separate Babel configuration as explained [here](#transpiling-sources).

## Use Babel Polyfills

AVA lets you write your tests using new JavaScript syntax, even on Node.js versions that otherwise wouldn't support it. However, it doesn't add or modify built-ins of your current environment. Using AVA would, for example, not provide modern features such as `Array.prototype.includes()` to an underlying Node.js 4 environment.
25 changes: 25 additions & 0 deletions docs/recipes/debugging-with-vscode.md
Original file line number Diff line number Diff line change
@@ -18,6 +18,9 @@ Add following to the `configurations` object:
"program": "${workspaceRoot}/node_modules/ava/profile.js",
"args": [
"${file}"
],
"skipFiles": [
"<node_internals>/**/*.js"
]
}
```
@@ -33,3 +36,25 @@ Save this configuration after you added it.
Set breakpoints in the code **or** write `debugger;` at the point where it should stop.

Hit the green `Debug` button next to the list of configurations on the top left in the `Debug` view. Once the breakpoint is hit, you can evaluate variables and step through the code.

## Serial debugging

By default AVA runs tests concurrently. This may complicate debugging. Add a configuration with the `--serial` argument so AVA runs only one test at a time:

```json
{
"type": "node",
"request": "launch",
"name": "Run AVA test serially",
"program": "${workspaceRoot}/node_modules/ava/profile.js",
"args": [
"--serial",
"${file}"
],
"skipFiles": [
"<node_internals>/**/*.js"
]
}
```

*Note that, if your tests aren't properly isolated, certain test failures may not appear when running the tests serially.*
2 changes: 1 addition & 1 deletion docs/recipes/precompiling-with-webpack.md
Original file line number Diff line number Diff line change
@@ -222,7 +222,7 @@ npm scripts:
{
"scripts": {
"precompile-src": "cross-env NODE_ENV=test babel src --out-dir _src",
"precompile-tests": "cross-env NODE_ENV=test webpack --config webpack.config.test.js",
"precompile-tests": "cross-env NODE_ENV=test webpack --config webpack.config.js",
"pretest": "npm run precompile-src && npm run precompile-tests",
"test": "cross-env NODE_ENV=test nyc --cache ava _build"
}
2 changes: 1 addition & 1 deletion index.js.flow
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ type TestContext = AssertContext & {
title: string;
plan(count: number): void;
skip: AssertContext;
log(message: string): void;
log(...values: Array<any>): void;
};
type ContextualTestContext = TestContext & { context: any; };
type ContextualCallbackTestContext = TestContext & { context: any; end(): void; };
20 changes: 18 additions & 2 deletions lib/assert.js
Original file line number Diff line number Diff line change
@@ -49,14 +49,22 @@ class AssertionError extends Error {

if (opts.stack) {
this.stack = opts.stack;
} else {
const limitBefore = Error.stackTraceLimit;
Error.stackTraceLimit = Infinity;
Error.captureStackTrace(this);
Error.stackTraceLimit = limitBefore;
}
}
}
exports.AssertionError = AssertionError;

function getStack() {
const limitBefore = Error.stackTraceLimit;
Error.stackTraceLimit = Infinity;
const obj = {};
Error.captureStackTrace(obj, getStack);
Error.stackTraceLimit = limitBefore;
return obj.stack;
}

@@ -122,8 +130,16 @@ function wrapAssertions(callbacks) {
}
},

log(text) {
log(this, text);
log() {
const args = Array.from(arguments, value => {
return typeof value === 'string' ?
value :
concordance.format(value, concordanceOptions);
});

if (args.length > 0) {
log(this, args.join(' '));
}
},

deepEqual(actual, expected, message) {
4 changes: 1 addition & 3 deletions lib/caching-precompiler.js
Original file line number Diff line number Diff line change
@@ -76,9 +76,7 @@ class CachingPrecompiler {

// Append source map comment to transformed code
// So that other libraries (like nyc) can find the source map
const dirPath = path.dirname(filePath);
const relativeMapPath = path.relative(dirPath, mapPath);
const comment = convertSourceMap.generateMapFileComment(relativeMapPath);
const comment = convertSourceMap.generateMapFileComment(mapPath);

return `${result.code}\n${comment}`;
}
2 changes: 0 additions & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -23,8 +23,6 @@ worker.setRunner(runner);
// that no more tests should be logged
let isFailed = false;

Error.stackTraceLimit = Infinity;

function test(props) {
if (isFailed) {
return;
4 changes: 2 additions & 2 deletions lib/process-adapter.js
Original file line number Diff line number Diff line change
@@ -48,13 +48,13 @@ if (opts.tty) {
}

if (debug.enabled) {
// Forward the `time-require` `--sorted` flag.
// Forward the `@ladjs/time-require` `--sorted` flag.
// Intended for internal optimization tests only.
if (opts._sorted) {
process.argv.push('--sorted');
}

require('time-require'); // eslint-disable-line import/no-unassigned-import
require('@ladjs/time-require'); // eslint-disable-line import/no-unassigned-import
}

const sourceMapCache = new Map();
89 changes: 25 additions & 64 deletions lib/reporters/tap.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';
const format = require('util').format;
const indentString = require('indent-string');
const supertap = require('supertap');
const stripAnsi = require('strip-ansi');
const yaml = require('js-yaml');

function dumpError(error, includeMessage) {
const obj = Object.assign({}, error.object);
@@ -32,7 +30,7 @@ function dumpError(error, includeMessage) {
obj.at = error.stack.split('\n')[0];
}

return ` ---\n${indentString(yaml.safeDump(obj).trim(), 4)}\n ...`;
return obj;
}

class TapReporter {
@@ -41,79 +39,42 @@ class TapReporter {
}

start() {
return 'TAP version 13';
return supertap.start();
}

test(test) {
const output = [];

let directive = '';
const passed = test.todo ? 'not ok' : 'ok';

if (test.todo) {
directive = '# TODO';
} else if (test.skip) {
directive = '# SKIP';
}

const title = stripAnsi(test.title);

const appendLogs = () => {
if (test.logs) {
test.logs.forEach(log => {
const logLines = indentString(log, 4);
const logLinesWithLeadingFigure = logLines.replace(
/^ {4}/,
' * '
);

output.push(logLinesWithLeadingFigure);
});
}
};

output.push(`# ${title}`);

if (test.error) {
output.push(format('not ok %d - %s', ++this.i, title));
appendLogs();
output.push(dumpError(test.error, true));
} else {
output.push(format('%s %d - %s %s', passed, ++this.i, title, directive).trim());
appendLogs();
}

return output.join('\n');
return supertap.test(test.title, {
passed: !test.error,
index: ++this.i,
todo: test.todo,
skip: test.skip,
comment: test.logs,
error: test.error ? dumpError(test.error, true) : null
});
}

unhandledError(err) {
const output = [
`# ${err.message}`,
format('not ok %d - %s', ++this.i, err.message)
];
let error;

// AvaErrors don't have stack traces
if (err.type !== 'exception' || err.name !== 'AvaError') {
output.push(dumpError(err, false));
error = dumpError(err, false);
}

return output.join('\n');
return supertap.test(err.message, {
passed: false,
index: ++this.i,
error
});
}

finish(runStatus) {
const output = [
'',
'1..' + (runStatus.passCount + runStatus.failCount + runStatus.skipCount),
'# tests ' + (runStatus.passCount + runStatus.failCount + runStatus.skipCount),
'# pass ' + runStatus.passCount
];

if (runStatus.skipCount > 0) {
output.push(`# skip ${runStatus.skipCount}`);
}

output.push('# fail ' + (runStatus.failCount + runStatus.rejectionCount + runStatus.exceptionCount), '');

return output.join('\n');
return supertap.finish({
passed: runStatus.passCount,
failed: runStatus.failCount,
skipped: runStatus.skipCount,
crashed: runStatus.rejectionCount + runStatus.exceptionCount
});
}

write(str) {
8 changes: 7 additions & 1 deletion lib/test-worker.js
Original file line number Diff line number Diff line change
@@ -27,7 +27,13 @@ globals.options = opts;

const serializeError = require('./serialize-error');

(opts.require || []).forEach(x => require(x));
(opts.require || []).forEach(x => {
if (/[/\\]@std[/\\]esm[/\\]index\.js$/.test(x)) {
require = require(x)(module); // eslint-disable-line no-global-assign
} else {
require(x);
}
});

adapter.installSourceMapSupport();
adapter.installPrecompilerHook();
Loading