ava 0.16.0 → 0.18.2
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/api.js +297 -265
- package/cli.js +15 -179
- package/index.js +5 -98
- package/index.js.flow +201 -0
- package/lib/assert.js +87 -53
- package/lib/ava-error.js +4 -8
- package/lib/ava-files.js +282 -0
- package/lib/babel-config.js +35 -73
- package/lib/beautify-stack.js +17 -16
- package/lib/caching-precompiler.js +72 -87
- package/lib/cli.js +181 -0
- package/lib/code-excerpt.js +57 -0
- package/lib/colors.js +6 -2
- package/lib/concurrent.js +62 -75
- package/lib/enhance-assert.js +57 -49
- package/lib/extract-stack.js +10 -0
- package/lib/fork.js +67 -68
- package/lib/format-assert-error.js +72 -0
- package/lib/globals.js +3 -8
- package/lib/hook.js +15 -20
- package/lib/logger.js +59 -82
- package/lib/main.js +90 -0
- package/lib/prefix-title.js +21 -0
- package/lib/process-adapter.js +108 -0
- package/lib/reporters/mini.js +260 -257
- package/lib/reporters/tap.js +80 -85
- package/lib/reporters/verbose.js +142 -115
- package/lib/run-status.js +110 -152
- package/lib/runner.js +125 -137
- package/lib/sequence.js +68 -84
- package/lib/serialize-error.js +68 -4
- package/lib/snapshot-state.js +30 -0
- package/lib/test-collection.js +144 -156
- package/lib/test-worker.js +45 -95
- package/lib/test.js +289 -318
- package/lib/throws-helper.js +9 -9
- package/lib/validate-test.js +48 -0
- package/lib/watcher.js +258 -297
- package/package.json +63 -53
- package/profile.js +68 -55
- package/readme.md +215 -101
- package/types/generated.d.ts +848 -228
- package/types/make.js +54 -23
- package/lib/send.js +0 -16
package/lib/test-worker.js
CHANGED
|
@@ -1,114 +1,64 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* eslint-disable import/order */
|
|
3
|
-
|
|
4
|
-
var testPath = opts.file;
|
|
3
|
+
const process = require('./process-adapter');
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
process.stdout.isTTY = true;
|
|
9
|
-
process.stdout.columns = opts.tty.columns || 80;
|
|
10
|
-
process.stdout.rows = opts.tty.rows;
|
|
5
|
+
const opts = process.opts;
|
|
6
|
+
const testPath = opts.file;
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
tty.isatty = function (fd) {
|
|
16
|
-
if (fd === 1 || fd === process.stdout) {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return isatty(fd);
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
var path = require('path');
|
|
25
|
-
var fs = require('fs');
|
|
26
|
-
var debug = require('debug')('ava');
|
|
27
|
-
var sourceMapSupport = require('source-map-support');
|
|
28
|
-
|
|
29
|
-
if (debug.enabled) {
|
|
30
|
-
// Forward the `time-require` `--sorted` flag.
|
|
31
|
-
// Intended for internal optimization tests only.
|
|
32
|
-
if (opts._sorted) {
|
|
33
|
-
process.argv.push('--sorted');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
require('time-require');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// bind globals first before anything has a chance to interfere
|
|
40
|
-
var globals = require('./globals');
|
|
8
|
+
// Bind globals first before anything has a chance to interfere
|
|
9
|
+
const globals = require('./globals');
|
|
41
10
|
globals.options = opts;
|
|
42
|
-
|
|
11
|
+
const Promise = require('bluebird');
|
|
43
12
|
|
|
44
13
|
// Bluebird specific
|
|
45
14
|
Promise.longStackTraces();
|
|
46
15
|
|
|
47
16
|
(opts.require || []).forEach(require);
|
|
48
17
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
sourceMapSupport.install({
|
|
52
|
-
environment: 'node',
|
|
53
|
-
handleUncaughtExceptions: false,
|
|
54
|
-
retrieveSourceMap: function (source) {
|
|
55
|
-
if (sourceMapCache[source]) {
|
|
56
|
-
return {
|
|
57
|
-
url: source,
|
|
58
|
-
map: fs.readFileSync(sourceMapCache[source], 'utf8')
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
});
|
|
18
|
+
process.installSourceMapSupport();
|
|
63
19
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
var installPrecompiler = require('require-precompiled');
|
|
69
|
-
var cacheDir = opts.cacheDir;
|
|
20
|
+
const currentlyUnhandled = require('currently-unhandled')();
|
|
21
|
+
const serializeError = require('./serialize-error');
|
|
22
|
+
const send = process.send;
|
|
23
|
+
const throwsHelper = require('./throws-helper');
|
|
70
24
|
|
|
71
|
-
//
|
|
25
|
+
// Check if test files required ava and show error, when they didn't
|
|
72
26
|
exports.avaRequired = false;
|
|
73
27
|
|
|
74
|
-
|
|
75
|
-
var precompiled = opts.precompiled[filename];
|
|
28
|
+
process.installPrecompilerHook();
|
|
76
29
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return fs.readFileSync(path.join(cacheDir, precompiled + '.js'), 'utf8');
|
|
80
|
-
}
|
|
30
|
+
const dependencies = [];
|
|
31
|
+
process.installDependencyTracking(dependencies, testPath);
|
|
81
32
|
|
|
82
|
-
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
var dependencies = [];
|
|
86
|
-
Object.keys(require.extensions).forEach(function (ext) {
|
|
87
|
-
var wrappedHandler = require.extensions[ext];
|
|
88
|
-
require.extensions[ext] = function (module, filename) {
|
|
89
|
-
if (filename !== testPath) {
|
|
90
|
-
dependencies.push(filename);
|
|
91
|
-
}
|
|
92
|
-
wrappedHandler(module, filename);
|
|
93
|
-
};
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
require(testPath);
|
|
33
|
+
require(testPath); // eslint-disable-line import/no-dynamic-require
|
|
97
34
|
|
|
98
35
|
process.on('unhandledRejection', throwsHelper);
|
|
99
36
|
|
|
100
|
-
process.on('uncaughtException',
|
|
37
|
+
process.on('uncaughtException', exception => {
|
|
101
38
|
throwsHelper(exception);
|
|
102
|
-
|
|
39
|
+
|
|
40
|
+
let serialized;
|
|
41
|
+
try {
|
|
42
|
+
serialized = serializeError(exception);
|
|
43
|
+
} catch (ignore) { // eslint-disable-line unicorn/catch-error-name
|
|
44
|
+
// Avoid using serializeError
|
|
45
|
+
const err = new Error('Failed to serialize uncaught exception');
|
|
46
|
+
serialized = {
|
|
47
|
+
name: err.name,
|
|
48
|
+
message: err.message,
|
|
49
|
+
stack: err.stack
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
send('uncaughtException', {exception: serialized});
|
|
103
53
|
});
|
|
104
54
|
|
|
105
|
-
//
|
|
55
|
+
// If AVA was not required, show an error
|
|
106
56
|
if (!exports.avaRequired) {
|
|
107
57
|
send('no-tests', {avaRequired: false});
|
|
108
58
|
}
|
|
109
59
|
|
|
110
|
-
//
|
|
111
|
-
process.on('message',
|
|
60
|
+
// Parse and re-emit AVA messages
|
|
61
|
+
process.on('message', message => {
|
|
112
62
|
if (!message.ava) {
|
|
113
63
|
return;
|
|
114
64
|
}
|
|
@@ -116,35 +66,35 @@ process.on('message', function (message) {
|
|
|
116
66
|
process.emit(message.name, message.data);
|
|
117
67
|
});
|
|
118
68
|
|
|
119
|
-
process.on('ava-exit',
|
|
120
|
-
//
|
|
121
|
-
|
|
69
|
+
process.on('ava-exit', () => {
|
|
70
|
+
// Use a little delay when running on AppVeyor (because it's shit)
|
|
71
|
+
const delay = process.env.AVA_APPVEYOR ? 100 : 0;
|
|
122
72
|
|
|
123
|
-
globals.setTimeout(
|
|
73
|
+
globals.setTimeout(() => {
|
|
124
74
|
process.exit(0); // eslint-disable-line xo/no-process-exit
|
|
125
75
|
}, delay);
|
|
126
76
|
});
|
|
127
77
|
|
|
128
|
-
|
|
129
|
-
process.on('ava-teardown',
|
|
130
|
-
//
|
|
78
|
+
let tearingDown = false;
|
|
79
|
+
process.on('ava-teardown', () => {
|
|
80
|
+
// AVA-teardown can be sent more than once
|
|
131
81
|
if (tearingDown) {
|
|
132
82
|
return;
|
|
133
83
|
}
|
|
134
84
|
tearingDown = true;
|
|
135
85
|
|
|
136
|
-
|
|
86
|
+
let rejections = currentlyUnhandled();
|
|
137
87
|
|
|
138
88
|
if (rejections.length === 0) {
|
|
139
89
|
exit();
|
|
140
90
|
return;
|
|
141
91
|
}
|
|
142
92
|
|
|
143
|
-
rejections = rejections.map(
|
|
93
|
+
rejections = rejections.map(rejection => {
|
|
144
94
|
return serializeError(rejection.reason);
|
|
145
95
|
});
|
|
146
96
|
|
|
147
|
-
send('unhandledRejections', {rejections
|
|
97
|
+
send('unhandledRejections', {rejections});
|
|
148
98
|
globals.setTimeout(exit, 100);
|
|
149
99
|
});
|
|
150
100
|
|
|
@@ -152,5 +102,5 @@ function exit() {
|
|
|
152
102
|
// Include dependencies in the final teardown message. This ensures the full
|
|
153
103
|
// set of dependencies is included no matter how the process exits, unless
|
|
154
104
|
// it flat out crashes.
|
|
155
|
-
send('teardown', {dependencies
|
|
105
|
+
send('teardown', {dependencies});
|
|
156
106
|
}
|