tape-six 1.0.3 → 1.1.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 +130 -128
- package/bin/tape6-bun.js +1 -1
- package/bin/tape6-deno.js +2 -2
- package/bin/tape6-node.js +1 -1
- package/bin/tape6-runner.js +8 -9
- package/package.json +12 -3
- package/src/Tester.js +23 -8
- package/src/bun/TestWorker.js +1 -1
- package/src/deno/TestWorker.js +1 -1
- package/src/node/TestWorker.js +1 -1
- package/src/utils/box.js +2 -1
- package/src/utils/config.js +4 -4
- package/src/utils/fileSets.js +2 -1
- package/src/utils/formatters.js +17 -3
- package/src/utils/yamlFormatter.js +8 -3
- package/web-app/donut.js +8 -2
- package/web-app/index.html +1 -1
- package/web-app/tape6-donut.css +3 -1
- package/web-app/tape6-donut.js +1 -1
- package/web-app/tape6-hflip.js +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# tape-six [![NPM version][npm-img]][npm-url]
|
|
2
2
|
|
|
3
|
-
[npm-img]:
|
|
4
|
-
[npm-url]:
|
|
3
|
+
[npm-img]: https://img.shields.io/npm/v/tape-six.svg
|
|
4
|
+
[npm-url]: https://npmjs.org/package/tape-six
|
|
5
5
|
|
|
6
6
|
`tape-six` is a [TAP](https://en.wikipedia.org/wiki/Test_Anything_Protocol)-based library for unit tests.
|
|
7
7
|
It is written in the modern JavaScript for the modern JavaScript and works in [Node](https://nodejs.org/),
|
|
@@ -16,19 +16,19 @@ unmemorable names. That's why all internal names, environment variables, and pub
|
|
|
16
16
|
Why another library? Working on projects written in modern JS (with modules) I found several problems
|
|
17
17
|
with existing unit test libraries:
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
- In my opinion unit test files should be directly executable with `node`, `deno`, `bun`, browsers
|
|
20
20
|
(with a trivial HTML file to load a test file) without a need for a special test runner utility,
|
|
21
21
|
which wraps and changes my beautiful code.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
- Debugging my tests should be trivial. It should not be different from debugging any regular file.
|
|
23
|
+
- The test harness should not obfuscate code nor include hundreds of other packages.
|
|
24
|
+
- I want to debug my code, not dependencies I've never heard about.
|
|
25
|
+
- I want to see where a problem happens, not some guts of a test harness.
|
|
26
|
+
- Tests should work with ES modules natively.
|
|
27
|
+
- What if I want to debug some CommonJS code with Node? Fret not! Modules can import CommonJS files directly.
|
|
28
28
|
But not the other way around (yet). And it helps to test how module users can use your beautiful
|
|
29
29
|
CommonJS package.
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
- The [DX](https://en.wikipedia.org/wiki/User_experience#Developer_experience) in browsers are usually abysmal.
|
|
31
|
+
- Both console-based debugging and a UI to navigate results should be properly supported.
|
|
32
32
|
|
|
33
33
|
## Docs
|
|
34
34
|
|
|
@@ -47,39 +47,39 @@ import test from 'tape-six';
|
|
|
47
47
|
|
|
48
48
|
This function registers a test suite. Available options:
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
- `async test(name, options, testFn)` — registers a test suite to be executed asynchronously.
|
|
51
51
|
The returned promise is resolved when the test suite is finished.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
60
|
using the callback-style API to notify that the test suite is finished.
|
|
61
|
-
|
|
61
|
+
- The test function has a different signature: `testPromiseFn(tester, resolve, reject)`.
|
|
62
62
|
|
|
63
63
|
The arguments mentioned above are:
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
76
|
When the timeout is exceeded, `tape6` will stop waiting for the test to finish,
|
|
77
77
|
but it will continue running in the background.
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
- The default: no timeout.
|
|
79
|
+
- `testFn` — the test function to be executed. It will be called with the `tester` object.
|
|
80
80
|
The result will be ignored.
|
|
81
|
-
|
|
82
|
-
|
|
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
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
84
|
|
|
85
85
|
Given all that `test` and its helpers can be called like this:
|
|
@@ -116,80 +116,80 @@ test({
|
|
|
116
116
|
`Tester` helps to do asserts and provides an interface between a test suite and the test harness.
|
|
117
117
|
The following methods are available (all `msg` arguments are optional):
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
188
|
See [deep6's any](https://github.com/uhop/deep6/wiki/any) for details.
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
193
|
|
|
194
194
|
In all cases, the `msg` message is optional. If it is not provided, some suitable generic message will be used.
|
|
195
195
|
|
|
@@ -229,29 +229,31 @@ See [set-up tests](https://github.com/uhop/tape-six/wiki/Set-up-tests) for detai
|
|
|
229
229
|
|
|
230
230
|
### Command-line utilities
|
|
231
231
|
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
- [tape6](https://github.com/uhop/tape-six/wiki/Utility-%E2%80%90-tape6) — the main utility of the package to run tests in different environments.
|
|
233
|
+
- [tape6-server](https://github.com/uhop/tape-six/wiki/Utility-%E2%80%90-tape6-server) — a custom web server with a web application that helps running tests in browsers.
|
|
234
234
|
|
|
235
235
|
## Release notes
|
|
236
236
|
|
|
237
237
|
The most recent releases:
|
|
238
238
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
239
|
+
- 1.1.0 _Added TypeScript support._
|
|
240
|
+
- 1.0.4 _Bugfix for platform-specific tests, old platforms, minor updates to accommodate Deno 2, updated dev deps._
|
|
241
|
+
- 1.0.3 _Minor update to accommodate changes in Bun and updated dev deps._
|
|
242
|
+
- 1.0.2 _Bugfix for Deno using the JSONL reporter._
|
|
243
|
+
- 1.0.1 _Technical release: added more links._
|
|
244
|
+
- 1.0.0 _The first official release._
|
|
245
|
+
- 0.12.3 _Technical release: exposed internal classes for external utilities._
|
|
246
|
+
- 0.12.2 _Fixed a minor serialization issue._
|
|
247
|
+
- 0.12.1 _Minor Deno-related refactoring, fixed the way tests are triggered._
|
|
248
|
+
- 0.12.0 _Removed data to avoid serializing non-serializable objects._
|
|
249
|
+
- 0.11.0 _Minor improvements to the server: temporary redirects, a hyperlink to the web app._
|
|
250
|
+
- 0.10.0 _Refactored test runners, refactored stopping tests on failure, added JSONL reporter, fixed bugs._
|
|
251
|
+
- 0.9.6 _Updated deps._
|
|
252
|
+
- 0.9.5 _Updated the lock file._
|
|
253
|
+
- 0.9.4 _Updated deps. Added test runners for Bun and Deno._
|
|
254
|
+
- 0.9.3 _Made TTY reporter work with non-TTY streams._
|
|
255
|
+
- 0.9.2 _Fixed Windows runner._
|
|
256
|
+
- 0.9.1 _More updates related to renaming `tape6` ⇒ `tape-six`._
|
|
257
|
+
- 0.9.0 _Initial release._
|
|
256
258
|
|
|
257
259
|
For more info consult full [release notes](https://github.com/uhop/tape-six/wiki/Release-notes).
|
package/bin/tape6-bun.js
CHANGED
package/bin/tape6-deno.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env -S deno run --allow-read --allow-env --
|
|
1
|
+
#!/usr/bin/env -S deno run --allow-read --allow-env --ext=js
|
|
2
2
|
|
|
3
3
|
import {fileURLToPath} from 'node:url';
|
|
4
4
|
|
|
@@ -85,7 +85,7 @@ const config = () => {
|
|
|
85
85
|
} else {
|
|
86
86
|
parallel = 0;
|
|
87
87
|
}
|
|
88
|
-
if (!parallel) parallel = navigator
|
|
88
|
+
if (!parallel) parallel = globalThis.navigator?.hardwareConcurrency || 1;
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
const init = async () => {
|
package/bin/tape6-node.js
CHANGED
package/bin/tape6-runner.js
CHANGED
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
import process from 'node:process';
|
|
4
4
|
import {fileURLToPath} from 'node:url';
|
|
5
5
|
|
|
6
|
-
const requestedRuntime =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}[process.argv[2]];
|
|
6
|
+
const requestedRuntime = {
|
|
7
|
+
node: 'tape6-node.js',
|
|
8
|
+
deno: 'tape6-deno.js',
|
|
9
|
+
bun: 'tape6-bun.js',
|
|
10
|
+
server: 'tape6-server.js',
|
|
11
|
+
runner: 'tape6-runner.js',
|
|
12
|
+
main: 'tape6.js'
|
|
13
|
+
}[process.argv[2]];
|
|
15
14
|
|
|
16
15
|
const runtime = requestedRuntime || 'tape6.js',
|
|
17
16
|
url = new URL('./' + runtime, import.meta.url),
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tape-six",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "TAP the test harness for the modern JavaScript (ES6).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"module": "index.js",
|
|
8
|
+
"types": "index.d.ts",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": "./index.js",
|
|
10
11
|
"./bin/*": "./bin/*",
|
|
@@ -22,10 +23,16 @@
|
|
|
22
23
|
"copyDeep6": "node scripts/copyFolder.js --src ./vendors/deep6/src --dst ./src/deep6 --clear",
|
|
23
24
|
"build": "npm run copyDeep6",
|
|
24
25
|
"prepublishOnly": "npm run build",
|
|
26
|
+
"lint": "prettier --check .",
|
|
27
|
+
"lint:fix": "prettier --write .",
|
|
25
28
|
"test": "node ./bin/tape6.js --flags FO",
|
|
26
29
|
"test:bun": "bun run ./bin/tape6-bun.js --flags FO",
|
|
27
30
|
"test:deno": "deno run -A ./bin/tape6-deno.js --flags FO",
|
|
28
|
-
"test:chrome": "node tests/puppeteer-chrome.js"
|
|
31
|
+
"test:chrome": "node tests/puppeteer-chrome.js",
|
|
32
|
+
"ts-check": "tsc --noEmit",
|
|
33
|
+
"ts-test": "node ./bin/tape6.js --flags FO '/ts-tests/test-*.ts'",
|
|
34
|
+
"ts-test:bun": "bun run ./bin/tape6-bun.js --flags FO '/ts-tests/test-*.ts'",
|
|
35
|
+
"ts-test:deno": "deno run -A ./bin/tape6-deno.js --flags FO '/ts-tests/test-*.ts'"
|
|
29
36
|
},
|
|
30
37
|
"github": "http://github.com/uhop/tape-six",
|
|
31
38
|
"repository": {
|
|
@@ -64,6 +71,8 @@
|
|
|
64
71
|
}
|
|
65
72
|
},
|
|
66
73
|
"devDependencies": {
|
|
67
|
-
"
|
|
74
|
+
"@types/node": "^22.13.10",
|
|
75
|
+
"puppeteer": "^24.4.0",
|
|
76
|
+
"typescript": "^5.8.2"
|
|
68
77
|
}
|
|
69
78
|
}
|
package/src/Tester.js
CHANGED
|
@@ -15,12 +15,18 @@ class Tester {
|
|
|
15
15
|
this.testNumber = testNumber;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
plan(
|
|
19
|
-
this.state.setPlan(
|
|
18
|
+
plan(_n) {
|
|
19
|
+
// this.state.setPlan(_n);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
comment(msg) {
|
|
23
|
-
this.state.emit({
|
|
23
|
+
this.state.emit({
|
|
24
|
+
type: 'comment',
|
|
25
|
+
name: msg || 'comment',
|
|
26
|
+
test: this.testNumber,
|
|
27
|
+
marker: new Error(),
|
|
28
|
+
time: this.state.timer.now()
|
|
29
|
+
});
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
skipTest(...args) {
|
|
@@ -343,7 +349,8 @@ class Tester {
|
|
|
343
349
|
}
|
|
344
350
|
|
|
345
351
|
rejects(promise, msg) {
|
|
346
|
-
if (!promise || typeof promise.then != 'function')
|
|
352
|
+
if (!promise || typeof promise.then != 'function')
|
|
353
|
+
throw new TypeError('the first argument should be a promise');
|
|
347
354
|
return promise
|
|
348
355
|
.then(
|
|
349
356
|
() => null,
|
|
@@ -366,7 +373,8 @@ class Tester {
|
|
|
366
373
|
}
|
|
367
374
|
|
|
368
375
|
resolves(promise, msg) {
|
|
369
|
-
if (!promise || typeof promise.then != 'function')
|
|
376
|
+
if (!promise || typeof promise.then != 'function')
|
|
377
|
+
throw new TypeError('the first argument should be a promise');
|
|
370
378
|
return promise
|
|
371
379
|
.then(
|
|
372
380
|
() => null,
|
|
@@ -392,17 +400,24 @@ class Tester {
|
|
|
392
400
|
}
|
|
393
401
|
Tester.prototype.any = Tester.prototype._ = any;
|
|
394
402
|
|
|
395
|
-
const setAliases = (source, aliases) =>
|
|
403
|
+
const setAliases = (source, aliases) =>
|
|
404
|
+
aliases.split(', ').forEach(alias => (Tester.prototype[alias] = Tester.prototype[source]));
|
|
396
405
|
|
|
397
406
|
setAliases('ok', 'true, assert');
|
|
398
407
|
setAliases('notOk', 'false, notok');
|
|
399
408
|
setAliases('error', 'ifError, ifErr, iferror');
|
|
400
409
|
setAliases('strictEqual', 'is, equal, equals, isEqual, strictEquals');
|
|
401
|
-
setAliases(
|
|
410
|
+
setAliases(
|
|
411
|
+
'notStrictEqual',
|
|
412
|
+
'not, notEqual, notEquals, isNotEqual, doesNotEqual, isUnequal, notStrictEquals, isNot'
|
|
413
|
+
);
|
|
402
414
|
setAliases('looseEqual', 'looseEquals');
|
|
403
415
|
setAliases('notLooseEqual', 'notLooseEquals');
|
|
404
416
|
setAliases('deepEqual', 'same, deepEquals, isEquivalent');
|
|
405
|
-
setAliases(
|
|
417
|
+
setAliases(
|
|
418
|
+
'notDeepEqual',
|
|
419
|
+
'notSame, notDeepEquals, notEquivalent, notDeeply, isNotDeepEqual, isNotEquivalent'
|
|
420
|
+
);
|
|
406
421
|
setAliases('rejects', 'doesNotResolve');
|
|
407
422
|
setAliases('resolves', 'doesNotReject');
|
|
408
423
|
|
package/src/bun/TestWorker.js
CHANGED
|
@@ -7,7 +7,7 @@ const utilName = new URL('../test.js', import.meta.url),
|
|
|
7
7
|
baseName = Bun.pathToFileURL(Bun.cwd + sep);
|
|
8
8
|
|
|
9
9
|
export default class TestWorker extends EventServer {
|
|
10
|
-
constructor(reporter, numberOfTasks = navigator
|
|
10
|
+
constructor(reporter, numberOfTasks = globalThis.navigator?.hardwareConcurrency || 1, options) {
|
|
11
11
|
super(reporter, numberOfTasks, options);
|
|
12
12
|
this.counter = 0;
|
|
13
13
|
this.idToWorker = {};
|
package/src/deno/TestWorker.js
CHANGED
|
@@ -8,7 +8,7 @@ const utilName = new URL('../test.js', import.meta.url),
|
|
|
8
8
|
baseName = pathToFileURL(Deno.cwd() + sep);
|
|
9
9
|
|
|
10
10
|
export default class TestWorker extends EventServer {
|
|
11
|
-
constructor(reporter, numberOfTasks = navigator
|
|
11
|
+
constructor(reporter, numberOfTasks = globalThis.navigator?.hardwareConcurrency || 1, options) {
|
|
12
12
|
super(reporter, numberOfTasks, options);
|
|
13
13
|
this.counter = 0;
|
|
14
14
|
this.idToWorker = {};
|
package/src/node/TestWorker.js
CHANGED
|
@@ -10,7 +10,7 @@ const utilName = new URL('../test.js', import.meta.url),
|
|
|
10
10
|
baseName = pathToFileURL(process.cwd() + sep);
|
|
11
11
|
|
|
12
12
|
export default class TestWorker extends EventServer {
|
|
13
|
-
constructor(reporter, numberOfTasks = navigator
|
|
13
|
+
constructor(reporter, numberOfTasks = globalThis.navigator?.hardwareConcurrency || 1, options) {
|
|
14
14
|
super(reporter, numberOfTasks, options);
|
|
15
15
|
this.counter = 0;
|
|
16
16
|
this.idToWorker = {};
|
package/src/utils/box.js
CHANGED
|
@@ -12,7 +12,8 @@ export const stringRep = (n, str = ' ') => {
|
|
|
12
12
|
return buffer;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
export const findEscSequence =
|
|
15
|
+
export const findEscSequence =
|
|
16
|
+
/\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|[\x20-\x2F]*[\x30-\x7E])/g;
|
|
16
17
|
export const getLength = str => String(str).replace(findEscSequence, '').length;
|
|
17
18
|
|
|
18
19
|
export const normalizeBox = (strings, symbol = ' ', align = 'right') => {
|
package/src/utils/config.js
CHANGED
|
@@ -48,10 +48,10 @@ export const resolveTests = async (rootFolder, type, traceFn) => {
|
|
|
48
48
|
// determine test patterns
|
|
49
49
|
let patterns = [];
|
|
50
50
|
if (cfg[type]) {
|
|
51
|
-
if (Array.isArray(cfg[type]
|
|
52
|
-
patterns = patterns.concat(cfg[type]
|
|
53
|
-
} else if (typeof cfg[type]
|
|
54
|
-
patterns.push(cfg[type]
|
|
51
|
+
if (Array.isArray(cfg[type])) {
|
|
52
|
+
patterns = patterns.concat(cfg[type]);
|
|
53
|
+
} else if (typeof cfg[type] == 'string') {
|
|
54
|
+
patterns.push(cfg[type]);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
package/src/utils/fileSets.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// file sets are represented as sorted name lists with no duplicated items
|
|
2
2
|
|
|
3
|
-
export const normalize = fileSet =>
|
|
3
|
+
export const normalize = fileSet =>
|
|
4
|
+
fileSet.sort().filter((name, i, list) => !i || list[i - 1] !== name);
|
|
4
5
|
|
|
5
6
|
export const union = (a, b) => {
|
|
6
7
|
if (!a.length) return b.slice(0);
|
package/src/utils/formatters.js
CHANGED
|
@@ -24,7 +24,21 @@ export const formatTime = ms => {
|
|
|
24
24
|
if (ms < SEC) return formatNumber(ms, 1) + 'ms';
|
|
25
25
|
if (ms < 10000) return formatNumber(ms / SEC, 3) + 's';
|
|
26
26
|
if (ms < MIN) return formatNumber(ms / SEC, 2) + 's';
|
|
27
|
-
if (ms < HOUR)
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
if (ms < HOUR)
|
|
28
|
+
return (
|
|
29
|
+
formatNumber(Math.floor(ms / MIN), 0) +
|
|
30
|
+
'm' +
|
|
31
|
+
omit(formatNumber(Math.floor((ms % MIN) / SEC), 0), 's')
|
|
32
|
+
);
|
|
33
|
+
if (ms < DAY)
|
|
34
|
+
return (
|
|
35
|
+
formatNumber(Math.floor(ms / HOUR), 0) +
|
|
36
|
+
'h' +
|
|
37
|
+
omit(formatNumber(Math.floor((ms % HOUR) / MIN), 0), 'm')
|
|
38
|
+
);
|
|
39
|
+
return (
|
|
40
|
+
formatNumber(Math.floor(ms / DAY), 0) +
|
|
41
|
+
'd' +
|
|
42
|
+
omit(formatNumber(Math.floor((ms % DAY) / HOUR), 0), 'h')
|
|
43
|
+
);
|
|
30
44
|
};
|
|
@@ -135,13 +135,18 @@ const yamlFormatter = (object, options) => {
|
|
|
135
135
|
options = {...defaultOptions, ...options};
|
|
136
136
|
const lines = [],
|
|
137
137
|
string = options.string || ' ',
|
|
138
|
-
offset =
|
|
138
|
+
offset =
|
|
139
|
+
!isNaN(options.offset) && options.offset > 0
|
|
140
|
+
? repeatString(options.offset, string)
|
|
141
|
+
: typeof options.offset == 'string'
|
|
142
|
+
? options.offset
|
|
143
|
+
: '',
|
|
139
144
|
levelOffset =
|
|
140
145
|
!isNaN(options.levelOffset) && options.levelOffset > 0
|
|
141
146
|
? repeatString(options.levelOffset, string)
|
|
142
147
|
: typeof options.levelOffset == 'string'
|
|
143
|
-
|
|
144
|
-
|
|
148
|
+
? options.levelOffset
|
|
149
|
+
: '',
|
|
145
150
|
opts = {levelOffset, maxDepth: options.maxDepth};
|
|
146
151
|
format(object, opts, 0, offset, lines);
|
|
147
152
|
return lines;
|
package/web-app/donut.js
CHANGED
|
@@ -80,7 +80,10 @@ export const makeSegment = (args, options) => {
|
|
|
80
80
|
data.x4 = (innerRadius * Math.cos(start) + cx).toFixed(precision);
|
|
81
81
|
data.y4 = (innerRadius * Math.sin(start) + cy).toFixed(precision);
|
|
82
82
|
// a segment
|
|
83
|
-
path = tmpl(
|
|
83
|
+
path = tmpl(
|
|
84
|
+
'M${x1} ${y1}A${r} ${r} 0 ${lg} 1 ${x2} ${y2}L${x3} ${y3}A${r0} ${r0} 0 ${lg} 0 ${x4} ${y4}L${x1} ${y1}z',
|
|
85
|
+
data
|
|
86
|
+
);
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
89
|
node.setAttribute('d', path);
|
|
@@ -186,7 +189,10 @@ export const processPieRun = (data, options) => {
|
|
|
186
189
|
});
|
|
187
190
|
newTotal = sizes.reduce((acc, size) => acc + size.angle, 0);
|
|
188
191
|
const excess = newTotal - total,
|
|
189
|
-
totalForLargeAngles = sizes.reduce(
|
|
192
|
+
totalForLargeAngles = sizes.reduce(
|
|
193
|
+
(acc, size) => (size.angle <= minAngle ? acc : acc + size.angle),
|
|
194
|
+
0
|
|
195
|
+
);
|
|
190
196
|
changeRatio = (totalForLargeAngles - excess) / totalForLargeAngles;
|
|
191
197
|
sizes.forEach(size => {
|
|
192
198
|
if (size.angle > minAngle) {
|
package/web-app/index.html
CHANGED
package/web-app/tape6-donut.css
CHANGED
|
@@ -7,7 +7,9 @@ tape6-donut path {
|
|
|
7
7
|
transform-origin: 0 0;
|
|
8
8
|
transform: matrix(1, 0, 0, 1, 0, 0);
|
|
9
9
|
opacity: 1;
|
|
10
|
-
transition:
|
|
10
|
+
transition:
|
|
11
|
+
transform 0.2s linear,
|
|
12
|
+
opacity 0.2s linear;
|
|
11
13
|
|
|
12
14
|
stroke-width: 1px; /*3px;*/
|
|
13
15
|
stroke: #888;
|
package/web-app/tape6-donut.js
CHANGED
|
@@ -10,7 +10,7 @@ class Tape6Donut extends HTMLElement {
|
|
|
10
10
|
this.appendChild(this.svg);
|
|
11
11
|
}
|
|
12
12
|
clear() {
|
|
13
|
-
while(this.svg.lastChild) this.svg.removeChild(this.svg.lastChild);
|
|
13
|
+
while (this.svg.lastChild) this.svg.removeChild(this.svg.lastChild);
|
|
14
14
|
return this;
|
|
15
15
|
}
|
|
16
16
|
show(data, options, add) {
|
package/web-app/tape6-hflip.js
CHANGED
|
@@ -5,7 +5,7 @@ class Tape6HFlip extends HTMLElement {
|
|
|
5
5
|
this.inTransition = false;
|
|
6
6
|
this.flipper = document.createElement('div');
|
|
7
7
|
this.flipper.className = 'flipper';
|
|
8
|
-
while(this.firstChild) {
|
|
8
|
+
while (this.firstChild) {
|
|
9
9
|
this.flipper.appendChild(this.firstChild);
|
|
10
10
|
}
|
|
11
11
|
this.addEventListener('transitionend', this);
|