ava 0.16.0 → 0.17.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/api.js +238 -188
- package/cli.js +11 -174
- package/index.js +5 -98
- package/index.js.flow +218 -0
- package/lib/assert.js +3 -3
- package/lib/babel-config.js +11 -5
- package/lib/beautify-stack.js +23 -0
- package/lib/caching-precompiler.js +25 -29
- package/lib/cli.js +172 -0
- package/lib/colors.js +2 -0
- package/lib/concurrent.js +2 -3
- package/lib/fork.js +23 -15
- package/lib/logger.js +4 -5
- package/lib/main.js +89 -0
- package/lib/prefix-title.js +25 -0
- package/lib/process-adapter.js +107 -0
- package/lib/reporters/mini.js +32 -27
- package/lib/run-status.js +5 -25
- package/lib/sequence.js +2 -4
- package/lib/test-worker.js +8 -71
- package/lib/throws-helper.js +1 -1
- package/lib/watcher.js +2 -5
- package/package.json +27 -26
- package/profile.js +10 -9
- package/readme.md +15 -12
- package/types/generated.d.ts +994 -192
- package/types/make.js +41 -9
- package/lib/send.js +0 -16
package/types/make.js
CHANGED
|
@@ -40,19 +40,27 @@ function generatePrefixed(prefix) {
|
|
|
40
40
|
continue;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
// If `parts` is not sorted, we alias it to the sorted chain.
|
|
44
|
+
if (!isSorted(parts)) {
|
|
45
|
+
const chain = parts.sort().join('.');
|
|
46
|
+
if (exists(parts)) {
|
|
47
|
+
output += '\texport const ' + part + ': typeof test.' + chain + ';\n';
|
|
48
|
+
}
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
|
|
43
52
|
// Check that `part` is a valid function name.
|
|
44
53
|
// `always` is a valid prefix, for instance of `always.after`,
|
|
45
54
|
// but not a valid function name.
|
|
46
55
|
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')) {
|
|
56
|
+
if (prefix.includes(parts, 'todo')) {
|
|
51
57
|
output += '\t' + writeFunction(part, 'name: string', 'void');
|
|
52
58
|
} else {
|
|
53
59
|
const type = testType(parts);
|
|
54
60
|
output += '\t' + writeFunction(part, 'name: string, implementation: ' + type);
|
|
55
61
|
output += '\t' + writeFunction(part, 'implementation: ' + type);
|
|
62
|
+
output += '\t' + writeFunction(part, 'name: string, implementation: Macros<' + type + 'Context>, ...args: any[]');
|
|
63
|
+
output += '\t' + writeFunction(part, 'implementation: Macros<' + type + 'Context>, ...args: any[]');
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
66
|
|
|
@@ -70,6 +78,10 @@ function writeFunction(name, args) {
|
|
|
70
78
|
return 'export function ' + name + '(' + args + '): void;\n';
|
|
71
79
|
}
|
|
72
80
|
|
|
81
|
+
// Checks whether a chain is a valid function name (when `asPrefix === false`)
|
|
82
|
+
// or a valid prefix that could contain members.
|
|
83
|
+
// For instance, `test.always` is not a valid function name, but it is a valid
|
|
84
|
+
// prefix of `test.always.after`.
|
|
73
85
|
function verify(parts, asPrefix) {
|
|
74
86
|
const has = arrayHas(parts);
|
|
75
87
|
|
|
@@ -93,19 +105,39 @@ function verify(parts, asPrefix) {
|
|
|
93
105
|
// `always` can only be used with `after` or `afterEach`.
|
|
94
106
|
// Without it can still be a valid prefix
|
|
95
107
|
if (has('after') || has('afterEach')) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
} else if (!verify(parts.concat(['after'])) && !verify(parts.concat(['afterEach']))) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
if (!verify(parts.concat(['after']), false) && !verify(parts.concat(['afterEach']), false)) {
|
|
100
111
|
// If `after` nor `afterEach` cannot be added to this prefix,
|
|
101
112
|
// `always` is not allowed here.
|
|
102
113
|
return false;
|
|
103
114
|
}
|
|
115
|
+
// Only allowed as a prefix
|
|
116
|
+
return asPrefix;
|
|
104
117
|
}
|
|
105
118
|
|
|
106
119
|
return true;
|
|
107
120
|
}
|
|
108
121
|
|
|
122
|
+
// Checks whether a chain is a valid function name or a valid prefix with some member
|
|
123
|
+
function exists(parts) {
|
|
124
|
+
if (verify(parts, false)) {
|
|
125
|
+
// valid function name
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
if (!verify(parts, true)) {
|
|
129
|
+
// not valid prefix
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
// valid prefix, check whether it has members
|
|
133
|
+
for (const prefix of allParts) {
|
|
134
|
+
if (!parts.includes(prefix) && exists(parts.concat([prefix]))) {
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
|
|
109
141
|
// Checks that an array is sorted
|
|
110
142
|
function isSorted(a) {
|
|
111
143
|
for (let i = 1; i < a.length; i++) {
|
|
@@ -126,7 +158,7 @@ function testType(parts) {
|
|
|
126
158
|
type = 'Callback' + type;
|
|
127
159
|
}
|
|
128
160
|
|
|
129
|
-
if (!has('
|
|
161
|
+
if (!has('before') && !has('after')) {
|
|
130
162
|
type = 'Contextual' + type;
|
|
131
163
|
}
|
|
132
164
|
|
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
|
-
};
|