tape-six 0.12.3 → 1.0.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/README.md +211 -7
- package/bin/tape6-bun.js +2 -2
- package/bin/tape6-deno.js +2 -2
- package/bin/tape6-node.js +2 -2
- package/bin/tape6.js +0 -0
- package/index.js +7 -2
- package/package.json +2 -2
- package/src/JSONLReporter.js +1 -1
- package/src/Tester.js +2 -2
- package/web-app/index.js +36 -9
package/README.md
CHANGED
|
@@ -3,35 +3,239 @@
|
|
|
3
3
|
[npm-img]: https://img.shields.io/npm/v/tape-six.svg
|
|
4
4
|
[npm-url]: https://npmjs.org/package/tape-six
|
|
5
5
|
|
|
6
|
-
tape-six is a [TAP](https://en.wikipedia.org/wiki/Test_Anything_Protocol)-based library for unit tests.
|
|
6
|
+
tape-six is a [TAP](https://en.wikipedia.org/wiki/Test_Anything_Protocol)-based library for unit tests.
|
|
7
|
+
It is written in the modern JavaScript for the modern JavaScript and works in [Node](https://nodejs.org/),
|
|
8
|
+
[Deno](https://deno.land/), [Bun](https://bun.sh/) and browsers.
|
|
7
9
|
|
|
8
|
-
Why `tape-six`? It was supposed to be named `tape6` but `npm` does not allow names "similar"
|
|
10
|
+
Why `tape-six`? It was supposed to be named `tape6` but `npm` does not allow names "similar"
|
|
11
|
+
to existing packages. Instead of eliminating name-squatting they force to use unintuitive and
|
|
12
|
+
unmemorable names. That's why all internal names, environment variables, and public names still use `tape6`.
|
|
9
13
|
|
|
10
14
|
## Rationale
|
|
11
15
|
|
|
12
|
-
Why another library? Working on projects written in modern JS (with modules) I found several problems
|
|
16
|
+
Why another library? Working on projects written in modern JS (with modules) I found several problems
|
|
17
|
+
with existing unit test libraries:
|
|
13
18
|
|
|
14
|
-
* In my opinion unit test files should be directly executable with `node`, `deno`, browsers
|
|
19
|
+
* In my opinion unit test files should be directly executable with `node`, `deno`, `bun`, browsers
|
|
20
|
+
(with a trivial HTML file to load a test file) without a need for a special test runner utility,
|
|
21
|
+
which wraps and changes my beautiful code.
|
|
15
22
|
* Debugging my tests should be trivial. It should not be different from debugging any regular file.
|
|
16
23
|
* The test harness should not obfuscate code nor include hundreds of other packages.
|
|
17
24
|
* I want to debug my code, not dependencies I've never heard about.
|
|
18
25
|
* I want to see where a problem happens, not some guts of a test harness.
|
|
19
26
|
* Tests should work with ES modules natively.
|
|
20
|
-
* What if I want to debug some CommonJS code with Node? Fret not! Modules can import CommonJS files directly.
|
|
27
|
+
* What if I want to debug some CommonJS code with Node? Fret not! Modules can import CommonJS files directly.
|
|
28
|
+
But not the other way around (yet). And it helps to test how module users can use your beautiful
|
|
29
|
+
CommonJS package.
|
|
21
30
|
* The [DX](https://en.wikipedia.org/wiki/User_experience#Developer_experience) in browsers are usually abysmal.
|
|
22
31
|
* Both console-based debugging and a UI to navigate results should be properly supported.
|
|
23
32
|
|
|
24
33
|
## Docs
|
|
25
34
|
|
|
26
35
|
The documentation can be found in the [wiki](https://github.com/uhop/tape-six/wiki).
|
|
36
|
+
See how it can be used in [tests/](https://github.com/uhop/tape-six/tree/master/tests).
|
|
27
37
|
|
|
28
|
-
The
|
|
29
|
-
|
|
38
|
+
The whole API is based on two objects: `test` and `Tester`.
|
|
39
|
+
|
|
40
|
+
### `test`
|
|
41
|
+
|
|
42
|
+
`test` is the entry point to the test suite:
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
import test from 'tape-six';
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
This function registers a test suite. Available options:
|
|
49
|
+
|
|
50
|
+
* `async test(name, options, testFn)` — registers a test suite to be executed asynchronously.
|
|
51
|
+
The returned promise is resolved when the test suite is finished.
|
|
52
|
+
* In most cases no need to wait for the returned promise.
|
|
53
|
+
* The test function has the following signature: `testFn(tester)`
|
|
54
|
+
* `test.skip(name, options, testFn)` — registers a test suite to be skipped.
|
|
55
|
+
* It is used to mark a test suite to be skipped. It will not be executed.
|
|
56
|
+
* `test.todo(name, options, testFn)` — registers a test suite that is marked as work in progress.
|
|
57
|
+
* Tests in this suite will be executed, errors will be reported but not counted as failures.
|
|
58
|
+
* It is used to mark tests for incomplete features under development.
|
|
59
|
+
* `test.asPromise(name, options, testPromiseFn)` — registers a test suite to be executed asynchronously
|
|
60
|
+
using the callback-style API to notify that the test suite is finished.
|
|
61
|
+
* The test function has a different signature: `testPromiseFn(tester, resolve, reject)`.
|
|
62
|
+
|
|
63
|
+
The arguments mentioned above are:
|
|
64
|
+
|
|
65
|
+
* `name` — the optional name of the test suite. If not provided, it will be set to the name of the test function or `'(anonymous)'`.
|
|
66
|
+
* `options` — the optional options object. Available options:
|
|
67
|
+
* `skip` — if `true`, the test suite will be skipped.
|
|
68
|
+
* `todo` — if `true`, the test suite will be marked as work in progress.
|
|
69
|
+
* `name` — the optional name of the test suite. If not provided, it will be set to the name of the test function or `'(anonymous)'`.
|
|
70
|
+
* Can be overridden by the `name` argument.
|
|
71
|
+
* `testFn` — the optional test function to be executed.
|
|
72
|
+
* Can be overridden by the `testFn` argument.
|
|
73
|
+
* `timeout` — the optional timeout in milliseconds. It is used for asynchronous tests.
|
|
74
|
+
* If the timeout is exceeded, the test suite will be marked as failed.
|
|
75
|
+
* **Important:** JavaScript does not provide a generic way to cancel asynchronous operations.
|
|
76
|
+
When the timeout is exceeded, `tape6` will stop waiting for the test to finish,
|
|
77
|
+
but it will continue running in the background.
|
|
78
|
+
* The default: no timeout.
|
|
79
|
+
* `testFn` — the test function to be executed. It will be called with the `tester` object.
|
|
80
|
+
The result will be ignored.
|
|
81
|
+
* This function can be an asynchronous one or return a promise.
|
|
82
|
+
* `testPromiseFn` — the test function to be executed. It will be called with the `tester` object
|
|
83
|
+
and two callbacks: `resolve` and `reject` modeled on the [Promise API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/Promise).
|
|
84
|
+
|
|
85
|
+
Given all that `test` and its helpers can be called like this:
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
test(name, options, testFn);
|
|
89
|
+
test(name, testFn);
|
|
90
|
+
test(testFn);
|
|
91
|
+
test(name, options);
|
|
92
|
+
test(options, testFn);
|
|
93
|
+
test(options);
|
|
94
|
+
|
|
95
|
+
// examples:
|
|
96
|
+
test('foo', t => {
|
|
97
|
+
t.pass();
|
|
98
|
+
});
|
|
99
|
+
test('bar', async t => {
|
|
100
|
+
t.fail();
|
|
101
|
+
});
|
|
102
|
+
test(function baz(t) {
|
|
103
|
+
t.ok(1 < 2);
|
|
104
|
+
});
|
|
105
|
+
test({
|
|
106
|
+
name: 'qux',
|
|
107
|
+
todo: true,
|
|
108
|
+
testFn: t => {
|
|
109
|
+
t.ok(1 < 2);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### `Tester`
|
|
115
|
+
|
|
116
|
+
`Tester` helps to do asserts and provides an interface between a test suite and the test harness.
|
|
117
|
+
The following methods are available (all `msg` arguments are optional):
|
|
118
|
+
|
|
119
|
+
* Asserts:
|
|
120
|
+
* `pass(msg)` — asserts that the test passed.
|
|
121
|
+
* `fail(msg)` — asserts that the test failed.
|
|
122
|
+
* `ok(val, msg)` — asserts that `val` is truthy.
|
|
123
|
+
* `true()` — an alias of `ok()`.
|
|
124
|
+
* `assert()` — an alias of `ok()`.
|
|
125
|
+
* `notOk(val, msg)` — asserts that `val` is falsy.
|
|
126
|
+
* `false()` — an alias of `notOk()`.
|
|
127
|
+
* `notok()` — an alias of `notOk()`.
|
|
128
|
+
* `error(err, msg)` — asserts that `err` is falsy.
|
|
129
|
+
* `ifError()` — an alias of `error()`.
|
|
130
|
+
* `ifErr()` — an alias of `error()`.
|
|
131
|
+
* `iferror()` — an alias of `error()`.
|
|
132
|
+
* `strictEqual(a, b, msg)` — asserts that `a` and `b` are strictly equal.
|
|
133
|
+
* Strict equality is defined as `a === b`.
|
|
134
|
+
* `is()` — an alias of `strictEqual()`.
|
|
135
|
+
* `equal()` — an alias of `strictEqual()`.
|
|
136
|
+
* `isEqual()` — an alias of `strictEqual()`.
|
|
137
|
+
* `equals()` — an alias of `strictEqual()`.
|
|
138
|
+
* `strictEquals()` — an alias of `strictEqual()`.
|
|
139
|
+
* `notStrictEqual(a, b, msg)` — asserts that `a` and `b` are not strictly equal.
|
|
140
|
+
* `not()` — an alias of `notStrictEqual()`.
|
|
141
|
+
* `notEqual()` — an alias of `notStrictEqual()`.
|
|
142
|
+
* `notEquals()` — an alias of `notStrictEqual()`.
|
|
143
|
+
* `notStrictEquals()` — an alias of `notStrictEqual()`.
|
|
144
|
+
* `doesNotEqual()` — an alias of `notStrictEqual()`.
|
|
145
|
+
* `isUnequal()` — an alias of `notStrictEqual()`.
|
|
146
|
+
* `looseEqual(a, b, msg)` — asserts that `a` and `b` are loosely equal.
|
|
147
|
+
* Loose equality is defined as `a == b`.
|
|
148
|
+
* `looseEquals()` — an alias of `looseEqual()`.
|
|
149
|
+
* `notLooseEqual(a, b, msg)` — asserts that `a` and `b` are not loosely equal.
|
|
150
|
+
* `notLooseEquals()` — an alias of `notLooseEqual()`.
|
|
151
|
+
* `deepEqual(a, b, msg)` — asserts that `a` and `b` are deeply equal.
|
|
152
|
+
* Individual components of `a` and `b` are compared recursively using the strict equality.
|
|
153
|
+
* See [deep6's equal()](https://github.com/uhop/deep6/wiki/equal()) for details.
|
|
154
|
+
* `same()` — an alias of `deepEqual()`.
|
|
155
|
+
* `deepEquals()` — an alias of `deepEqual()`.
|
|
156
|
+
* `isEquivalent()` — an alias of `deepEqual()`.
|
|
157
|
+
* `notDeepEqual(a, b, msg)` — asserts that `a` and `b` are not deeply equal.
|
|
158
|
+
* `notSame()` — an alias of `notDeepEqual()`.
|
|
159
|
+
* `notDeepEquals()` — an alias of `notDeepEqual()`.
|
|
160
|
+
* `notEquivalent()` — an alias of `notDeepEqual()`.
|
|
161
|
+
* `notDeeply()` — an alias of `notDeepEqual()`.
|
|
162
|
+
* `isNotDeepEqual()` — an alias of `notDeepEqual()`.
|
|
163
|
+
* `isNotEquivalent()` — an alias of `notDeepEqual()`.
|
|
164
|
+
* `deepLooseEqual(a, b, msg)` — asserts that `a` and `b` are deeply loosely equal.
|
|
165
|
+
* Individual components of `a` and `b` are compared recursively using the loose equality.
|
|
166
|
+
* `notDeepLooseEqual(a, b, msg)` — asserts that `a` and `b` are not deeply loosely equal.
|
|
167
|
+
* `throws(fn, msg)` — asserts that `fn` throws.
|
|
168
|
+
* `fn` is called with no arguments in the global context.
|
|
169
|
+
* `doesNotThrow(fn, msg)` — asserts that `fn` does not throw.
|
|
170
|
+
* `matchString(string, regexp, msg)` — asserts that `string` matches `regexp`.
|
|
171
|
+
* `doesNotMatchString(string, regexp, msg)` — asserts that `string` does not match `regexp`.
|
|
172
|
+
* `match(a, b, msg)` — asserts that `a` matches `b`.
|
|
173
|
+
* See [deep6's match()](https://github.com/uhop/deep6/wiki/match()) for details.
|
|
174
|
+
* `doesNotMatch(a, b, msg)` — asserts that `a` does not match `b`.
|
|
175
|
+
* `rejects(promise, msg)` — asserts that `promise` rejects.
|
|
176
|
+
* This is an asynchronous method. It is likely to be waited for.
|
|
177
|
+
* `doesNotResolve()` — an alias of `rejects()`.
|
|
178
|
+
* `resolves(promise, msg)` — asserts that `promise` resolves.
|
|
179
|
+
* This is an asynchronous method. It is likely to be waited for.
|
|
180
|
+
* `doesNotReject()` — an alias of `resolves()`.
|
|
181
|
+
* Embedded test suites (all of them are asynchronous and should be waited for):
|
|
182
|
+
* `test(name, options, testFn)` — runs a test suite asynchronously. See `test()` above.
|
|
183
|
+
* `skip(name, options, testFn)` — skips a test suite asynchronously. See `test.skip()` above.
|
|
184
|
+
* `todo(name, options, testFn)` — runs a provisional test suite asynchronously. See `test.todo()` above.
|
|
185
|
+
* `asPromise(name, options, testPromiseFn)` — runs a test suite asynchronously. See `test.asPromise()` above.
|
|
186
|
+
* Miscellaneous:
|
|
187
|
+
* `any` — returns the `any` object. It can be used in deep equivalency asserts to match any value.
|
|
188
|
+
See [deep6's any](https://github.com/uhop/deep6/wiki/any) for details.
|
|
189
|
+
* `plan(n)` — sets the number of tests in the test suite. Rarely used.
|
|
190
|
+
* `comment(msg)` — sends a comment to the test harness. Rarely used.
|
|
191
|
+
* `skipTest(...args, msg)` — skips the current test yet sends a message to the test harness.
|
|
192
|
+
* `bailOut(msg)` — stops the test suite and sends a message to the test harness.
|
|
193
|
+
|
|
194
|
+
In all cases, the `msg` message is optional. If it is not provided, some suitable generic message will be used.
|
|
195
|
+
|
|
196
|
+
Example:
|
|
197
|
+
|
|
198
|
+
```js
|
|
199
|
+
test('Sample test', async t => {
|
|
200
|
+
const result = await getFromDb({first: 'Bob', last: 'Smith'});
|
|
201
|
+
t.equal(result.position, 'chief bozo', 'the position is correct');
|
|
202
|
+
t.ok(result.manager, 'the manager exists');
|
|
203
|
+
|
|
204
|
+
const manager = await getFromDb(result.manager);
|
|
205
|
+
t.ok(manager, 'the manager is retrieved');
|
|
206
|
+
t.equal(manager.first, 'Jane', 'the manager is Jane');
|
|
207
|
+
t.deepEqual(manager.employees, ['Bob Smith'], 'Jane manages only Bob Smith');
|
|
208
|
+
});
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Running tests
|
|
212
|
+
|
|
213
|
+
It is super easy to run tests:
|
|
214
|
+
|
|
215
|
+
1. Install the `tape-six` package: `npm i -D tape-six`
|
|
216
|
+
2. Write a test. For example, you named it `test.js`.
|
|
217
|
+
3. Run the test: `node test.js`
|
|
218
|
+
1. Or: `bun run test.js`
|
|
219
|
+
2. Or: `deno run -A test.js`
|
|
220
|
+
3. Or you can run them in a browser!
|
|
221
|
+
4. Profit!
|
|
222
|
+
|
|
223
|
+
If you have a lot of tests, you can organize them using multiple files and directories.
|
|
224
|
+
`tape-six` provides multiple test runners that can run them in different environments.
|
|
225
|
+
|
|
226
|
+
### Command-line utilities
|
|
227
|
+
|
|
228
|
+
TBD
|
|
229
|
+
|
|
230
|
+
### Setting up your project
|
|
231
|
+
|
|
232
|
+
TBD
|
|
30
233
|
|
|
31
234
|
## Release notes
|
|
32
235
|
|
|
33
236
|
The most recent releases:
|
|
34
237
|
|
|
238
|
+
* 1.0.0 *The first official release.*
|
|
35
239
|
* 0.12.3 *Technical release: exposed internal classes for external utilities.*
|
|
36
240
|
* 0.12.2 *Fixed a minor serialization issue.*
|
|
37
241
|
* 0.12.1 *Minor Deno-related refactoring, fixed the way tests are triggered.*
|
package/bin/tape6-bun.js
CHANGED
|
@@ -38,7 +38,7 @@ const config = () => {
|
|
|
38
38
|
d: 'showData',
|
|
39
39
|
o: 'failOnce',
|
|
40
40
|
n: 'showAssertNumber',
|
|
41
|
-
|
|
41
|
+
m: 'monochrome'
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
let flagIsSet = false,
|
|
@@ -103,7 +103,7 @@ const init = async () => {
|
|
|
103
103
|
reporter = ttyReporter.report.bind(ttyReporter);
|
|
104
104
|
}
|
|
105
105
|
if (!reporter) {
|
|
106
|
-
const tapReporter = new TapReporter({useJson: true});
|
|
106
|
+
const tapReporter = new TapReporter({useJson: true, hasColors: !options.monochrome});
|
|
107
107
|
reporter = tapReporter.report.bind(tapReporter);
|
|
108
108
|
}
|
|
109
109
|
setReporter(reporter);
|
package/bin/tape6-deno.js
CHANGED
|
@@ -38,7 +38,7 @@ const config = () => {
|
|
|
38
38
|
d: 'showData',
|
|
39
39
|
o: 'failOnce',
|
|
40
40
|
n: 'showAssertNumber',
|
|
41
|
-
|
|
41
|
+
m: 'monochrome'
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
let flagIsSet = false,
|
|
@@ -103,7 +103,7 @@ const init = async () => {
|
|
|
103
103
|
reporter = ttyReporter.report.bind(ttyReporter);
|
|
104
104
|
}
|
|
105
105
|
if (!reporter) {
|
|
106
|
-
const tapReporter = new TapReporter({useJson: true});
|
|
106
|
+
const tapReporter = new TapReporter({useJson: true, hasColors: !options.monochrome});
|
|
107
107
|
reporter = tapReporter.report.bind(tapReporter);
|
|
108
108
|
}
|
|
109
109
|
setReporter(reporter);
|
package/bin/tape6-node.js
CHANGED
|
@@ -39,7 +39,7 @@ const config = () => {
|
|
|
39
39
|
d: 'showData',
|
|
40
40
|
o: 'failOnce',
|
|
41
41
|
n: 'showAssertNumber',
|
|
42
|
-
|
|
42
|
+
m: 'monochrome'
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
let flagIsSet = false,
|
|
@@ -104,7 +104,7 @@ const init = async () => {
|
|
|
104
104
|
reporter = ttyReporter.report.bind(ttyReporter);
|
|
105
105
|
}
|
|
106
106
|
if (!reporter) {
|
|
107
|
-
const tapReporter = new TapReporter({useJson: true});
|
|
107
|
+
const tapReporter = new TapReporter({useJson: true, hasColors: !options.monochrome});
|
|
108
108
|
reporter = tapReporter.report.bind(tapReporter);
|
|
109
109
|
}
|
|
110
110
|
setReporter(reporter);
|
package/bin/tape6.js
CHANGED
|
File without changes
|
package/index.js
CHANGED
|
@@ -19,7 +19,8 @@ const optionNames = {
|
|
|
19
19
|
d: 'showData',
|
|
20
20
|
o: 'failOnce',
|
|
21
21
|
n: 'showAssertNumber',
|
|
22
|
-
|
|
22
|
+
m: 'monochrome',
|
|
23
|
+
j: 'useJsonL'
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
const init = async () => {
|
|
@@ -60,6 +61,10 @@ const init = async () => {
|
|
|
60
61
|
reporter = event => window.__tape6_reporter(id, event);
|
|
61
62
|
} else if (window.parent && typeof window.parent.__tape6_reporter == 'function') {
|
|
62
63
|
reporter = event => window.parent.__tape6_reporter(id, event);
|
|
64
|
+
} else if (options.useJsonL) {
|
|
65
|
+
const JSONLReporter = (await import('./src/JSONLReporter.js')).default,
|
|
66
|
+
jsonlReporter = new JSONLReporter(options);
|
|
67
|
+
reporter = jsonlReporter.report.bind(jsonlReporter);
|
|
63
68
|
}
|
|
64
69
|
} else if (isDeno) {
|
|
65
70
|
if (Deno.env.TAPE6_JSONL) {
|
|
@@ -93,7 +98,7 @@ const init = async () => {
|
|
|
93
98
|
}
|
|
94
99
|
}
|
|
95
100
|
if (!reporter) {
|
|
96
|
-
const tapReporter = new TapReporter({useJson: true, hasColors: options.
|
|
101
|
+
const tapReporter = new TapReporter({useJson: true, hasColors: !options.monochrome});
|
|
97
102
|
reporter = tapReporter.report.bind(tapReporter);
|
|
98
103
|
}
|
|
99
104
|
setReporter(reporter);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tape-six",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "TAP the test harness for the modern JavaScript (ES6).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -64,6 +64,6 @@
|
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"puppeteer": "^23.
|
|
67
|
+
"puppeteer": "^23.5.1"
|
|
68
68
|
}
|
|
69
69
|
}
|
package/src/JSONLReporter.js
CHANGED
package/src/Tester.js
CHANGED
|
@@ -398,11 +398,11 @@ setAliases('ok', 'true, assert');
|
|
|
398
398
|
setAliases('notOk', 'false, notok');
|
|
399
399
|
setAliases('error', 'ifError, ifErr, iferror');
|
|
400
400
|
setAliases('strictEqual', 'is, equal, equals, isEqual, strictEquals');
|
|
401
|
-
setAliases('notStrictEqual', 'not, notEqual, notEquals, isNotEqual, doesNotEqual,
|
|
401
|
+
setAliases('notStrictEqual', 'not, notEqual, notEquals, isNotEqual, doesNotEqual, isUnequal, notStrictEquals, isNot');
|
|
402
402
|
setAliases('looseEqual', 'looseEquals');
|
|
403
403
|
setAliases('notLooseEqual', 'notLooseEquals');
|
|
404
404
|
setAliases('deepEqual', 'same, deepEquals, isEquivalent');
|
|
405
|
-
setAliases('notDeepEqual', 'notSame, notDeepEquals, notEquivalent, notDeeply, isNotDeepEqual,
|
|
405
|
+
setAliases('notDeepEqual', 'notSame, notDeepEquals, notEquivalent, notDeeply, isNotDeepEqual, isNotEquivalent');
|
|
406
406
|
setAliases('rejects', 'doesNotResolve');
|
|
407
407
|
setAliases('resolves', 'doesNotReject');
|
|
408
408
|
|
package/web-app/index.js
CHANGED
|
@@ -3,13 +3,25 @@ import {getReporter, setReporter, setConfiguredFlag} from '../src/test.js';
|
|
|
3
3
|
import defer from '../src/utils/defer.js';
|
|
4
4
|
import State, {StopTest} from '../src/State.js';
|
|
5
5
|
import TapReporter from '../src/TapReporter.js';
|
|
6
|
+
import JSONLReporter from '../src/JSONLReporter.js';
|
|
6
7
|
import DomReporter from './DomReporter.js';
|
|
7
8
|
import DashReporter from './DashReporter.js';
|
|
8
9
|
import TestWorker from './TestWorker.js';
|
|
9
10
|
|
|
10
11
|
setConfiguredFlag(true); // we are running the show
|
|
11
12
|
|
|
12
|
-
const optionNames = {
|
|
13
|
+
const optionNames = {
|
|
14
|
+
f: 'failureOnly',
|
|
15
|
+
t: 'showTime',
|
|
16
|
+
b: 'showBanner',
|
|
17
|
+
d: 'showData',
|
|
18
|
+
o: 'failOnce',
|
|
19
|
+
s: 'showStack',
|
|
20
|
+
l: 'showLog',
|
|
21
|
+
n: 'showAssertNumber',
|
|
22
|
+
m: 'monochrome',
|
|
23
|
+
j: 'useJsonL'
|
|
24
|
+
},
|
|
13
25
|
options = {};
|
|
14
26
|
|
|
15
27
|
let flags = '',
|
|
@@ -62,10 +74,23 @@ window.addEventListener('DOMContentLoaded', () => {
|
|
|
62
74
|
};
|
|
63
75
|
}
|
|
64
76
|
|
|
65
|
-
const
|
|
66
|
-
domReporter = new DomReporter({root: document.querySelector('.tape6 .report')})
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
const dashReporter = new DashReporter(),
|
|
78
|
+
domReporter = new DomReporter({root: document.querySelector('.tape6 .report')});
|
|
79
|
+
|
|
80
|
+
let textReporter = null;
|
|
81
|
+
if (options.showLog) {
|
|
82
|
+
textReporter = options.useJsonL
|
|
83
|
+
? new JSONLReporter()
|
|
84
|
+
: new TapReporter({useJson: true, hasColors: !options.monochrome});
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
setReporter(
|
|
88
|
+
event => (
|
|
89
|
+
textReporter && textReporter.report(event),
|
|
90
|
+
domReporter.report(event),
|
|
91
|
+
dashReporter.report(event)
|
|
92
|
+
)
|
|
93
|
+
);
|
|
69
94
|
|
|
70
95
|
const donut = document.querySelector('tape6-donut');
|
|
71
96
|
donut.show([{value: 0, className: 'nothing'}], {
|
|
@@ -92,9 +117,9 @@ window.addEventListener('DOMContentLoaded', () => {
|
|
|
92
117
|
|
|
93
118
|
if (window.location.search) {
|
|
94
119
|
if (patterns && patterns.length) {
|
|
95
|
-
files = await fetch(
|
|
96
|
-
|
|
97
|
-
);
|
|
120
|
+
files = await fetch(
|
|
121
|
+
'/--patterns?' + patterns.map(pattern => 'q=' + encodeURIComponent(pattern)).join('&')
|
|
122
|
+
).then(response => (response.ok ? response.json() : null));
|
|
98
123
|
}
|
|
99
124
|
}
|
|
100
125
|
|
|
@@ -107,7 +132,9 @@ window.addEventListener('DOMContentLoaded', () => {
|
|
|
107
132
|
return;
|
|
108
133
|
}
|
|
109
134
|
|
|
110
|
-
const importmap = await fetch('/--importmap').then(response =>
|
|
135
|
+
const importmap = await fetch('/--importmap').then(response =>
|
|
136
|
+
response.ok ? response.json() : null
|
|
137
|
+
);
|
|
111
138
|
if (importmap) options.importmap = importmap;
|
|
112
139
|
|
|
113
140
|
const rootState = new State(null, {callback: getReporter(), failOnce: options.failOnce}),
|