ava 4.3.0 → 4.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/reporters/default.js +3 -0
- package/lib/snapshot-manager.js +3 -1
- package/lib/worker/line-numbers.js +16 -3
- package/package.json +1 -1
- package/readme.md +2 -0
package/lib/reporters/default.js
CHANGED
|
@@ -220,6 +220,9 @@ export default class Reporter {
|
|
|
220
220
|
this.lineNumberErrors.push(event);
|
|
221
221
|
|
|
222
222
|
this.write(colors.information(`${figures.warning} Could not parse ${this.relativeFile(event.testFile)} for line number selection`));
|
|
223
|
+
this.lineWriter.writeLine();
|
|
224
|
+
this.lineWriter.writeLine(colors.errorStack(event.err.stack));
|
|
225
|
+
this.lineWriter.writeLine();
|
|
223
226
|
break;
|
|
224
227
|
}
|
|
225
228
|
|
package/lib/snapshot-manager.js
CHANGED
|
@@ -391,7 +391,9 @@ class Manager {
|
|
|
391
391
|
|
|
392
392
|
const resolveSourceFile = mem(file => {
|
|
393
393
|
const sourceMap = findSourceMap(file);
|
|
394
|
-
|
|
394
|
+
// Prior to Node.js 18.8.0, the value when a source map could not be found was `undefined`.
|
|
395
|
+
// This changed to `null` in <https://github.com/nodejs/node/pull/43875>. Check both.
|
|
396
|
+
if (sourceMap === undefined || sourceMap === null) {
|
|
395
397
|
return file;
|
|
396
398
|
}
|
|
397
399
|
|
|
@@ -61,11 +61,18 @@ function findTest(locations, declaration) {
|
|
|
61
61
|
const range = (start, end) => Array.from({length: end - start + 1}).fill(start).map((element, index) => element + index);
|
|
62
62
|
|
|
63
63
|
const translate = (sourceMap, pos) => {
|
|
64
|
-
if (sourceMap ===
|
|
64
|
+
if (sourceMap === null) {
|
|
65
65
|
return pos;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
const entry = sourceMap.findEntry(pos.line - 1, pos.column); // Source maps are 0-based
|
|
69
|
+
|
|
70
|
+
// When used with ts-node/register, we've seen entries without original values. Return the
|
|
71
|
+
// original position.
|
|
72
|
+
if (entry.originalLine === undefined || entry.originalColumn === undefined) {
|
|
73
|
+
return pos;
|
|
74
|
+
}
|
|
75
|
+
|
|
69
76
|
return {
|
|
70
77
|
line: entry.originalLine + 1, // Readjust for Acorn.
|
|
71
78
|
column: entry.originalColumn,
|
|
@@ -81,7 +88,7 @@ export default function lineNumberSelection({file, lineNumbers = []}) {
|
|
|
81
88
|
|
|
82
89
|
let locations = parse(file);
|
|
83
90
|
let lookedForSourceMap = false;
|
|
84
|
-
let sourceMap;
|
|
91
|
+
let sourceMap = null;
|
|
85
92
|
|
|
86
93
|
return () => {
|
|
87
94
|
if (!lookedForSourceMap) {
|
|
@@ -91,7 +98,13 @@ export default function lineNumberSelection({file, lineNumbers = []}) {
|
|
|
91
98
|
// Source maps are not available before then.
|
|
92
99
|
sourceMap = findSourceMap(file);
|
|
93
100
|
|
|
94
|
-
if (sourceMap
|
|
101
|
+
if (sourceMap === undefined) {
|
|
102
|
+
// Prior to Node.js 18.8.0, the value when a source map could not be found was `undefined`.
|
|
103
|
+
// This changed to `null` in <https://github.com/nodejs/node/pull/43875>.
|
|
104
|
+
sourceMap = null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (sourceMap !== null) {
|
|
95
108
|
locations = locations.map(({start, end}) => ({
|
|
96
109
|
start: translate(sourceMap, start),
|
|
97
110
|
end: translate(sourceMap, end),
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -66,6 +66,8 @@ Alternatively you can install `ava` manually:
|
|
|
66
66
|
npm install --save-dev ava
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
+
*Make sure to install AVA locally. As of AVA 4 it can no longer be run globally.*
|
|
70
|
+
|
|
69
71
|
Don't forget to configure the `test` script in your `package.json` as per above.
|
|
70
72
|
|
|
71
73
|
### Create your test file
|