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/types/make.js
CHANGED
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
|
|
15
15
|
const path = require('path');
|
|
16
16
|
const fs = require('fs');
|
|
17
|
+
const isArraySorted = require('is-array-sorted');
|
|
17
18
|
const runner = require('../lib/runner');
|
|
18
19
|
|
|
19
|
-
const arrayHas = parts => part => parts.
|
|
20
|
+
const arrayHas = parts => part => parts.indexOf(part) !== -1;
|
|
20
21
|
|
|
21
22
|
const base = fs.readFileSync(path.join(__dirname, 'base.d.ts'), 'utf8');
|
|
22
23
|
|
|
@@ -35,24 +36,34 @@ function generatePrefixed(prefix) {
|
|
|
35
36
|
for (const part of allParts) {
|
|
36
37
|
const parts = prefix.concat([part]);
|
|
37
38
|
|
|
38
|
-
if (prefix.
|
|
39
|
+
if (prefix.indexOf(part) !== -1 || !verify(parts, true)) {
|
|
39
40
|
// Function already in prefix or not allowed here
|
|
40
41
|
continue;
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
// If `parts` is not sorted, we alias it to the sorted chain
|
|
45
|
+
if (!isArraySorted(parts)) {
|
|
46
|
+
const chain = parts.sort().join('.');
|
|
47
|
+
|
|
48
|
+
if (exists(parts)) {
|
|
49
|
+
output += `\texport const ${part}: typeof test.${chain};\n`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
|
|
43
55
|
// Check that `part` is a valid function name.
|
|
44
56
|
// `always` is a valid prefix, for instance of `always.after`,
|
|
45
57
|
// but not a valid function name.
|
|
46
58
|
if (verify(parts, false)) {
|
|
47
|
-
if (
|
|
48
|
-
output += '\texport const ' + part + ': typeof test.' + parts.sort().join('.') + ';\n';
|
|
49
|
-
continue;
|
|
50
|
-
} else if (prefix.includes(parts, 'todo')) {
|
|
59
|
+
if (parts.indexOf('todo') !== -1) { // eslint-disable-line no-negated-condition
|
|
51
60
|
output += '\t' + writeFunction(part, 'name: string', 'void');
|
|
52
61
|
} else {
|
|
53
62
|
const type = testType(parts);
|
|
54
|
-
output += '\t' + writeFunction(part,
|
|
55
|
-
output += '\t' + writeFunction(part,
|
|
63
|
+
output += '\t' + writeFunction(part, `name: string, implementation: ${type}`);
|
|
64
|
+
output += '\t' + writeFunction(part, `implementation: ${type}`);
|
|
65
|
+
output += '\t' + writeFunction(part, `name: string, implementation: Macros<${type}Context>, ...args: any[]`);
|
|
66
|
+
output += '\t' + writeFunction(part, `implementation: Macros<${type}Context>, ...args: any[]`);
|
|
56
67
|
}
|
|
57
68
|
}
|
|
58
69
|
|
|
@@ -63,13 +74,19 @@ function generatePrefixed(prefix) {
|
|
|
63
74
|
return children;
|
|
64
75
|
}
|
|
65
76
|
|
|
66
|
-
|
|
77
|
+
const namespace = ['test'].concat(prefix).join('.');
|
|
78
|
+
|
|
79
|
+
return `export namespace ${namespace} {\n${output}}\n${children}`;
|
|
67
80
|
}
|
|
68
81
|
|
|
69
82
|
function writeFunction(name, args) {
|
|
70
|
-
return
|
|
83
|
+
return `export function ${name}(${args}): void;\n`;
|
|
71
84
|
}
|
|
72
85
|
|
|
86
|
+
// Checks whether a chain is a valid function name (when `asPrefix === false`)
|
|
87
|
+
// or a valid prefix that could contain members.
|
|
88
|
+
// For instance, `test.always` is not a valid function name, but it is a valid
|
|
89
|
+
// prefix of `test.always.after`.
|
|
73
90
|
function verify(parts, asPrefix) {
|
|
74
91
|
const has = arrayHas(parts);
|
|
75
92
|
|
|
@@ -93,28 +110,42 @@ function verify(parts, asPrefix) {
|
|
|
93
110
|
// `always` can only be used with `after` or `afterEach`.
|
|
94
111
|
// Without it can still be a valid prefix
|
|
95
112
|
if (has('after') || has('afterEach')) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (!verify(parts.concat(['after']), false) && !verify(parts.concat(['afterEach']), false)) {
|
|
100
117
|
// If `after` nor `afterEach` cannot be added to this prefix,
|
|
101
118
|
// `always` is not allowed here.
|
|
102
119
|
return false;
|
|
103
120
|
}
|
|
121
|
+
|
|
122
|
+
// Only allowed as a prefix
|
|
123
|
+
return asPrefix;
|
|
104
124
|
}
|
|
105
125
|
|
|
106
126
|
return true;
|
|
107
127
|
}
|
|
108
128
|
|
|
109
|
-
// Checks
|
|
110
|
-
function
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
129
|
+
// Checks whether a chain is a valid function name or a valid prefix with some member
|
|
130
|
+
function exists(parts) {
|
|
131
|
+
if (verify(parts, false)) {
|
|
132
|
+
// Valid function name
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (!verify(parts, true)) {
|
|
137
|
+
// Not valid prefix
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Valid prefix, check whether it has members
|
|
142
|
+
for (const prefix of allParts) {
|
|
143
|
+
if (parts.indexOf(prefix) === -1 && exists(parts.concat([prefix]))) {
|
|
144
|
+
return true;
|
|
114
145
|
}
|
|
115
146
|
}
|
|
116
147
|
|
|
117
|
-
return
|
|
148
|
+
return false;
|
|
118
149
|
}
|
|
119
150
|
|
|
120
151
|
// Returns the type name of for the test implementation
|
|
@@ -123,11 +154,11 @@ function testType(parts) {
|
|
|
123
154
|
let type = 'Test';
|
|
124
155
|
|
|
125
156
|
if (has('cb')) {
|
|
126
|
-
type =
|
|
157
|
+
type = `Callback${type}`;
|
|
127
158
|
}
|
|
128
159
|
|
|
129
|
-
if (!has('
|
|
130
|
-
type =
|
|
160
|
+
if (!has('before') && !has('after')) {
|
|
161
|
+
type = `Contextual${type}`;
|
|
131
162
|
}
|
|
132
163
|
|
|
133
164
|
return type;
|
package/lib/send.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// utility to send messages to processes
|
|
4
|
-
module.exports = function (ps, name, data) {
|
|
5
|
-
if (typeof ps === 'string') {
|
|
6
|
-
data = name || {};
|
|
7
|
-
name = ps;
|
|
8
|
-
ps = process;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
ps.send({
|
|
12
|
-
name: 'ava-' + name,
|
|
13
|
-
data: data,
|
|
14
|
-
ava: true
|
|
15
|
-
});
|
|
16
|
-
};
|