From 3f17f8c7d6070c6414896a439dc93a6f3613a620 Mon Sep 17 00:00:00 2001 From: Eric Cornelissen Date: Mon, 6 Jun 2022 14:05:44 +0200 Subject: [PATCH 1/7] Update checksum algorithm for lockfile churn detection --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b40bf05a3..879aa88ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 From 91f5254d7bfb6c658d0e89f48a852b92b70e31da Mon Sep 17 00:00:00 2001 From: Gabriel Alencar Date: Tue, 7 Jun 2022 10:13:33 -0300 Subject: [PATCH 2/7] Update recommended VS Code debug configuration --- docs/recipes/debugging-with-vscode.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/recipes/debugging-with-vscode.md b/docs/recipes/debugging-with-vscode.md index 7f3e75bfb..02355ff25 100644 --- a/docs/recipes/debugging-with-vscode.md +++ b/docs/recipes/debugging-with-vscode.md @@ -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": [ "/**/*.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": [ "/**/*.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": [ "/**/*.js" ] From 26a2e5d56a21e014edba382191d6c0a16444d880 Mon Sep 17 00:00:00 2001 From: Eric Cornelissen Date: Thu, 23 Jun 2022 17:45:51 +0200 Subject: [PATCH 3/7] 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. --- docs/01-writing-tests.md | 4 +--- docs/recipes/test-setup.md | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/01-writing-tests.md b/docs/01-writing-tests.md index 9a3d37011..abec90c38 100644 --- a/docs/01-writing-tests.md +++ b/docs/01-writing-tests.md @@ -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); diff --git a/docs/recipes/test-setup.md b/docs/recipes/test-setup.md index 4cafa5cee..556ed4de0 100644 --- a/docs/recipes/test-setup.md +++ b/docs/recipes/test-setup.md @@ -16,7 +16,7 @@ You could do all these things using plain setup functions, but there are tradeof |---|--- | ⛔️   used for all tests| ✅   can change or skip depending on test | ⛔️   more overhead for beginners, "some magic"| ✅   easier for beginners, "no magic" -| ✅   supports callback mode, built-in support for observables| ⛔️   must use promises for asynchronous behavior +| ✅   built-in support for observables| ⛔️   must use promises for asynchronous behavior | ✅   failure has friendly output| ⛔️   errors are attributed to the test | ✅   corresponding `afterEach` and `afterEach.always` for cleanup| ⛔️   cannot easily clean up From ac0d75d05d28e511b1b3654b09d11d602e360179 Mon Sep 17 00:00:00 2001 From: Binyamin Aron Green Date: Thu, 23 Jun 2022 11:48:00 -0400 Subject: [PATCH 4/7] Document that AVA 4 cannot be run globally Co-authored-by: Mark Wubben --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index cdada8de4..a16e308be 100644 --- a/readme.md +++ b/readme.md @@ -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 From 357234260afc49646cddc2e9253f2740dd25d8e6 Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Sun, 10 Jul 2022 14:23:50 +0200 Subject: [PATCH 5/7] When translating line numbers, check whether the source map entry has original values --- lib/worker/line-numbers.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/worker/line-numbers.js b/lib/worker/line-numbers.js index c7865f85f..b7031d49b 100644 --- a/lib/worker/line-numbers.js +++ b/lib/worker/line-numbers.js @@ -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, From d57c76c47687e61c38e059ea6442d92b4a9404fa Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Sun, 10 Jul 2022 14:25:11 +0200 Subject: [PATCH 6/7] Report error when parsing for line number selection This makes the failure a little less mysterious. --- lib/reporters/default.js | 3 +++ test-tap/reporters/default.edgecases.v12.log | 14 +++++++++++++- test-tap/reporters/default.edgecases.v14.log | 14 +++++++++++++- test-tap/reporters/default.edgecases.v16.log | 14 +++++++++++++- test-tap/reporters/default.edgecases.v18.log | 14 +++++++++++++- 5 files changed, 55 insertions(+), 4 deletions(-) diff --git a/lib/reporters/default.js b/lib/reporters/default.js index 955a6bc0a..8a612deef 100644 --- a/lib/reporters/default.js +++ b/lib/reporters/default.js @@ -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; } diff --git a/test-tap/reporters/default.edgecases.v12.log b/test-tap/reporters/default.edgecases.v12.log index bbbe457d2..6db3a290b 100644 --- a/test-tap/reporters/default.edgecases.v12.log +++ b/test-tap/reporters/default.edgecases.v12.log @@ -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 diff --git a/test-tap/reporters/default.edgecases.v14.log b/test-tap/reporters/default.edgecases.v14.log index e39930d14..47a58d804 100644 --- a/test-tap/reporters/default.edgecases.v14.log +++ b/test-tap/reporters/default.edgecases.v14.log @@ -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' diff --git a/test-tap/reporters/default.edgecases.v16.log b/test-tap/reporters/default.edgecases.v16.log index e39930d14..47a58d804 100644 --- a/test-tap/reporters/default.edgecases.v16.log +++ b/test-tap/reporters/default.edgecases.v16.log @@ -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' diff --git a/test-tap/reporters/default.edgecases.v18.log b/test-tap/reporters/default.edgecases.v18.log index e39930d14..83bd6a2aa 100644 --- a/test-tap/reporters/default.edgecases.v18.log +++ b/test-tap/reporters/default.edgecases.v18.log @@ -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' From 53e570998bcbee584701c271aa7478825895c35b Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Sun, 10 Jul 2022 18:25:48 +0200 Subject: [PATCH 7/7] 4.3.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index b7624dc27..1a6dc06e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ava", - "version": "4.3.0", + "version": "4.3.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ava", - "version": "4.3.0", + "version": "4.3.1", "license": "MIT", "dependencies": { "acorn": "^8.7.1", diff --git a/package.json b/package.json index 1f777e98a..10ce03b6f 100644 --- a/package.json +++ b/package.json @@ -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",