tape-six 1.0.2 → 1.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  # tape-six [![NPM version][npm-img]][npm-url]
2
2
 
3
- [npm-img]: https://img.shields.io/npm/v/tape-six.svg
4
- [npm-url]: https://npmjs.org/package/tape-six
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
- * In my opinion unit test files should be directly executable with `node`, `deno`, `bun`, browsers
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
- * 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.
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
- * 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.
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
- * `async test(name, options, testFn)` — registers a test suite to be executed asynchronously.
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
- * 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
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
- * The test function has a different signature: `testPromiseFn(tester, resolve, reject)`.
61
+ - The test function has a different signature: `testPromiseFn(tester, resolve, reject)`.
62
62
 
63
63
  The arguments mentioned above are:
64
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.
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
- * The default: no timeout.
79
- * `testFn` — the test function to be executed. It will be called with the `tester` object.
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
- * 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
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
- * 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.
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()` &mdash; an alias of `deepEqual()`.
155
+ - `deepEquals()` &mdash; an alias of `deepEqual()`.
156
+ - `isEquivalent()` &mdash; an alias of `deepEqual()`.
157
+ - `notDeepEqual(a, b, msg)` &mdash; asserts that `a` and `b` are not deeply equal.
158
+ - `notSame()` &mdash; an alias of `notDeepEqual()`.
159
+ - `notDeepEquals()` &mdash; an alias of `notDeepEqual()`.
160
+ - `notEquivalent()` &mdash; an alias of `notDeepEqual()`.
161
+ - `notDeeply()` &mdash; an alias of `notDeepEqual()`.
162
+ - `isNotDeepEqual()` &mdash; an alias of `notDeepEqual()`.
163
+ - `isNotEquivalent()` &mdash; an alias of `notDeepEqual()`.
164
+ - `deepLooseEqual(a, b, msg)` &mdash; 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)` &mdash; asserts that `a` and `b` are not deeply loosely equal.
167
+ - `throws(fn, msg)` &mdash; asserts that `fn` throws.
168
+ - `fn` is called with no arguments in the global context.
169
+ - `doesNotThrow(fn, msg)` &mdash; asserts that `fn` does not throw.
170
+ - `matchString(string, regexp, msg)` &mdash; asserts that `string` matches `regexp`.
171
+ - `doesNotMatchString(string, regexp, msg)` &mdash; asserts that `string` does not match `regexp`.
172
+ - `match(a, b, msg)` &mdash; asserts that `a` matches `b`.
173
+ - See [deep6's match()](<https://github.com/uhop/deep6/wiki/match()>) for details.
174
+ - `doesNotMatch(a, b, msg)` &mdash; asserts that `a` does not match `b`.
175
+ - `rejects(promise, msg)` &mdash; asserts that `promise` rejects.
176
+ - This is an asynchronous method. It is likely to be waited for.
177
+ - `doesNotResolve()` &mdash; an alias of `rejects()`.
178
+ - `resolves(promise, msg)` &mdash; asserts that `promise` resolves.
179
+ - This is an asynchronous method. It is likely to be waited for.
180
+ - `doesNotReject()` &mdash; an alias of `resolves()`.
181
+ - Embedded test suites (all of them are asynchronous and should be waited for):
182
+ - `test(name, options, testFn)` &mdash; runs a test suite asynchronously. See `test()` above.
183
+ - `skip(name, options, testFn)` &mdash; skips a test suite asynchronously. See `test.skip()` above.
184
+ - `todo(name, options, testFn)` &mdash; runs a provisional test suite asynchronously. See `test.todo()` above.
185
+ - `asPromise(name, options, testPromiseFn)` &mdash; runs a test suite asynchronously. See `test.asPromise()` above.
186
+ - Miscellaneous:
187
+ - `any` &mdash; 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
- * `plan(n)` &mdash; sets the number of tests in the test suite. Rarely used.
190
- * `comment(msg)` &mdash; sends a comment to the test harness. Rarely used.
191
- * `skipTest(...args, msg)` &mdash; skips the current test yet sends a message to the test harness.
192
- * `bailOut(msg)` &mdash; stops the test suite and sends a message to the test harness.
189
+ - `plan(n)` &mdash; sets the number of tests in the test suite. Rarely used.
190
+ - `comment(msg)` &mdash; sends a comment to the test harness. Rarely used.
191
+ - `skipTest(...args, msg)` &mdash; skips the current test yet sends a message to the test harness.
192
+ - `bailOut(msg)` &mdash; 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,28 +229,30 @@ 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
- * [tape6](https://github.com/uhop/tape-six/wiki/Utility-%E2%80%90-tape6) &mdash; 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) &mdash; a custom web server with a web application that helps running tests in browsers.
232
+ - [tape6](https://github.com/uhop/tape-six/wiki/Utility-%E2%80%90-tape6) &mdash; 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) &mdash; 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
- * 1.0.2 *Bugfix for Deno using the JSONL reporter.*
240
- * 1.0.1 *Technical release: added more links.*
241
- * 1.0.0 *The first official release.*
242
- * 0.12.3 *Technical release: exposed internal classes for external utilities.*
243
- * 0.12.2 *Fixed a minor serialization issue.*
244
- * 0.12.1 *Minor Deno-related refactoring, fixed the way tests are triggered.*
245
- * 0.12.0 *Removed data to avoid serializing non-serializable objects.*
246
- * 0.11.0 *Minor improvements to the server: temporary redirects, a hyperlink to the web app.*
247
- * 0.10.0 *Refactored test runners, refactored stopping tests on failure, added JSONL reporter, fixed bugs.*
248
- * 0.9.6 *Updated deps.*
249
- * 0.9.5 *Updated the lock file.*
250
- * 0.9.4 *Updated deps. Added test runners for Bun and Deno.*
251
- * 0.9.3 *Made TTY reporter work with non-TTY streams.*
252
- * 0.9.2 *Fixed Windows runner.*
253
- * 0.9.1 *More updates related to renaming `tape6` &rArr; `tape-six`.*
254
- * 0.9.0 *Initial release.*
239
+ - 1.0.4 _Bugfix for platform-specific tests, old platforms, minor updates to accommodate Deno 2, updated dev deps._
240
+ - 1.0.3 _Minor update to accommodate changes in Bun and updated dev deps._
241
+ - 1.0.2 _Bugfix for Deno using the JSONL reporter._
242
+ - 1.0.1 _Technical release: added more links._
243
+ - 1.0.0 _The first official release._
244
+ - 0.12.3 _Technical release: exposed internal classes for external utilities._
245
+ - 0.12.2 _Fixed a minor serialization issue._
246
+ - 0.12.1 _Minor Deno-related refactoring, fixed the way tests are triggered._
247
+ - 0.12.0 _Removed data to avoid serializing non-serializable objects._
248
+ - 0.11.0 _Minor improvements to the server: temporary redirects, a hyperlink to the web app._
249
+ - 0.10.0 _Refactored test runners, refactored stopping tests on failure, added JSONL reporter, fixed bugs._
250
+ - 0.9.6 _Updated deps._
251
+ - 0.9.5 _Updated the lock file._
252
+ - 0.9.4 _Updated deps. Added test runners for Bun and Deno._
253
+ - 0.9.3 _Made TTY reporter work with non-TTY streams._
254
+ - 0.9.2 _Fixed Windows runner._
255
+ - 0.9.1 _More updates related to renaming `tape6` &rArr; `tape-six`._
256
+ - 0.9.0 _Initial release._
255
257
 
256
258
  For more info consult full [release notes](https://github.com/uhop/tape-six/wiki/Release-notes).
package/bin/tape6-bun.js CHANGED
@@ -85,7 +85,7 @@ const config = () => {
85
85
  } else {
86
86
  parallel = 0;
87
87
  }
88
- if (!parallel) parallel = navigator.hardwareConcurrency;
88
+ if (!parallel) parallel = globalThis.navigator?.hardwareConcurrency || 1;
89
89
  };
90
90
 
91
91
  const init = async () => {
package/bin/tape6-deno.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env -S deno run --allow-read --allow-env --allow-hrtime --ext=js
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.hardwareConcurrency;
88
+ if (!parallel) parallel = globalThis.navigator?.hardwareConcurrency || 1;
89
89
  };
90
90
 
91
91
  const init = async () => {
package/bin/tape6-node.js CHANGED
@@ -86,7 +86,7 @@ const config = () => {
86
86
  } else {
87
87
  parallel = 0;
88
88
  }
89
- if (!parallel) parallel = navigator.hardwareConcurrency;
89
+ if (!parallel) parallel = globalThis.navigator?.hardwareConcurrency || 1;
90
90
  };
91
91
 
92
92
  const init = async () => {
@@ -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
- node: 'tape6-node.js',
9
- deno: 'tape6-deno.js',
10
- bun: 'tape6-bun.js',
11
- server: 'tape6-server.js',
12
- runner: 'tape6-runner.js',
13
- main: 'tape6.js'
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,6 +1,6 @@
1
1
  {
2
2
  "name": "tape-six",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "TAP the test harness for the modern JavaScript (ES6).",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -25,7 +25,9 @@
25
25
  "test": "node ./bin/tape6.js --flags FO",
26
26
  "test:bun": "bun run ./bin/tape6-bun.js --flags FO",
27
27
  "test:deno": "deno run -A ./bin/tape6-deno.js --flags FO",
28
- "test:chrome": "node tests/puppeteer-chrome.js"
28
+ "test:chrome": "node tests/puppeteer-chrome.js",
29
+ "lint": "prettier --check .",
30
+ "lint:fix": "prettier --write ."
29
31
  },
30
32
  "github": "http://github.com/uhop/tape-six",
31
33
  "repository": {
@@ -64,6 +66,6 @@
64
66
  }
65
67
  },
66
68
  "devDependencies": {
67
- "puppeteer": "^23.5.1"
69
+ "puppeteer": "^24.4.0"
68
70
  }
69
71
  }
package/src/Tester.js CHANGED
@@ -20,7 +20,13 @@ class Tester {
20
20
  }
21
21
 
22
22
  comment(msg) {
23
- this.state.emit({type: 'comment', name: msg || 'comment', test: this.testNumber, marker: new Error(), time: this.state.timer.now()});
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') throw new TypeError('the first argument should be a promise');
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') throw new TypeError('the first argument should be a promise');
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) => aliases.split(', ').forEach(alias => (Tester.prototype[alias] = Tester.prototype[source]));
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('notStrictEqual', 'not, notEqual, notEquals, isNotEqual, doesNotEqual, isUnequal, notStrictEquals, isNot');
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('notDeepEqual', 'notSame, notDeepEquals, notEquivalent, notDeeply, isNotDeepEqual, isNotEquivalent');
417
+ setAliases(
418
+ 'notDeepEqual',
419
+ 'notSame, notDeepEquals, notEquivalent, notDeeply, isNotDeepEqual, isNotEquivalent'
420
+ );
406
421
  setAliases('rejects', 'doesNotResolve');
407
422
  setAliases('resolves', 'doesNotReject');
408
423
 
@@ -1,11 +1,13 @@
1
+ import {sep} from 'node:path';
2
+
1
3
  import {StopTest} from '../State.js';
2
4
  import EventServer from '../utils/EventServer.js';
3
5
 
4
6
  const utilName = new URL('../test.js', import.meta.url),
5
- baseName = Bun.pathToFileURL(Bun.cwd);
7
+ baseName = Bun.pathToFileURL(Bun.cwd + sep);
6
8
 
7
9
  export default class TestWorker extends EventServer {
8
- constructor(reporter, numberOfTasks = navigator.hardwareConcurrency, options) {
10
+ constructor(reporter, numberOfTasks = globalThis.navigator?.hardwareConcurrency || 1, options) {
9
11
  super(reporter, numberOfTasks, options);
10
12
  this.counter = 0;
11
13
  this.idToWorker = {};
@@ -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.hardwareConcurrency, options) {
11
+ constructor(reporter, numberOfTasks = globalThis.navigator?.hardwareConcurrency || 1, options) {
12
12
  super(reporter, numberOfTasks, options);
13
13
  this.counter = 0;
14
14
  this.idToWorker = {};
@@ -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.hardwareConcurrency, options) {
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 = /\x1B(?:\[[\x30-\x3F]*[\x20-\x2F]*[\x40-\x7E]|[\x20-\x2F]*[\x30-\x7E])/g;
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') => {
@@ -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].tests)) {
52
- patterns = patterns.concat(cfg[type].tests);
53
- } else if (typeof cfg[type].tests == 'string') {
54
- patterns.push(cfg[type].tests);
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
 
@@ -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 => fileSet.sort().filter((name, i, list) => !i || list[i - 1] !== name);
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);
@@ -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) return formatNumber(Math.floor(ms / MIN), 0) + 'm' + omit(formatNumber(Math.floor((ms % MIN) / SEC), 0), 's');
28
- if (ms < DAY) return formatNumber(Math.floor(ms / HOUR), 0) + 'h' + omit(formatNumber(Math.floor((ms % HOUR) / MIN), 0), 'm');
29
- return formatNumber(Math.floor(ms / DAY), 0) + 'd' + omit(formatNumber(Math.floor((ms % DAY) / HOUR), 0), 'h');
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 = !isNaN(options.offset) && options.offset > 0 ? repeatString(options.offset, string) : typeof options.offset == 'string' ? options.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
- ? options.levelOffset
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('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', data);
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((acc, size) => (size.angle <= minAngle ? acc : acc + size.angle), 0);
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) {
@@ -1,4 +1,4 @@
1
- <!DOCTYPE html>
1
+ <!doctype html>
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="utf-8" />
@@ -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: transform 0.2s linear, opacity 0.2s linear;
10
+ transition:
11
+ transform 0.2s linear,
12
+ opacity 0.2s linear;
11
13
 
12
14
  stroke-width: 1px; /*3px;*/
13
15
  stroke: #888;
@@ -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) {
@@ -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);