@effectionx/test-adapter 0.2.0 → 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/esm/mod.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Future, Operation, Scope } from "effection";
1
+ import type { Future, Operation, Result, Scope } from "effection";
2
2
  export interface TestOperation {
3
3
  (): Operation<void>;
4
4
  }
@@ -40,7 +40,7 @@ export interface TestAdapter {
40
40
  * Actually run a test. This evaluates all setup operations, and then after those have completed
41
41
  * it runs the body of the test itself.
42
42
  */
43
- runTest(body: TestOperation): Future<void>;
43
+ runTest(body: TestOperation): Future<Result<void>>;
44
44
  /**
45
45
  * Teardown this test adapter and all of the task and resources that are running inside it.
46
46
  * This basically destroys the Effection `Scope` associated with this adapter.
package/esm/mod.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAG1D,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;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAErC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC;IAEjC;;;OAGG;IACH,QAAQ,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI,CAAC;IAElC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zB;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,CA6Cb"}
package/esm/mod.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createScope } from "effection";
1
+ import { createScope, Err, Ok } from "effection";
2
2
  const anonymousNames = (function* () {
3
3
  let count = 1;
4
4
  while (true) {
@@ -9,16 +9,16 @@ const anonymousNames = (function* () {
9
9
  * Create a new test adapter with the given options.
10
10
  */
11
11
  export function createTestAdapter(options = {}) {
12
- let setups = [];
13
- let { parent, name = anonymousNames.next().value } = options;
14
- let [scope, destroy] = createScope(parent?.scope);
15
- let adapter = {
12
+ const setups = [];
13
+ const { parent, name = anonymousNames.next().value } = options;
14
+ const [scope, destroy] = createScope(parent?.scope);
15
+ const adapter = {
16
16
  parent,
17
17
  name,
18
18
  scope,
19
19
  setups,
20
20
  get lineage() {
21
- let lineage = [adapter];
21
+ const lineage = [adapter];
22
22
  for (let current = parent; current; current = current.parent) {
23
23
  lineage.unshift(current);
24
24
  }
@@ -32,11 +32,17 @@ export function createTestAdapter(options = {}) {
32
32
  },
33
33
  runTest(op) {
34
34
  return scope.run(function* () {
35
- let allSetups = adapter.lineage.reduce((all, adapter) => all.concat(adapter.setups), []);
36
- for (let setup of allSetups) {
37
- yield* setup();
35
+ const allSetups = adapter.lineage.reduce((all, adapter) => all.concat(adapter.setups), []);
36
+ try {
37
+ for (const setup of allSetups) {
38
+ yield* setup();
39
+ }
40
+ yield* op();
41
+ return Ok(void 0);
42
+ }
43
+ catch (error) {
44
+ return Err(error);
38
45
  }
39
- yield* op();
40
46
  });
41
47
  },
42
48
  destroy,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effectionx/test-adapter",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "author": "engineering@frontside.com",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "sideEffects": false,
26
26
  "dependencies": {
27
- "effection": "4.0.0-beta.2"
27
+ "effection": "^3"
28
28
  },
29
29
  "_generatedBy": "dnt@dev"
30
30
  }
package/script/mod.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Future, Operation, Scope } from "effection";
1
+ import type { Future, Operation, Result, Scope } from "effection";
2
2
  export interface TestOperation {
3
3
  (): Operation<void>;
4
4
  }
@@ -40,7 +40,7 @@ export interface TestAdapter {
40
40
  * Actually run a test. This evaluates all setup operations, and then after those have completed
41
41
  * it runs the body of the test itself.
42
42
  */
43
- runTest(body: TestOperation): Future<void>;
43
+ runTest(body: TestOperation): Future<Result<void>>;
44
44
  /**
45
45
  * Teardown this test adapter and all of the task and resources that are running inside it.
46
46
  * This basically destroys the Effection `Scope` associated with this adapter.
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAG1D,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;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAErC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC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AAC,CAAC;IAEnD;;;OAGG;IACH,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;CACzB;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,CA6Cb"}
package/script/mod.js CHANGED
@@ -12,16 +12,16 @@ const anonymousNames = (function* () {
12
12
  * Create a new test adapter with the given options.
13
13
  */
14
14
  function createTestAdapter(options = {}) {
15
- let setups = [];
16
- let { parent, name = anonymousNames.next().value } = options;
17
- let [scope, destroy] = (0, effection_1.createScope)(parent?.scope);
18
- let adapter = {
15
+ const setups = [];
16
+ const { parent, name = anonymousNames.next().value } = options;
17
+ const [scope, destroy] = (0, effection_1.createScope)(parent?.scope);
18
+ const adapter = {
19
19
  parent,
20
20
  name,
21
21
  scope,
22
22
  setups,
23
23
  get lineage() {
24
- let lineage = [adapter];
24
+ const lineage = [adapter];
25
25
  for (let current = parent; current; current = current.parent) {
26
26
  lineage.unshift(current);
27
27
  }
@@ -35,11 +35,17 @@ function createTestAdapter(options = {}) {
35
35
  },
36
36
  runTest(op) {
37
37
  return scope.run(function* () {
38
- let allSetups = adapter.lineage.reduce((all, adapter) => all.concat(adapter.setups), []);
39
- for (let setup of allSetups) {
40
- yield* setup();
38
+ const allSetups = adapter.lineage.reduce((all, adapter) => all.concat(adapter.setups), []);
39
+ try {
40
+ for (const setup of allSetups) {
41
+ yield* setup();
42
+ }
43
+ yield* op();
44
+ return (0, effection_1.Ok)(void 0);
45
+ }
46
+ catch (error) {
47
+ return (0, effection_1.Err)(error);
41
48
  }
42
- yield* op();
43
49
  });
44
50
  },
45
51
  destroy,