qunitx 1.2.19 → 1.3.1
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 +388 -198
- package/dist/.build-hash +1 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/browser/index.d.ts +33 -0
- package/dist/browser/index.js +10 -3
- package/dist/deno/index.d.ts +97 -3
- package/dist/deno/index.js +10 -1
- package/dist/node/index.d.ts +4 -0
- package/dist/node/index.js +15 -4
- package/package.json +1 -1
- package/shims/deno/index.ts +105 -4
package/dist/node/index.js
CHANGED
|
@@ -22,15 +22,26 @@ Object.freeze(Assert);
|
|
|
22
22
|
Object.freeze(ModuleContext);
|
|
23
23
|
Object.freeze(TestContext);
|
|
24
24
|
import { default as default2 } from "./module.js";
|
|
25
|
-
const skip = Test.skip;
|
|
26
25
|
import { default as default3 } from "./test.js";
|
|
26
|
+
import { default as default4 } from "./module.js";
|
|
27
|
+
const skip = Test.skip;
|
|
28
|
+
import { default as default5 } from "./test.js";
|
|
27
29
|
const todo = Test.todo;
|
|
28
|
-
var node_default = {
|
|
30
|
+
var node_default = {
|
|
31
|
+
AssertionError: Assert.AssertionError,
|
|
32
|
+
describe: Module,
|
|
33
|
+
it: Test,
|
|
34
|
+
module: Module,
|
|
35
|
+
test: Test,
|
|
36
|
+
config: {}
|
|
37
|
+
};
|
|
29
38
|
export {
|
|
30
39
|
Assert,
|
|
31
40
|
node_default as default,
|
|
32
|
-
default2 as
|
|
41
|
+
default2 as describe,
|
|
42
|
+
default3 as it,
|
|
43
|
+
default4 as module,
|
|
33
44
|
skip,
|
|
34
|
-
|
|
45
|
+
default5 as test,
|
|
35
46
|
todo
|
|
36
47
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qunitx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.1",
|
|
5
5
|
"description": "Universal test library — run the same test file in Node.js, Deno, and the browser with QUnit's battle-tested assertion API",
|
|
6
6
|
"author": "Izel Nakri",
|
|
7
7
|
"license": "MIT",
|
package/shims/deno/index.ts
CHANGED
|
@@ -6,13 +6,16 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```js
|
|
9
|
+
* // math_test.js
|
|
9
10
|
* import { module, test } from "qunitx";
|
|
10
11
|
*
|
|
11
12
|
* module("Math", (hooks) => {
|
|
12
|
-
* hooks.
|
|
13
|
+
* hooks.beforeEach(function () {
|
|
14
|
+
* this.numbers = [1, 2, 3];
|
|
15
|
+
* });
|
|
13
16
|
*
|
|
14
|
-
* test("addition", (assert)
|
|
15
|
-
* assert.equal(
|
|
17
|
+
* test("addition", function (assert) {
|
|
18
|
+
* assert.equal(this.numbers.reduce((sum, n) => sum + n, 0), 6);
|
|
16
19
|
* });
|
|
17
20
|
*
|
|
18
21
|
* test("async", async (assert) => {
|
|
@@ -22,6 +25,52 @@
|
|
|
22
25
|
* });
|
|
23
26
|
* ```
|
|
24
27
|
*
|
|
28
|
+
* Both runtimes install it under the same name, so that one file runs on either.
|
|
29
|
+
* In a Deno project:
|
|
30
|
+
*
|
|
31
|
+
* ```sh
|
|
32
|
+
* deno add qunitx
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* In a Node project:
|
|
36
|
+
*
|
|
37
|
+
* ```sh
|
|
38
|
+
* npm install --save-dev qunitx
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* Then run it with whichever runner you have:
|
|
42
|
+
*
|
|
43
|
+
* ```sh
|
|
44
|
+
* deno test math_test.js
|
|
45
|
+
* node --test math_test.js
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```js
|
|
50
|
+
* // The same test written with the BDD aliases — describe and it are the same
|
|
51
|
+
* // function objects as module and test, so everything above applies unchanged.
|
|
52
|
+
* import { describe, it } from "qunitx";
|
|
53
|
+
*
|
|
54
|
+
* describe("Math", (hooks) => {
|
|
55
|
+
* hooks.beforeEach(function () {
|
|
56
|
+
* this.numbers = [1, 2, 3];
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* it("addition", function (assert) {
|
|
60
|
+
* assert.equal(this.numbers.reduce((sum, n) => sum + n, 0), 6);
|
|
61
|
+
* });
|
|
62
|
+
*
|
|
63
|
+
* it("async", async (assert) => {
|
|
64
|
+
* const n = await Promise.resolve(42);
|
|
65
|
+
* assert.strictEqual(n, 42);
|
|
66
|
+
* });
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* `describe.skip`, `it.skip`, `it.todo`, runtime options, and nesting all behave
|
|
71
|
+
* identically to their `module` / `test` counterparts, and the commands above are
|
|
72
|
+
* unchanged.
|
|
73
|
+
*
|
|
25
74
|
* @module
|
|
26
75
|
*/
|
|
27
76
|
import '../../vendor/qunit.js';
|
|
@@ -123,6 +172,49 @@ export { Assert };
|
|
|
123
172
|
*/
|
|
124
173
|
export { default as module } from './module.ts';
|
|
125
174
|
|
|
175
|
+
/**
|
|
176
|
+
* BDD-style alias for {@linkcode module}. The same function object, so
|
|
177
|
+
* `describe.skip` and `describe.todo` behave exactly like `module.skip` and
|
|
178
|
+
* `module.todo`.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```js
|
|
182
|
+
* import { describe, it } from "qunitx";
|
|
183
|
+
*
|
|
184
|
+
* describe("Math", (hooks) => {
|
|
185
|
+
* hooks.beforeEach((assert) => {
|
|
186
|
+
* assert.step("setup");
|
|
187
|
+
* });
|
|
188
|
+
*
|
|
189
|
+
* it("adds", (assert) => {
|
|
190
|
+
* assert.equal(1 + 1, 2);
|
|
191
|
+
* });
|
|
192
|
+
* });
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
export { default as describe } from './module.ts';
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* BDD-style alias for {@linkcode test}. The same function object, so `it.skip`
|
|
199
|
+
* and `it.todo` behave exactly like `test.skip` and `test.todo`.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```js
|
|
203
|
+
* import { describe, it } from "qunitx";
|
|
204
|
+
*
|
|
205
|
+
* describe("Math", () => {
|
|
206
|
+
* it("adds", (assert) => {
|
|
207
|
+
* assert.equal(1 + 1, 2);
|
|
208
|
+
* });
|
|
209
|
+
*
|
|
210
|
+
* it.skip("divides", (assert) => {
|
|
211
|
+
* assert.equal(4 / 2, 2);
|
|
212
|
+
* });
|
|
213
|
+
* });
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
export { default as it } from './test.ts';
|
|
217
|
+
|
|
126
218
|
/**
|
|
127
219
|
* Registers a skipped test. Equivalent to `test.skip`. The test body is never
|
|
128
220
|
* executed and the test is reported as ignored by Deno's runner.
|
|
@@ -213,12 +305,21 @@ export const todo: (testName: string, _testContent?: unknown) => void = Test.tod
|
|
|
213
305
|
* @property {Function} test - Defines an individual test inside a `module()` callback.
|
|
214
306
|
* Receives an {@linkcode Assert} instance as its first argument.
|
|
215
307
|
* See the named {@linkcode test} export for full parameter documentation.
|
|
308
|
+
* @property {Function} describe - BDD-style alias for `module`. Same function object.
|
|
309
|
+
* @property {Function} it - BDD-style alias for `test`. Same function object.
|
|
216
310
|
* @property {typeof AssertionError} AssertionError - The error class thrown when an
|
|
217
311
|
* assertion fails. Extends Deno's built-in `AssertionError`.
|
|
218
312
|
* @property {object} config - Runtime configuration object (currently unused; reserved
|
|
219
313
|
* for future QUnit config compatibility).
|
|
220
314
|
*/
|
|
221
|
-
export default {
|
|
315
|
+
export default {
|
|
316
|
+
AssertionError: Assert.AssertionError,
|
|
317
|
+
describe: Module,
|
|
318
|
+
it: Test,
|
|
319
|
+
module: Module,
|
|
320
|
+
test: Test,
|
|
321
|
+
config: {},
|
|
322
|
+
};
|
|
222
323
|
|
|
223
324
|
/** Public types referenced by the signatures above, so consumers can name them. */
|
|
224
325
|
export type { HookFn, HooksObject, PushResultInfo, TestFn } from '../types.ts';
|