@effectionx/bdd 0.3.1 → 0.4.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/bdd.test.ts +12 -0
- package/bdd.ts +124 -0
- package/dist/bdd.d.ts +41 -0
- package/dist/bdd.d.ts.map +1 -0
- package/dist/bdd.js +77 -0
- package/dist/mod.d.ts +2 -0
- package/dist/mod.d.ts.map +1 -0
- package/dist/mod.js +3 -0
- package/dist/mod.node.d.ts +10 -0
- package/dist/mod.node.d.ts.map +1 -0
- package/dist/mod.node.js +8 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/mod.deno.ts +128 -0
- package/mod.node.ts +10 -0
- package/mod.ts +3 -0
- package/package.json +20 -18
- package/tsconfig.json +14 -0
- package/esm/_dnt.shims.d.ts +0 -2
- package/esm/_dnt.shims.d.ts.map +0 -1
- package/esm/_dnt.shims.js +0 -57
- package/esm/bdd/mod.d.ts +0 -26
- package/esm/bdd/mod.d.ts.map +0 -1
- package/esm/bdd/mod.js +0 -78
- package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.d.ts +0 -26
- package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.16/assertion_error.js +0 -30
- package/esm/deps/jsr.io/@std/internal/1.0.12/assertion_state.d.ts +0 -150
- package/esm/deps/jsr.io/@std/internal/1.0.12/assertion_state.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.12/assertion_state.js +0 -237
- package/esm/deps/jsr.io/@std/testing/1.0.16/_test_suite.d.ts +0 -78
- package/esm/deps/jsr.io/@std/testing/1.0.16/_test_suite.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/testing/1.0.16/_test_suite.js +0 -385
- package/esm/deps/jsr.io/@std/testing/1.0.16/bdd.d.ts +0 -336
- package/esm/deps/jsr.io/@std/testing/1.0.16/bdd.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/testing/1.0.16/bdd.js +0 -1057
- package/esm/package.json +0 -3
- package/esm/test-adapter/box.d.ts +0 -4
- package/esm/test-adapter/box.d.ts.map +0 -1
- package/esm/test-adapter/box.js +0 -15
- package/esm/test-adapter/mod.d.ts +0 -77
- package/esm/test-adapter/mod.d.ts.map +0 -1
- package/esm/test-adapter/mod.js +0 -89
- package/script/_dnt.shims.d.ts +0 -2
- package/script/_dnt.shims.d.ts.map +0 -1
- package/script/_dnt.shims.js +0 -60
- package/script/bdd/mod.d.ts +0 -26
- package/script/bdd/mod.d.ts.map +0 -1
- package/script/bdd/mod.js +0 -84
- package/script/deps/jsr.io/@std/assert/1.0.16/assertion_error.d.ts +0 -26
- package/script/deps/jsr.io/@std/assert/1.0.16/assertion_error.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/assert/1.0.16/assertion_error.js +0 -34
- package/script/deps/jsr.io/@std/internal/1.0.12/assertion_state.d.ts +0 -150
- package/script/deps/jsr.io/@std/internal/1.0.12/assertion_state.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.12/assertion_state.js +0 -275
- package/script/deps/jsr.io/@std/testing/1.0.16/_test_suite.d.ts +0 -78
- package/script/deps/jsr.io/@std/testing/1.0.16/_test_suite.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/testing/1.0.16/_test_suite.js +0 -389
- package/script/deps/jsr.io/@std/testing/1.0.16/bdd.d.ts +0 -336
- package/script/deps/jsr.io/@std/testing/1.0.16/bdd.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/testing/1.0.16/bdd.js +0 -1068
- package/script/package.json +0 -3
- package/script/test-adapter/box.d.ts +0 -4
- package/script/test-adapter/box.d.ts.map +0 -1
- package/script/test-adapter/box.js +0 -19
- package/script/test-adapter/mod.d.ts +0 -77
- package/script/test-adapter/mod.d.ts.map +0 -1
- package/script/test-adapter/mod.js +0 -92
package/script/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"box.d.ts","sourceRoot":"","sources":["../../src/test-adapter/box.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,SAAS,EAAE,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAEjE,wBAAiB,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAMzE;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAK7C"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.box = box;
|
|
4
|
-
exports.unbox = unbox;
|
|
5
|
-
const effection_1 = require("effection");
|
|
6
|
-
function* box(content) {
|
|
7
|
-
try {
|
|
8
|
-
return (0, effection_1.Ok)(yield* content());
|
|
9
|
-
}
|
|
10
|
-
catch (error) {
|
|
11
|
-
return (0, effection_1.Err)(error);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function unbox(result) {
|
|
15
|
-
if (result.ok) {
|
|
16
|
-
return result.value;
|
|
17
|
-
}
|
|
18
|
-
throw result.error;
|
|
19
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { Future, Operation, Result, Scope } from "effection";
|
|
2
|
-
export interface TestOperation {
|
|
3
|
-
(): Operation<void>;
|
|
4
|
-
}
|
|
5
|
-
export interface TestAdapter {
|
|
6
|
-
/**
|
|
7
|
-
* The parent of this adapter. All of the setup from this adapter will be
|
|
8
|
-
* run in addition to the setup of this adapter during `runTest()`
|
|
9
|
-
*/
|
|
10
|
-
readonly parent?: TestAdapter;
|
|
11
|
-
/**
|
|
12
|
-
* The name of this adapter which is mostly useful for debugging purposes
|
|
13
|
-
*/
|
|
14
|
-
readonly name: string;
|
|
15
|
-
/**
|
|
16
|
-
* A qualified name that contains not only the name of this adapter, but of all its
|
|
17
|
-
* ancestors. E.g. `All Tests > File System > write`
|
|
18
|
-
*/
|
|
19
|
-
readonly fullname: string;
|
|
20
|
-
/**
|
|
21
|
-
* A list of this test adapter and every adapter that it descends from.
|
|
22
|
-
*/
|
|
23
|
-
readonly lineage: Array<TestAdapter>;
|
|
24
|
-
/**
|
|
25
|
-
* The setup operations that will be run by this test adapter. It only includes those
|
|
26
|
-
* setups that are associated with this adapter, not those of its ancestors.
|
|
27
|
-
*/
|
|
28
|
-
readonly setup: {
|
|
29
|
-
all: TestOperation[];
|
|
30
|
-
each: TestOperation[];
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Add a setup operation to every test that is part of this adapter. In BDD integrations,
|
|
34
|
-
* this is usually called by `beforEach()`
|
|
35
|
-
*/
|
|
36
|
-
addSetup(op: TestOperation): void;
|
|
37
|
-
/**
|
|
38
|
-
* Add a setup operation that will run exactly once before any tests that are run in this
|
|
39
|
-
* adapter. In BDD integrations, this is usually called by beforeAll()
|
|
40
|
-
*/
|
|
41
|
-
addOnetimeSetup(op: TestOperation): void;
|
|
42
|
-
/**
|
|
43
|
-
* Actually run a test. This evaluates all setup operations, and then after those have completed
|
|
44
|
-
* it runs the body of the test itself.
|
|
45
|
-
*/
|
|
46
|
-
runTest(body: TestOperation): Future<Result<void>>;
|
|
47
|
-
/**
|
|
48
|
-
* Teardown this test adapter and all of the task and resources that are running inside it.
|
|
49
|
-
* This basically destroys the Effection `Scope` associated with this adapter.
|
|
50
|
-
*/
|
|
51
|
-
destroy(): Future<void>;
|
|
52
|
-
/**
|
|
53
|
-
* Used internally to prepare adapters to run test
|
|
54
|
-
*
|
|
55
|
-
* @ignore
|
|
56
|
-
*/
|
|
57
|
-
["@@init@@"](): Operation<Result<Scope>>;
|
|
58
|
-
}
|
|
59
|
-
export interface TestAdapterOptions {
|
|
60
|
-
/**
|
|
61
|
-
* The name of this test adapter which is handy for debugging.
|
|
62
|
-
* Usually, you'll give this the same name as the current test
|
|
63
|
-
* context. For example, when integrating with BDD, this would be
|
|
64
|
-
* the same as
|
|
65
|
-
*/
|
|
66
|
-
name?: string;
|
|
67
|
-
/**
|
|
68
|
-
* The parent test adapter. All of the setup from this adapter will be
|
|
69
|
-
* run in addition to the setup of this adapter during `runTest()`
|
|
70
|
-
*/
|
|
71
|
-
parent?: TestAdapter;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Create a new test adapter with the given options.
|
|
75
|
-
*/
|
|
76
|
-
export declare function createTestAdapter(options?: TestAdapterOptions): TestAdapter;
|
|
77
|
-
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/test-adapter/mod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,SAAS,EACT,MAAM,EACN,KAAK,EAEN,MAAM,WAAW,CAAC;AAWnB,MAAM,WAAW,aAAa;IAC5B,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAErC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE;QAAE,GAAG,EAAE,aAAa,EAAE,CAAC;QAAC,IAAI,EAAE,aAAa,EAAE,CAAA;KAAE,CAAC;IAEhE;;;OAGG;IACH,QAAQ,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI,CAAC;IAElC;;;OAGG;IACH,eAAe,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI,CAAC;IAEzC;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAEnD;;;OAGG;IACH,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;IAExB;;;;OAIG;IACH,CAAC,UAAU,CAAC,IAAI,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AASD;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,kBAAuB,GAC/B,WAAW,CA4Fb"}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createTestAdapter = createTestAdapter;
|
|
4
|
-
const effection_1 = require("effection");
|
|
5
|
-
const box_js_1 = require("./box.js");
|
|
6
|
-
const anonymousNames = (function* () {
|
|
7
|
-
let count = 1;
|
|
8
|
-
while (true) {
|
|
9
|
-
yield `anonymous test adapter ${count++}`;
|
|
10
|
-
}
|
|
11
|
-
})();
|
|
12
|
-
/**
|
|
13
|
-
* Create a new test adapter with the given options.
|
|
14
|
-
*/
|
|
15
|
-
function createTestAdapter(options = {}) {
|
|
16
|
-
const setup = {
|
|
17
|
-
all: [],
|
|
18
|
-
each: [],
|
|
19
|
-
};
|
|
20
|
-
const { parent, name = anonymousNames.next().value } = options;
|
|
21
|
-
let scope = undefined;
|
|
22
|
-
let destroy = function* () { };
|
|
23
|
-
const adapter = {
|
|
24
|
-
parent,
|
|
25
|
-
name,
|
|
26
|
-
setup,
|
|
27
|
-
get lineage() {
|
|
28
|
-
const lineage = [adapter];
|
|
29
|
-
for (let current = parent; current; current = current.parent) {
|
|
30
|
-
lineage.unshift(current);
|
|
31
|
-
}
|
|
32
|
-
return lineage;
|
|
33
|
-
},
|
|
34
|
-
get fullname() {
|
|
35
|
-
return adapter.lineage.map((adapter) => adapter.name).join(" > ");
|
|
36
|
-
},
|
|
37
|
-
addSetup(op) {
|
|
38
|
-
setup.each.push(op);
|
|
39
|
-
},
|
|
40
|
-
addOnetimeSetup(op) {
|
|
41
|
-
setup.all.push(op);
|
|
42
|
-
},
|
|
43
|
-
runTest(op) {
|
|
44
|
-
return (0, effection_1.run)(function* () {
|
|
45
|
-
let init = yield* adapter["@@init@@"]();
|
|
46
|
-
if (!init.ok) {
|
|
47
|
-
return init;
|
|
48
|
-
}
|
|
49
|
-
let scope = init.value;
|
|
50
|
-
const setups = adapter.lineage.reduce((all, adapter) => all.concat(adapter.setup.each), []);
|
|
51
|
-
let test = yield* scope.spawn(() => (0, box_js_1.box)(function* () {
|
|
52
|
-
for (let fn of setups) {
|
|
53
|
-
yield* fn();
|
|
54
|
-
}
|
|
55
|
-
yield* op();
|
|
56
|
-
}));
|
|
57
|
-
return yield* test;
|
|
58
|
-
});
|
|
59
|
-
},
|
|
60
|
-
*["@@init@@"]() {
|
|
61
|
-
if (scope) {
|
|
62
|
-
return yield* scope.operation;
|
|
63
|
-
}
|
|
64
|
-
scope = (0, effection_1.withResolvers)();
|
|
65
|
-
let parent = adapter.parent
|
|
66
|
-
? yield* adapter.parent["@@init@@"]()
|
|
67
|
-
: (0, effection_1.Ok)((0, effection_1.createScope)()[0]);
|
|
68
|
-
if (!parent.ok) {
|
|
69
|
-
scope.resolve(parent);
|
|
70
|
-
return yield* scope.operation;
|
|
71
|
-
}
|
|
72
|
-
let task = yield* parent.value.spawn(function* () {
|
|
73
|
-
let init = yield* (0, box_js_1.box)(function* () {
|
|
74
|
-
for (let initializer of adapter.setup.all) {
|
|
75
|
-
yield* initializer();
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
if (!init.ok) {
|
|
79
|
-
scope.resolve(init);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
scope.resolve((0, effection_1.Ok)(yield* (0, effection_1.useScope)()));
|
|
83
|
-
yield* (0, effection_1.suspend)();
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
destroy = task.halt;
|
|
87
|
-
return yield* scope.operation;
|
|
88
|
-
},
|
|
89
|
-
destroy: () => (0, effection_1.run)(destroy),
|
|
90
|
-
};
|
|
91
|
-
return adapter;
|
|
92
|
-
}
|