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: v4.3.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: v4.3.1
Choose a head ref
  • 7 commits
  • 13 files changed
  • 4 contributors

Commits on Jun 6, 2022

  1. Copy the full SHA
    3f17f8c View commit details

Commits on Jun 7, 2022

  1. Copy the full SHA
    91f5254 View commit details

Commits on Jun 23, 2022

  1. Remove mentions of "callback mode" from docs

    The notion of callback mode was removed in v4, the remaining references to it in the documentation may confuse users.
    ericcornelissen authored Jun 23, 2022
    Copy the full SHA
    26a2e5d View commit details
  2. Document that AVA 4 cannot be run globally

    Co-authored-by: Mark Wubben <[email protected]>
    binyamin and novemberborn authored Jun 23, 2022
    Copy the full SHA
    ac0d75d View commit details

Commits on Jul 10, 2022

  1. Copy the full SHA
    3572342 View commit details
  2. Report error when parsing for line number selection

    This makes the failure a little less mysterious.
    novemberborn committed Jul 10, 2022
    Copy the full SHA
    d57c76c View commit details
  3. 4.3.1

    novemberborn committed Jul 10, 2022
    Copy the full SHA
    53e5709 View commit details
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -74,9 +74,9 @@ jobs:
- name: Test package-lock for unexpected modifications
run: |
npm -v
checksum=$(md5sum package-lock.json)
checksum=$(sha512sum package-lock.json)
npm install --package-lock-only --no-audit
if ! echo ${checksum} | md5sum --quiet -c -; then
if ! echo ${checksum} | sha512sum --quiet -c -; then
echo "package-lock.json was modified unexpectedly. Please rebuild it using npm@$(npm -v) and commit the changes."
exit 1
fi
4 changes: 1 addition & 3 deletions docs/01-writing-tests.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

Translations: [Français](https://github.com/avajs/ava-docs/blob/main/fr_FR/docs/01-writing-tests.md)

Tests are run concurrently. You can specify synchronous and asynchronous tests. Tests are considered synchronous unless you return a promise, an [observable](https://github.com/zenparsing/zen-observable), or declare it as a callback test.
Tests are run concurrently. You can specify synchronous and asynchronous tests. Tests are considered synchronous unless you return a promise or an [observable](https://github.com/zenparsing/zen-observable).

You must define all tests synchronously. They can't be defined inside `setTimeout`, `setImmediate`, etc.

@@ -73,8 +73,6 @@ test('promises the truth', async t => {

AVA comes with built-in support for [observables](https://github.com/zenparsing/es-observable). If you return an observable from a test, AVA will automatically consume it to completion before ending the test.

*You do not need to use "callback mode" or call `t.end()`.*

```js
test('handles observables', t => {
t.plan(3);
15 changes: 9 additions & 6 deletions docs/recipes/debugging-with-vscode.md
Original file line number Diff line number Diff line change
@@ -26,11 +26,12 @@ Alternatively you can create a launch configuration, which makes it easier to de
"type": "node",
"request": "launch",
"name": "Debug AVA test file",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/ava",
"runtimeArgs": [
"program": "${workspaceFolder}/node_modules/ava/entrypoints/cli.mjs",
"args": [
"${file}"
],
"outputCapture": "std",
"console": "integratedTerminal", // optional
"skipFiles": [
"<node_internals>/**/*.js"
]
@@ -55,11 +56,12 @@ Assuming the names of your test files are unique you could try the following con
"type": "node",
"request": "launch",
"name": "Debug AVA test file",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/ava",
"runtimeArgs": [
"program": "${workspaceFolder}/node_modules/ava/entrypoints/cli.mjs",
"args": [
"build/**/${fileBasenameNoExtension}.*"
],
"outputCapture": "std",
"console": "integratedTerminal", // optional
"skipFiles": [
"<node_internals>/**/*.js"
]
@@ -81,12 +83,13 @@ Or, if you're using a launch configuration, add the `--serial` argument:
"type": "node",
"request": "launch",
"name": "Debug AVA test file",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/ava",
"runtimeArgs": [
"program": "${workspaceFolder}/node_modules/ava/entrypoints/cli.mjs",
"args": [
"--serial",
"${file}"
],
"outputCapture": "std",
"console": "integratedTerminal", // optional
"skipFiles": [
"<node_internals>/**/*.js"
]
2 changes: 1 addition & 1 deletion docs/recipes/test-setup.md
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ You could do all these things using plain setup functions, but there are tradeof
|---|---
| ⛔️ &nbsp; used for all tests| ✅ &nbsp; can change or skip depending on test
| ⛔️ &nbsp; more overhead for beginners, "some magic"| ✅ &nbsp; easier for beginners, "no magic"
| ✅ &nbsp; supports callback mode, built-in support for observables| ⛔️ &nbsp; must use promises for asynchronous behavior
| ✅ &nbsp; built-in support for observables| ⛔️ &nbsp; must use promises for asynchronous behavior
| ✅ &nbsp; failure has friendly output| ⛔️ &nbsp; errors are attributed to the test
| ✅ &nbsp; corresponding `afterEach` and `afterEach.always` for cleanup| ⛔️ &nbsp; cannot easily clean up

3 changes: 3 additions & 0 deletions lib/reporters/default.js
Original file line number Diff line number Diff line change
@@ -220,6 +220,9 @@ export default class Reporter {
this.lineNumberErrors.push(event);

this.write(colors.information(`${figures.warning} Could not parse ${this.relativeFile(event.testFile)} for line number selection`));
this.lineWriter.writeLine();
this.lineWriter.writeLine(colors.errorStack(event.err.stack));
this.lineWriter.writeLine();
break;
}

7 changes: 7 additions & 0 deletions lib/worker/line-numbers.js
Original file line number Diff line number Diff line change
@@ -66,6 +66,13 @@ const translate = (sourceMap, pos) => {
}

const entry = sourceMap.findEntry(pos.line - 1, pos.column); // Source maps are 0-based

// When used with ts-node/register, we've seen entries without original values. Return the
// original position.
if (entry.originalLine === undefined || entry.originalColumn === undefined) {
return pos;
}

return {
line: entry.originalLine + 1, // Readjust for Acorn.
column: entry.originalColumn,
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ava",
"version": "4.3.0",
"version": "4.3.1",
"description": "Node.js test runner that lets you develop with confidence.",
"license": "MIT",
"repository": "avajs/ava",
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -66,6 +66,8 @@ Alternatively you can install `ava` manually:
npm install --save-dev ava
```

*Make sure to install AVA locally. As of AVA 4 it can no longer be run globally.*

Don't forget to configure the `test` script in your `package.json` as per above.

### Create your test file
14 changes: 13 additions & 1 deletion test-tap/reporters/default.edgecases.v12.log
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@

---tty-stream-chunk-separator
⚠ Could not parse ast-syntax-error.cjs for line number selection
---tty-stream-chunk-separator

SyntaxError: Unexpected token (3:11)
 at Parser.pp$4.raise (~/node_modules/acorn/dist/acorn.js:3462:15)
 at Parser.pp$9.unexpected (~/node_modules/acorn/dist/acorn.js:756:10)
 at Parser.pp$5.parseExprAtom (~/node_modules/acorn/dist/acorn.js:2837:12)
 at Parser.pp$5.parseExprSubscripts (~/node_modules/acorn/dist/acorn.js:2629:21)
 at Parser.pp$5.parseMaybeUnary (~/node_modules/acorn/dist/acorn.js:2595:19)
 at Parser.pp$5.parseExprOps (~/node_modules/acorn/dist/acorn.js:2522:21)
 at Parser.pp$5.parseMaybeConditional (~/node_modules/acorn/dist/acorn.js:2505:21)
 at Parser.pp$5.parseMaybeAssign (~/node_modules/acorn/dist/acorn.js:2472:21)
 at Parser.pp$8.parseVar (~/node_modules/acorn/dist/acorn.js:1299:26)
 at Parser.pp$8.parseVarStatement (~/node_modules/acorn/dist/acorn.js:1163:10)

---tty-stream-chunk-separator
Uncaught exception in ast-syntax-error.cjs

~/test-tap/fixture/report/edgecases/ast-syntax-error.cjs:3
14 changes: 13 additions & 1 deletion test-tap/reporters/default.edgecases.v14.log
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@

---tty-stream-chunk-separator
⚠ Could not parse ast-syntax-error.cjs for line number selection
---tty-stream-chunk-separator

SyntaxError: Unexpected token (3:11)
 at Parser.pp$4.raise (~/node_modules/acorn/dist/acorn.js:3462:15)
 at Parser.pp$9.unexpected (~/node_modules/acorn/dist/acorn.js:756:10)
 at Parser.pp$5.parseExprAtom (~/node_modules/acorn/dist/acorn.js:2837:12)
 at Parser.pp$5.parseExprSubscripts (~/node_modules/acorn/dist/acorn.js:2629:21)
 at Parser.pp$5.parseMaybeUnary (~/node_modules/acorn/dist/acorn.js:2595:19)
 at Parser.pp$5.parseExprOps (~/node_modules/acorn/dist/acorn.js:2522:21)
 at Parser.pp$5.parseMaybeConditional (~/node_modules/acorn/dist/acorn.js:2505:21)
 at Parser.pp$5.parseMaybeAssign (~/node_modules/acorn/dist/acorn.js:2472:21)
 at Parser.pp$8.parseVar (~/node_modules/acorn/dist/acorn.js:1299:26)
 at Parser.pp$8.parseVarStatement (~/node_modules/acorn/dist/acorn.js:1163:10)

---tty-stream-chunk-separator
Uncaught exception in ast-syntax-error.cjs

SyntaxError: Unexpected token 'do'
14 changes: 13 additions & 1 deletion test-tap/reporters/default.edgecases.v16.log
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@

---tty-stream-chunk-separator
⚠ Could not parse ast-syntax-error.cjs for line number selection
---tty-stream-chunk-separator

SyntaxError: Unexpected token (3:11)
 at Parser.pp$4.raise (~/node_modules/acorn/dist/acorn.js:3462:15)
 at Parser.pp$9.unexpected (~/node_modules/acorn/dist/acorn.js:756:10)
 at Parser.pp$5.parseExprAtom (~/node_modules/acorn/dist/acorn.js:2837:12)
 at Parser.pp$5.parseExprSubscripts (~/node_modules/acorn/dist/acorn.js:2629:21)
 at Parser.pp$5.parseMaybeUnary (~/node_modules/acorn/dist/acorn.js:2595:19)
 at Parser.pp$5.parseExprOps (~/node_modules/acorn/dist/acorn.js:2522:21)
 at Parser.pp$5.parseMaybeConditional (~/node_modules/acorn/dist/acorn.js:2505:21)
 at Parser.pp$5.parseMaybeAssign (~/node_modules/acorn/dist/acorn.js:2472:21)
 at Parser.pp$8.parseVar (~/node_modules/acorn/dist/acorn.js:1299:26)
 at Parser.pp$8.parseVarStatement (~/node_modules/acorn/dist/acorn.js:1163:10)

---tty-stream-chunk-separator
Uncaught exception in ast-syntax-error.cjs

SyntaxError: Unexpected token 'do'
14 changes: 13 additions & 1 deletion test-tap/reporters/default.edgecases.v18.log
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@

---tty-stream-chunk-separator
⚠ Could not parse ast-syntax-error.cjs for line number selection
---tty-stream-chunk-separator

SyntaxError: Unexpected token (3:11)
 at pp$4.raise (~/node_modules/acorn/dist/acorn.js:3462:15)
 at pp$9.unexpected (~/node_modules/acorn/dist/acorn.js:756:10)
 at pp$5.parseExprAtom (~/node_modules/acorn/dist/acorn.js:2837:12)
 at pp$5.parseExprSubscripts (~/node_modules/acorn/dist/acorn.js:2629:21)
 at pp$5.parseMaybeUnary (~/node_modules/acorn/dist/acorn.js:2595:19)
 at pp$5.parseExprOps (~/node_modules/acorn/dist/acorn.js:2522:21)
 at pp$5.parseMaybeConditional (~/node_modules/acorn/dist/acorn.js:2505:21)
 at pp$5.parseMaybeAssign (~/node_modules/acorn/dist/acorn.js:2472:21)
 at pp$8.parseVar (~/node_modules/acorn/dist/acorn.js:1299:26)
 at pp$8.parseVarStatement (~/node_modules/acorn/dist/acorn.js:1163:10)

---tty-stream-chunk-separator
Uncaught exception in ast-syntax-error.cjs

SyntaxError: Unexpected token 'do'