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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ava",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.2",
|
|
4
4
|
"description": "Futuristic test runner 🚀",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "avajs/ava",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
{
|
|
15
15
|
"name": "Vadim Demedes",
|
|
16
16
|
"email": "vdemedes@gmail.com",
|
|
17
|
-
"url": "github.com/
|
|
17
|
+
"url": "github.com/vadimdemedes"
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
"name": "James Talmage",
|
|
@@ -30,23 +30,29 @@
|
|
|
30
30
|
"name": "Juan Soto",
|
|
31
31
|
"email": "juan@juansoto.me",
|
|
32
32
|
"url": "juansoto.me"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "Jeroen Engels",
|
|
36
|
+
"email": "jfm.engels@gmail.com",
|
|
37
|
+
"url": "github.com/jfmengels"
|
|
33
38
|
}
|
|
34
39
|
],
|
|
35
40
|
"bin": "cli.js",
|
|
36
41
|
"typings": "types/generated.d.ts",
|
|
37
42
|
"engines": {
|
|
38
|
-
"node": ">=
|
|
43
|
+
"node": ">=4"
|
|
39
44
|
},
|
|
40
45
|
"scripts": {
|
|
41
|
-
"test": "xo &&
|
|
42
|
-
"test-win": "tap --no-cov --reporter=classic --timeout=150 test/*.js test/reporters/*.js",
|
|
46
|
+
"test": "xo && flow check test/flow-types && nyc tap --no-cov --timeout=150 --jobs=4 test/*.js test/reporters/*.js",
|
|
47
|
+
"test-win": "tap --no-cov --reporter=classic --timeout=150 --jobs=4 test/*.js test/reporters/*.js",
|
|
43
48
|
"visual": "node test/visual/run-visual-tests.js",
|
|
44
49
|
"prepublish": "npm run make-ts",
|
|
45
|
-
"make-ts": "
|
|
50
|
+
"make-ts": "node types/make.js"
|
|
46
51
|
},
|
|
47
52
|
"files": [
|
|
48
53
|
"lib",
|
|
49
54
|
"*.js",
|
|
55
|
+
"*.js.flow",
|
|
50
56
|
"types/generated.d.ts"
|
|
51
57
|
],
|
|
52
58
|
"keywords": [
|
|
@@ -58,9 +64,11 @@
|
|
|
58
64
|
"fast",
|
|
59
65
|
"tape",
|
|
60
66
|
"tap",
|
|
67
|
+
"jest",
|
|
61
68
|
"mocha",
|
|
62
69
|
"qunit",
|
|
63
70
|
"jasmine",
|
|
71
|
+
"testing",
|
|
64
72
|
"tdd",
|
|
65
73
|
"cli-app",
|
|
66
74
|
"cli",
|
|
@@ -76,120 +84,122 @@
|
|
|
76
84
|
"generators",
|
|
77
85
|
"yield",
|
|
78
86
|
"observable",
|
|
79
|
-
"observables"
|
|
80
|
-
"tap"
|
|
87
|
+
"observables"
|
|
81
88
|
],
|
|
82
89
|
"dependencies": {
|
|
90
|
+
"@ava/babel-preset-stage-4": "^1.0.0",
|
|
91
|
+
"@ava/babel-preset-transform-test-files": "^2.0.0",
|
|
92
|
+
"@ava/pretty-format": "^1.1.0",
|
|
83
93
|
"arr-flatten": "^1.0.1",
|
|
84
94
|
"array-union": "^1.0.1",
|
|
85
95
|
"array-uniq": "^1.0.2",
|
|
86
96
|
"arrify": "^1.0.0",
|
|
87
|
-
"
|
|
88
|
-
"ava-init": "^0.
|
|
89
|
-
"babel-code-frame": "^6.
|
|
90
|
-
"babel-core": "^6.
|
|
91
|
-
"babel-plugin-ava-throws-helper": "^0.1.0",
|
|
92
|
-
"babel-plugin-detective": "^2.0.0",
|
|
93
|
-
"babel-plugin-espower": "^2.2.0",
|
|
94
|
-
"babel-plugin-transform-runtime": "^6.3.13",
|
|
95
|
-
"babel-preset-es2015": "^6.3.13",
|
|
96
|
-
"babel-preset-stage-2": "^6.3.13",
|
|
97
|
-
"babel-runtime": "^6.3.19",
|
|
97
|
+
"auto-bind": "^1.1.0",
|
|
98
|
+
"ava-init": "^0.2.0",
|
|
99
|
+
"babel-code-frame": "^6.16.0",
|
|
100
|
+
"babel-core": "^6.17.0",
|
|
98
101
|
"bluebird": "^3.0.0",
|
|
99
102
|
"caching-transform": "^1.0.0",
|
|
100
103
|
"chalk": "^1.0.0",
|
|
101
104
|
"chokidar": "^1.4.2",
|
|
105
|
+
"clean-stack": "^1.1.1",
|
|
102
106
|
"clean-yaml-object": "^0.1.0",
|
|
103
|
-
"cli-cursor": "^1.0
|
|
104
|
-
"cli-spinners": "^0.
|
|
107
|
+
"cli-cursor": "^2.1.0",
|
|
108
|
+
"cli-spinners": "^1.0.0",
|
|
105
109
|
"cli-truncate": "^0.2.0",
|
|
106
110
|
"co-with-promise": "^4.6.0",
|
|
111
|
+
"code-excerpt": "^2.1.0",
|
|
107
112
|
"common-path-prefix": "^1.0.0",
|
|
108
113
|
"convert-source-map": "^1.2.0",
|
|
109
114
|
"core-assert": "^0.2.0",
|
|
110
115
|
"currently-unhandled": "^0.4.1",
|
|
111
116
|
"debug": "^2.2.0",
|
|
117
|
+
"diff": "^3.0.1",
|
|
118
|
+
"dot-prop": "^4.1.0",
|
|
112
119
|
"empower-core": "^0.6.1",
|
|
113
|
-
"
|
|
120
|
+
"equal-length": "^1.0.0",
|
|
121
|
+
"figures": "^2.0.0",
|
|
114
122
|
"find-cache-dir": "^0.1.1",
|
|
115
123
|
"fn-name": "^2.0.0",
|
|
124
|
+
"get-port": "^2.1.0",
|
|
125
|
+
"globby": "^6.0.0",
|
|
116
126
|
"has-flag": "^2.0.0",
|
|
117
127
|
"ignore-by-default": "^1.0.0",
|
|
128
|
+
"indent-string": "^3.0.0",
|
|
118
129
|
"is-ci": "^1.0.7",
|
|
119
130
|
"is-generator-fn": "^1.0.0",
|
|
120
131
|
"is-obj": "^1.0.0",
|
|
121
132
|
"is-observable": "^0.2.0",
|
|
122
133
|
"is-promise": "^2.1.0",
|
|
134
|
+
"jest-snapshot": "^18.1.0",
|
|
123
135
|
"last-line-stream": "^1.0.0",
|
|
124
136
|
"lodash.debounce": "^4.0.3",
|
|
125
137
|
"lodash.difference": "^4.3.0",
|
|
138
|
+
"lodash.flatten": "^4.2.0",
|
|
139
|
+
"lodash.isequal": "^4.5.0",
|
|
126
140
|
"loud-rejection": "^1.2.0",
|
|
127
141
|
"matcher": "^0.1.1",
|
|
128
142
|
"max-timeout": "^1.0.0",
|
|
129
|
-
"md5-hex": "^
|
|
143
|
+
"md5-hex": "^2.0.0",
|
|
130
144
|
"meow": "^3.7.0",
|
|
131
145
|
"ms": "^0.7.1",
|
|
132
|
-
"
|
|
133
|
-
"object-assign": "^4.0.1",
|
|
146
|
+
"multimatch": "^2.1.0",
|
|
134
147
|
"observable-to-promise": "^0.4.0",
|
|
135
148
|
"option-chain": "^0.1.0",
|
|
136
|
-
"package-hash": "^1.
|
|
137
|
-
"pkg-conf": "^
|
|
149
|
+
"package-hash": "^1.2.0",
|
|
150
|
+
"pkg-conf": "^2.0.0",
|
|
138
151
|
"plur": "^2.0.0",
|
|
139
|
-
"power-assert-context-formatter": "^1.0.4",
|
|
140
|
-
"power-assert-renderer-assertion": "^1.0.1",
|
|
141
|
-
"power-assert-renderer-succinct": "^1.0.1",
|
|
142
152
|
"pretty-ms": "^2.0.0",
|
|
143
|
-
"repeating": "^2.0.0",
|
|
144
153
|
"require-precompiled": "^0.1.0",
|
|
145
154
|
"resolve-cwd": "^1.0.0",
|
|
146
|
-
"
|
|
155
|
+
"slash": "^1.0.0",
|
|
147
156
|
"source-map-support": "^0.4.0",
|
|
148
|
-
"stack-utils": "^0.
|
|
157
|
+
"stack-utils": "^1.0.0",
|
|
149
158
|
"strip-ansi": "^3.0.1",
|
|
150
|
-
"strip-bom": "^
|
|
159
|
+
"strip-bom-buf": "^1.0.0",
|
|
151
160
|
"time-require": "^0.1.2",
|
|
152
161
|
"unique-temp-dir": "^1.0.0",
|
|
153
162
|
"update-notifier": "^1.0.0"
|
|
154
163
|
},
|
|
155
164
|
"devDependencies": {
|
|
156
|
-
"babel-cli": "^6.10.1",
|
|
157
165
|
"babel-preset-react": "^6.5.0",
|
|
158
166
|
"cli-table2": "^0.2.0",
|
|
159
167
|
"coveralls": "^2.11.4",
|
|
160
168
|
"delay": "^1.3.0",
|
|
161
|
-
"execa": "^0.
|
|
162
|
-
"
|
|
169
|
+
"execa": "^0.6.0",
|
|
170
|
+
"flow-bin": "^0.38.0",
|
|
171
|
+
"get-stream": "^3.0.0",
|
|
163
172
|
"git-branch": "^0.3.0",
|
|
164
173
|
"has-ansi": "^2.0.0",
|
|
165
|
-
"inquirer": "^
|
|
174
|
+
"inquirer": "^2.0.0",
|
|
175
|
+
"is-array-sorted": "^1.0.0",
|
|
166
176
|
"lolex": "^1.4.0",
|
|
167
177
|
"mkdirp": "^0.5.1",
|
|
168
|
-
"nyc": "^
|
|
178
|
+
"nyc": "^10.0.0",
|
|
169
179
|
"pify": "^2.3.0",
|
|
170
180
|
"proxyquire": "^1.7.4",
|
|
171
181
|
"rimraf": "^2.5.0",
|
|
172
182
|
"signal-exit": "^3.0.0",
|
|
173
183
|
"sinon": "^1.17.2",
|
|
174
184
|
"source-map-fixtures": "^2.1.0",
|
|
175
|
-
"tap": "^
|
|
185
|
+
"tap": "^10.0.0",
|
|
186
|
+
"temp-write": "^3.1.0",
|
|
176
187
|
"touch": "^1.0.0",
|
|
177
|
-
"xo": "
|
|
178
|
-
"zen-observable": "^0.
|
|
188
|
+
"xo": "^0.17.0",
|
|
189
|
+
"zen-observable": "^0.4.0"
|
|
179
190
|
},
|
|
180
191
|
"xo": {
|
|
192
|
+
"esnext": true,
|
|
181
193
|
"rules": {
|
|
182
|
-
"import/newline-after-import":
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
}
|
|
194
|
+
"import/newline-after-import": "off",
|
|
195
|
+
"no-use-extend-native/no-use-extend-native": "off"
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
"nyc": {
|
|
199
|
+
"reporter": [
|
|
200
|
+
"html",
|
|
201
|
+
"lcov",
|
|
202
|
+
"text"
|
|
193
203
|
]
|
|
194
204
|
}
|
|
195
205
|
}
|
package/profile.js
CHANGED
|
@@ -1,46 +1,57 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// Iron-node does not work with forked processes
|
|
4
4
|
// This cli command will run a single file in the current process.
|
|
5
5
|
// Intended to be used with iron-node for profiling purposes.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const EventEmitter = require('events');
|
|
9
|
+
const meow = require('meow');
|
|
10
|
+
const Promise = require('bluebird');
|
|
11
|
+
const pkgConf = require('pkg-conf');
|
|
12
|
+
const findCacheDir = require('find-cache-dir');
|
|
13
|
+
const uniqueTempDir = require('unique-temp-dir');
|
|
14
|
+
const arrify = require('arrify');
|
|
15
|
+
const resolveCwd = require('resolve-cwd');
|
|
16
|
+
const CachingPrecompiler = require('./lib/caching-precompiler');
|
|
17
|
+
const globals = require('./lib/globals');
|
|
18
|
+
|
|
19
|
+
function resolveModules(modules) {
|
|
20
|
+
return arrify(modules).map(name => {
|
|
21
|
+
const modulePath = resolveCwd(name);
|
|
22
|
+
|
|
23
|
+
if (modulePath === null) {
|
|
24
|
+
throw new Error(`Could not resolve required module '${name}'`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return modulePath;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Chrome gets upset when the `this` value is non-null for these functions
|
|
19
32
|
globals.setTimeout = setTimeout.bind(null);
|
|
20
33
|
globals.clearTimeout = clearTimeout.bind(null);
|
|
21
34
|
|
|
22
35
|
Promise.longStackTraces();
|
|
23
36
|
|
|
24
|
-
|
|
37
|
+
const conf = pkgConf.sync('ava', {
|
|
25
38
|
defaults: {
|
|
26
39
|
babel: 'default'
|
|
27
40
|
}
|
|
28
41
|
});
|
|
29
42
|
|
|
30
|
-
// Define a minimal set of options from the main CLI
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
], {
|
|
43
|
+
// Define a minimal set of options from the main CLI
|
|
44
|
+
const cli = meow(`
|
|
45
|
+
Usage
|
|
46
|
+
$ iron-node node_modules/ava/profile.js <test-file>
|
|
47
|
+
|
|
48
|
+
Options
|
|
49
|
+
--fail-fast Stop after first test failure
|
|
50
|
+
--serial, -s Run tests serially
|
|
51
|
+
|
|
52
|
+
`, {
|
|
41
53
|
string: [
|
|
42
|
-
'_'
|
|
43
|
-
'require'
|
|
54
|
+
'_'
|
|
44
55
|
],
|
|
45
56
|
boolean: [
|
|
46
57
|
'fail-fast',
|
|
@@ -50,7 +61,6 @@ var cli = meow([
|
|
|
50
61
|
],
|
|
51
62
|
default: conf,
|
|
52
63
|
alias: {
|
|
53
|
-
r: 'require',
|
|
54
64
|
s: 'serial'
|
|
55
65
|
}
|
|
56
66
|
});
|
|
@@ -59,31 +69,37 @@ if (cli.input.length !== 1) {
|
|
|
59
69
|
throw new Error('Specify a test file');
|
|
60
70
|
}
|
|
61
71
|
|
|
62
|
-
|
|
63
|
-
|
|
72
|
+
const file = path.resolve(cli.input[0]);
|
|
73
|
+
const cacheDir = findCacheDir({
|
|
64
74
|
name: 'ava',
|
|
65
75
|
files: [file]
|
|
66
76
|
}) || uniqueTempDir();
|
|
67
|
-
var precompiled = {};
|
|
68
|
-
precompiled[file] = new CachingPrecompiler(cacheDir, conf.babel).precompileFile(file);
|
|
69
77
|
|
|
70
|
-
|
|
71
|
-
|
|
78
|
+
const precompiler = new CachingPrecompiler({
|
|
79
|
+
path: cacheDir,
|
|
80
|
+
babel: conf.babel
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const precompiled = {};
|
|
84
|
+
precompiled[file] = precompiler.precompileFile(file);
|
|
85
|
+
|
|
86
|
+
const opts = {
|
|
87
|
+
file,
|
|
72
88
|
failFast: cli.flags.failFast,
|
|
73
89
|
serial: cli.flags.serial,
|
|
74
|
-
require: arrify(cli.flags.require),
|
|
75
90
|
tty: false,
|
|
76
|
-
cacheDir
|
|
77
|
-
precompiled
|
|
91
|
+
cacheDir,
|
|
92
|
+
precompiled,
|
|
93
|
+
require: resolveModules(conf.require)
|
|
78
94
|
};
|
|
79
95
|
|
|
80
|
-
|
|
81
|
-
|
|
96
|
+
const events = new EventEmitter();
|
|
97
|
+
let uncaughtExceptionCount = 0;
|
|
82
98
|
|
|
83
|
-
// Mock the behavior of a parent process
|
|
84
|
-
process.send =
|
|
99
|
+
// Mock the behavior of a parent process
|
|
100
|
+
process.send = data => {
|
|
85
101
|
if (data && data.ava) {
|
|
86
|
-
|
|
102
|
+
const name = data.name.replace(/^ava-/, '');
|
|
87
103
|
|
|
88
104
|
if (events.listeners(name).length > 0) {
|
|
89
105
|
events.emit(name, data.data);
|
|
@@ -97,11 +113,11 @@ process.send = function (data) {
|
|
|
97
113
|
console.log('NON AVA EVENT:', data);
|
|
98
114
|
};
|
|
99
115
|
|
|
100
|
-
events.on('test',
|
|
116
|
+
events.on('test', data => {
|
|
101
117
|
console.log('TEST:', data.title, data.error);
|
|
102
118
|
});
|
|
103
119
|
|
|
104
|
-
events.on('results',
|
|
120
|
+
events.on('results', data => {
|
|
105
121
|
if (console.profileEnd) {
|
|
106
122
|
console.profileEnd();
|
|
107
123
|
}
|
|
@@ -109,27 +125,24 @@ events.on('results', function (data) {
|
|
|
109
125
|
console.log('RESULTS:', data.stats);
|
|
110
126
|
|
|
111
127
|
if (process.exit) {
|
|
112
|
-
|
|
113
|
-
setTimeout(function () {
|
|
114
|
-
process.exit(data.stats.failCount + uncaughtExceptionCount); // eslint-disable-line xo/no-process-exit
|
|
115
|
-
}, 20);
|
|
128
|
+
process.exit(data.stats.failCount + uncaughtExceptionCount); // eslint-disable-line unicorn/no-process-exit
|
|
116
129
|
}
|
|
117
130
|
});
|
|
118
131
|
|
|
119
|
-
events.on('stats',
|
|
120
|
-
setImmediate(
|
|
132
|
+
events.on('stats', () => {
|
|
133
|
+
setImmediate(() => {
|
|
121
134
|
process.emit('ava-run', {});
|
|
122
135
|
});
|
|
123
136
|
});
|
|
124
137
|
|
|
125
|
-
events.on('uncaughtException',
|
|
138
|
+
events.on('uncaughtException', data => {
|
|
126
139
|
uncaughtExceptionCount++;
|
|
127
|
-
|
|
140
|
+
let stack = data && data.exception && data.exception.stack;
|
|
128
141
|
stack = stack || data;
|
|
129
142
|
console.log(stack);
|
|
130
143
|
});
|
|
131
144
|
|
|
132
|
-
// test-worker will read process.argv[2] for options
|
|
145
|
+
// `test-worker` will read process.argv[2] for options
|
|
133
146
|
process.argv[2] = JSON.stringify(opts);
|
|
134
147
|
process.argv.length = 3;
|
|
135
148
|
|
|
@@ -137,6 +150,6 @@ if (console.profile) {
|
|
|
137
150
|
console.profile('AVA test-worker process');
|
|
138
151
|
}
|
|
139
152
|
|
|
140
|
-
setImmediate(
|
|
141
|
-
require('./lib/test-worker');
|
|
153
|
+
setImmediate(() => {
|
|
154
|
+
require('./lib/test-worker'); // eslint-disable-line import/no-unassigned-import
|
|
142
155
|
});
|