tape-six 1.7.2 → 1.7.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 +19 -8
- package/TESTING.md +756 -0
- package/bin/tape6-bun.js +4 -3
- package/bin/tape6-node.js +4 -3
- package/bin/tape6-seq.js +4 -3
- package/index.d.ts +28 -21
- package/llms-full.txt +28 -8
- package/llms.txt +22 -7
- package/package.json +7 -4
- package/src/State.js +3 -2
- package/src/Tester.js +2 -2
- package/src/reporters/JSONLReporter.js +2 -2
- package/src/reporters/MinReporter.js +2 -13
- package/src/reporters/ProxyReporter.js +2 -2
- package/src/reporters/Reporter.js +3 -3
- package/src/reporters/TTYReporter.js +4 -4
- package/src/reporters/TapReporter.js +2 -1
- package/src/runners/bun/TestWorker.js +21 -34
- package/src/runners/deno/TestWorker.js +11 -20
- package/src/runners/deno/worker.js +1 -1
- package/src/runners/node/TestWorker.js +21 -34
- package/src/runners/seq/BypassReporter.js +4 -4
- package/src/runners/seq/TestWorker.js +18 -31
- package/src/test.js +1 -0
- package/src/utils/EventServer.js +4 -4
- package/web-app/DashReporter.js +2 -2
- package/web-app/DomReporter.js +2 -2
- package/workflows/write-tests.md +33 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
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
|
-
It is written in the modern JavaScript for the modern JavaScript and works in [Node](https://nodejs.org/), [Deno](https://deno.land/), [Bun](https://bun.sh/) and browsers.
|
|
7
|
+
It is written in the modern JavaScript for the modern JavaScript and works in [Node](https://nodejs.org/), [Deno](https://deno.land/), [Bun](https://bun.sh/) and browsers. **Zero runtime dependencies.**
|
|
8
8
|
|
|
9
9
|
It runs ES modules (`import`-based code) natively and supports CommonJS modules transparently using the built-in [ESM](https://nodejs.org/api/esm.html).
|
|
10
10
|
|
|
@@ -37,7 +37,7 @@ with existing unit test libraries:
|
|
|
37
37
|
- The [DX](https://en.wikipedia.org/wiki/User_experience#Developer_experience) in browsers are usually abysmal.
|
|
38
38
|
- Both console-based debugging and a UI to navigate results are properly supported.
|
|
39
39
|
- Integration with browser automation tools is supported for automated testing.
|
|
40
|
-
- Examples for
|
|
40
|
+
- Examples for [Playwright](https://playwright.dev/) and [Puppeteer](https://pptr.dev/) are provided.
|
|
41
41
|
|
|
42
42
|
## How it looks
|
|
43
43
|
|
|
@@ -137,6 +137,8 @@ import test from 'tape-six';
|
|
|
137
137
|
// const {default: test} = require('tape-six');
|
|
138
138
|
```
|
|
139
139
|
|
|
140
|
+
To help port tests from other frameworks, `test()` is aliased as `suite()`, `describe()` and `it()`. When called inside a test body, `test()` and its aliases automatically delegate to the current tester's `t.test()` method. The same applies to `test.skip()`, `test.todo()`, and `test.asPromise()`. Using `t.test()` directly is still preferred because it makes the delegation explicit.
|
|
141
|
+
|
|
140
142
|
This function registers a test suite. Available options:
|
|
141
143
|
|
|
142
144
|
- `async test(name, options, testFn)` — registers a test suite to be executed asynchronously.
|
|
@@ -162,11 +164,15 @@ The arguments mentioned above are:
|
|
|
162
164
|
- `name` — the optional name of the test suite. If not provided, it will be set to the name of the test function or `'(anonymous)'`.
|
|
163
165
|
- Can be overridden by the `name` argument.
|
|
164
166
|
- `timeout` — the optional timeout in milliseconds. It is used for asynchronous tests.
|
|
165
|
-
- If the timeout is exceeded, the
|
|
166
|
-
- **Important:** JavaScript does not provide a generic way to cancel asynchronous operations.
|
|
167
|
-
When the timeout is exceeded, `tape6` will stop waiting for the test to finish,
|
|
168
|
-
but it will continue running in the background.
|
|
167
|
+
- If the timeout is exceeded, `tape6` will use the tester's `signal` to indicate cancellation and stop waiting for the test to finish.
|
|
169
168
|
- The default: no timeout.
|
|
169
|
+
- Hooks:
|
|
170
|
+
- `beforeAll` — a function to be executed before all tests in the suite.
|
|
171
|
+
- `afterAll` — a function to be executed after all tests in the suite.
|
|
172
|
+
- `beforeEach` — a function to be executed before each test in the suite.
|
|
173
|
+
- `afterEach` — a function to be executed after each test in the suite.
|
|
174
|
+
- `before` — an alias for `beforeAll`.
|
|
175
|
+
- `after` — an alias for `afterAll`.
|
|
170
176
|
- `testFn` — the optional test function to be executed (see below).
|
|
171
177
|
- Can be overridden by the `testFn` argument.
|
|
172
178
|
- `testPromiseFn` — the optional callback-based test function to be executed.
|
|
@@ -307,8 +313,11 @@ The following methods are available (all `msg` arguments are optional):
|
|
|
307
313
|
- `skip(name, options, testFn)` — skips a test suite asynchronously. See `test.skip()` above.
|
|
308
314
|
- `todo(name, options, testFn)` — runs a provisional test suite asynchronously. See `test.todo()` above.
|
|
309
315
|
- `asPromise(name, options, testPromiseFn)` — runs a test suite asynchronously. See `test.asPromise()` above.
|
|
316
|
+
- Note: top-level `test()` and its aliases auto-delegate to `t.test()` when called inside a test body. Using `t.test()` directly is preferred.
|
|
317
|
+
- Properties:
|
|
318
|
+
- `signal` — an [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) that fires when the test is aborted (e.g. on timeout or bail-out). Use it to cancel pending async operations.
|
|
310
319
|
- Miscellaneous:
|
|
311
|
-
- `any` —
|
|
320
|
+
- `any` — a symbol that can be used in deep equivalency asserts to match any value.
|
|
312
321
|
See [deep6's any](https://github.com/uhop/deep6/wiki/any) for details.
|
|
313
322
|
- `_` — an alias of `any`.
|
|
314
323
|
- `plan(n)` — sets the number of tests in the test suite. Rarely used.
|
|
@@ -339,7 +348,7 @@ test('Sample test', async t => {
|
|
|
339
348
|
|
|
340
349
|
### Before/after hooks
|
|
341
350
|
|
|
342
|
-
`tape-six` supports scope-based before/after hooks: `beforeAll`, `afterAll`, `beforeEach`, `afterEach
|
|
351
|
+
`tape-six` supports scope-based before/after hooks: `beforeAll`, `afterAll`, `beforeEach`, `afterEach` (with `before`/`after` as aliases for `beforeAll`/`afterAll`), which can be used to set-up and tear-down a proper environment for tests. Like `test()` and its aliases, the top-level hook functions auto-delegate to the current tester when called inside a test body. Using `t.beforeAll()`, etc. is preferred. Read all about it in [before and after hooks](https://github.com/uhop/tape-six/wiki/Before-and-after-hooks).
|
|
343
352
|
|
|
344
353
|
### Running tests
|
|
345
354
|
|
|
@@ -411,6 +420,8 @@ Test output can be controlled by flags. See [Supported flags](https://github.com
|
|
|
411
420
|
|
|
412
421
|
The most recent releases:
|
|
413
422
|
|
|
423
|
+
- 1.7.4 _Bug fixes: uncaught exception handling, `StopTest` suppression in parallel runners._
|
|
424
|
+
- 1.7.3 _Bug fixes in reporters, runners, and assertions. Documentation corrections and improvements._
|
|
414
425
|
- 1.7.2 _Minor internal refactoring and fixes._
|
|
415
426
|
- 1.7.1 _Added AI support, added timeout to start test runners, fixed some bugs in the sequential test runner._
|
|
416
427
|
- 1.7.0 _New features: after/before hooks for tests, aliases for `suite()`, `describe()`, `it()`, `tape6-seq` — an in-process sequential test runner. Improvements: stricter monochrome detection, refactoring, bugfixes, updated dev dependencies and the documentation._
|