ava 0.24.0 → 0.25.0
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/cli.js +1 -1
- package/index.js.flow +1 -1
- package/lib/assert.js +18 -2
- package/lib/caching-precompiler.js +1 -3
- package/lib/main.js +0 -2
- package/lib/process-adapter.js +2 -2
- package/lib/reporters/tap.js +25 -64
- package/lib/test-worker.js +7 -1
- package/package.json +6 -5
- package/readme.md +2 -2
- package/types/generated.d.ts +6 -2
package/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ if (importLocal(__filename)) {
|
|
|
8
8
|
debug('Using local install of AVA');
|
|
9
9
|
} else {
|
|
10
10
|
if (debug.enabled) {
|
|
11
|
-
require('time-require'); // eslint-disable-line import/no-unassigned-import
|
|
11
|
+
require('@ladjs/time-require'); // eslint-disable-line import/no-unassigned-import
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
try {
|
package/index.js.flow
CHANGED
|
@@ -84,7 +84,7 @@ type TestContext = AssertContext & {
|
|
|
84
84
|
title: string;
|
|
85
85
|
plan(count: number): void;
|
|
86
86
|
skip: AssertContext;
|
|
87
|
-
log(
|
|
87
|
+
log(...values: Array<any>): void;
|
|
88
88
|
};
|
|
89
89
|
type ContextualTestContext = TestContext & { context: any; };
|
|
90
90
|
type ContextualCallbackTestContext = TestContext & { context: any; end(): void; };
|
package/lib/assert.js
CHANGED
|
@@ -49,14 +49,22 @@ class AssertionError extends Error {
|
|
|
49
49
|
|
|
50
50
|
if (opts.stack) {
|
|
51
51
|
this.stack = opts.stack;
|
|
52
|
+
} else {
|
|
53
|
+
const limitBefore = Error.stackTraceLimit;
|
|
54
|
+
Error.stackTraceLimit = Infinity;
|
|
55
|
+
Error.captureStackTrace(this);
|
|
56
|
+
Error.stackTraceLimit = limitBefore;
|
|
52
57
|
}
|
|
53
58
|
}
|
|
54
59
|
}
|
|
55
60
|
exports.AssertionError = AssertionError;
|
|
56
61
|
|
|
57
62
|
function getStack() {
|
|
63
|
+
const limitBefore = Error.stackTraceLimit;
|
|
64
|
+
Error.stackTraceLimit = Infinity;
|
|
58
65
|
const obj = {};
|
|
59
66
|
Error.captureStackTrace(obj, getStack);
|
|
67
|
+
Error.stackTraceLimit = limitBefore;
|
|
60
68
|
return obj.stack;
|
|
61
69
|
}
|
|
62
70
|
|
|
@@ -122,8 +130,16 @@ function wrapAssertions(callbacks) {
|
|
|
122
130
|
}
|
|
123
131
|
},
|
|
124
132
|
|
|
125
|
-
log(
|
|
126
|
-
|
|
133
|
+
log() {
|
|
134
|
+
const args = Array.from(arguments, value => {
|
|
135
|
+
return typeof value === 'string' ?
|
|
136
|
+
value :
|
|
137
|
+
concordance.format(value, concordanceOptions);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
if (args.length > 0) {
|
|
141
|
+
log(this, args.join(' '));
|
|
142
|
+
}
|
|
127
143
|
},
|
|
128
144
|
|
|
129
145
|
deepEqual(actual, expected, message) {
|
|
@@ -76,9 +76,7 @@ class CachingPrecompiler {
|
|
|
76
76
|
|
|
77
77
|
// Append source map comment to transformed code
|
|
78
78
|
// So that other libraries (like nyc) can find the source map
|
|
79
|
-
const
|
|
80
|
-
const relativeMapPath = path.relative(dirPath, mapPath);
|
|
81
|
-
const comment = convertSourceMap.generateMapFileComment(relativeMapPath);
|
|
79
|
+
const comment = convertSourceMap.generateMapFileComment(mapPath);
|
|
82
80
|
|
|
83
81
|
return `${result.code}\n${comment}`;
|
|
84
82
|
}
|
package/lib/main.js
CHANGED
package/lib/process-adapter.js
CHANGED
|
@@ -48,13 +48,13 @@ if (opts.tty) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
if (debug.enabled) {
|
|
51
|
-
// Forward the
|
|
51
|
+
// Forward the `@ladjs/time-require` `--sorted` flag.
|
|
52
52
|
// Intended for internal optimization tests only.
|
|
53
53
|
if (opts._sorted) {
|
|
54
54
|
process.argv.push('--sorted');
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
require('time-require'); // eslint-disable-line import/no-unassigned-import
|
|
57
|
+
require('@ladjs/time-require'); // eslint-disable-line import/no-unassigned-import
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
const sourceMapCache = new Map();
|
package/lib/reporters/tap.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
const
|
|
3
|
-
const indentString = require('indent-string');
|
|
2
|
+
const supertap = require('supertap');
|
|
4
3
|
const stripAnsi = require('strip-ansi');
|
|
5
|
-
const yaml = require('js-yaml');
|
|
6
4
|
|
|
7
5
|
function dumpError(error, includeMessage) {
|
|
8
6
|
const obj = Object.assign({}, error.object);
|
|
@@ -32,7 +30,7 @@ function dumpError(error, includeMessage) {
|
|
|
32
30
|
obj.at = error.stack.split('\n')[0];
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
return
|
|
33
|
+
return obj;
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
class TapReporter {
|
|
@@ -41,79 +39,42 @@ class TapReporter {
|
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
start() {
|
|
44
|
-
return
|
|
42
|
+
return supertap.start();
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
test(test) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
directive = '# SKIP';
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const title = stripAnsi(test.title);
|
|
60
|
-
|
|
61
|
-
const appendLogs = () => {
|
|
62
|
-
if (test.logs) {
|
|
63
|
-
test.logs.forEach(log => {
|
|
64
|
-
const logLines = indentString(log, 4);
|
|
65
|
-
const logLinesWithLeadingFigure = logLines.replace(
|
|
66
|
-
/^ {4}/,
|
|
67
|
-
' * '
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
output.push(logLinesWithLeadingFigure);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
output.push(`# ${title}`);
|
|
76
|
-
|
|
77
|
-
if (test.error) {
|
|
78
|
-
output.push(format('not ok %d - %s', ++this.i, title));
|
|
79
|
-
appendLogs();
|
|
80
|
-
output.push(dumpError(test.error, true));
|
|
81
|
-
} else {
|
|
82
|
-
output.push(format('%s %d - %s %s', passed, ++this.i, title, directive).trim());
|
|
83
|
-
appendLogs();
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return output.join('\n');
|
|
46
|
+
return supertap.test(test.title, {
|
|
47
|
+
passed: !test.error,
|
|
48
|
+
index: ++this.i,
|
|
49
|
+
todo: test.todo,
|
|
50
|
+
skip: test.skip,
|
|
51
|
+
comment: test.logs,
|
|
52
|
+
error: test.error ? dumpError(test.error, true) : null
|
|
53
|
+
});
|
|
87
54
|
}
|
|
88
55
|
|
|
89
56
|
unhandledError(err) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
format('not ok %d - %s', ++this.i, err.message)
|
|
93
|
-
];
|
|
57
|
+
let error;
|
|
58
|
+
|
|
94
59
|
// AvaErrors don't have stack traces
|
|
95
60
|
if (err.type !== 'exception' || err.name !== 'AvaError') {
|
|
96
|
-
|
|
61
|
+
error = dumpError(err, false);
|
|
97
62
|
}
|
|
98
63
|
|
|
99
|
-
return
|
|
64
|
+
return supertap.test(err.message, {
|
|
65
|
+
passed: false,
|
|
66
|
+
index: ++this.i,
|
|
67
|
+
error
|
|
68
|
+
});
|
|
100
69
|
}
|
|
101
70
|
|
|
102
71
|
finish(runStatus) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (runStatus.skipCount > 0) {
|
|
111
|
-
output.push(`# skip ${runStatus.skipCount}`);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
output.push('# fail ' + (runStatus.failCount + runStatus.rejectionCount + runStatus.exceptionCount), '');
|
|
115
|
-
|
|
116
|
-
return output.join('\n');
|
|
72
|
+
return supertap.finish({
|
|
73
|
+
passed: runStatus.passCount,
|
|
74
|
+
failed: runStatus.failCount,
|
|
75
|
+
skipped: runStatus.skipCount,
|
|
76
|
+
crashed: runStatus.rejectionCount + runStatus.exceptionCount
|
|
77
|
+
});
|
|
117
78
|
}
|
|
118
79
|
|
|
119
80
|
write(str) {
|
package/lib/test-worker.js
CHANGED
|
@@ -27,7 +27,13 @@ globals.options = opts;
|
|
|
27
27
|
|
|
28
28
|
const serializeError = require('./serialize-error');
|
|
29
29
|
|
|
30
|
-
(opts.require || []).forEach(x =>
|
|
30
|
+
(opts.require || []).forEach(x => {
|
|
31
|
+
if (/[/\\]@std[/\\]esm[/\\]index\.js$/.test(x)) {
|
|
32
|
+
require = require(x)(module); // eslint-disable-line no-global-assign
|
|
33
|
+
} else {
|
|
34
|
+
require(x);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
31
37
|
|
|
32
38
|
adapter.installSourceMapSupport();
|
|
33
39
|
adapter.installPrecompilerHook();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ava",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "Futuristic test runner 🚀",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "avajs/ava",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"@ava/babel-preset-transform-test-files": "^3.0.0",
|
|
66
66
|
"@ava/write-file-atomic": "^2.2.0",
|
|
67
67
|
"@concordance/react": "^1.0.0",
|
|
68
|
+
"@ladjs/time-require": "^0.1.4",
|
|
68
69
|
"ansi-escapes": "^3.0.0",
|
|
69
70
|
"ansi-styles": "^3.1.0",
|
|
70
71
|
"arr-flatten": "^1.0.1",
|
|
@@ -86,10 +87,10 @@
|
|
|
86
87
|
"cli-spinners": "^1.0.0",
|
|
87
88
|
"cli-truncate": "^1.0.0",
|
|
88
89
|
"co-with-promise": "^4.6.0",
|
|
89
|
-
"code-excerpt": "^2.1.
|
|
90
|
+
"code-excerpt": "^2.1.1",
|
|
90
91
|
"common-path-prefix": "^1.0.0",
|
|
91
92
|
"concordance": "^3.0.0",
|
|
92
|
-
"convert-source-map": "^1.
|
|
93
|
+
"convert-source-map": "^1.5.1",
|
|
93
94
|
"core-assert": "^0.2.0",
|
|
94
95
|
"currently-unhandled": "^0.4.1",
|
|
95
96
|
"debug": "^3.0.1",
|
|
@@ -111,7 +112,6 @@
|
|
|
111
112
|
"is-obj": "^1.0.0",
|
|
112
113
|
"is-observable": "^1.0.0",
|
|
113
114
|
"is-promise": "^2.1.0",
|
|
114
|
-
"js-yaml": "^3.8.2",
|
|
115
115
|
"last-line-stream": "^1.0.0",
|
|
116
116
|
"lodash.clonedeepwith": "^4.5.0",
|
|
117
117
|
"lodash.debounce": "^4.0.3",
|
|
@@ -139,13 +139,14 @@
|
|
|
139
139
|
"stack-utils": "^1.0.1",
|
|
140
140
|
"strip-ansi": "^4.0.0",
|
|
141
141
|
"strip-bom-buf": "^1.0.0",
|
|
142
|
+
"supertap": "^1.0.0",
|
|
142
143
|
"supports-color": "^5.0.0",
|
|
143
|
-
"time-require": "^0.1.2",
|
|
144
144
|
"trim-off-newlines": "^1.0.1",
|
|
145
145
|
"unique-temp-dir": "^1.0.0",
|
|
146
146
|
"update-notifier": "^2.3.0"
|
|
147
147
|
},
|
|
148
148
|
"devDependencies": {
|
|
149
|
+
"@std/esm": "^0.19.1",
|
|
149
150
|
"cli-table2": "^0.2.0",
|
|
150
151
|
"codecov": "^3.0.0",
|
|
151
152
|
"del": "^3.0.0",
|
package/readme.md
CHANGED
|
@@ -890,9 +890,9 @@ Plan how many assertion there are in the test. The test will fail if the actual
|
|
|
890
890
|
|
|
891
891
|
End the test. Only works with `test.cb()`.
|
|
892
892
|
|
|
893
|
-
###### `t.log(
|
|
893
|
+
###### `t.log(...values)`
|
|
894
894
|
|
|
895
|
-
|
|
895
|
+
Log values contextually alongside the test result instead of immediately printing them to `stdout`. Behaves somewhat like `console.log`, but without support for placeholder tokens.
|
|
896
896
|
|
|
897
897
|
## Assertions
|
|
898
898
|
|
package/types/generated.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export type ErrorValidator
|
|
|
7
7
|
export interface Observable {
|
|
8
8
|
subscribe(observer: (value: {}) => void): void;
|
|
9
9
|
}
|
|
10
|
+
export interface SnapshotOptions {
|
|
11
|
+
id?: string;
|
|
12
|
+
}
|
|
10
13
|
export type Test = (t: TestContext) => PromiseLike<void> | Iterator<any> | Observable | void;
|
|
11
14
|
export type GenericTest<T> = (t: GenericTestContext<T>) => PromiseLike<void> | Iterator<any> | Observable | void;
|
|
12
15
|
export type CallbackTest = (t: CallbackTestContext) => void;
|
|
@@ -78,6 +81,7 @@ export interface AssertContext {
|
|
|
78
81
|
* Assert that contents matches a snapshot.
|
|
79
82
|
*/
|
|
80
83
|
snapshot(contents: any, message?: string): void;
|
|
84
|
+
snapshot(contents: any, options: SnapshotOptions, message?: string): void;
|
|
81
85
|
/**
|
|
82
86
|
* Assert that contents does not match regex.
|
|
83
87
|
*/
|
|
@@ -100,9 +104,9 @@ export interface TestContext extends AssertContext {
|
|
|
100
104
|
|
|
101
105
|
skip: AssertContext;
|
|
102
106
|
/**
|
|
103
|
-
*
|
|
107
|
+
* Log values contextually alongside the test result instead of immediately printing them to `stdout`.
|
|
104
108
|
*/
|
|
105
|
-
log(
|
|
109
|
+
log(...values: any[]): void;
|
|
106
110
|
}
|
|
107
111
|
export interface CallbackTestContext extends TestContext {
|
|
108
112
|
/**
|