vitest-gwt 4.0.0 → 4.0.1-beta.3
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 +30 -50
- package/lib/index.cjs +27 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.cts +13 -0
- package/lib/index.d.mts +13 -0
- package/lib/index.mjs +21 -0
- package/lib/index.mjs.map +1 -0
- package/package.json +76 -46
- package/src/index.ts +10 -5
- package/src/withAspect.ts +11 -13
- package/lib/index.d.ts +0 -5
- package/lib/index.js +0 -11
- package/lib/index.js.map +0 -1
- package/lib/withAspect.d.ts +0 -4
- package/lib/withAspect.js +0 -16
- package/lib/withAspect.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# vitest-gwt
|
|
2
|
+
|
|
2
3
|
A small library to help Vitest support given-when-then style testing without a
|
|
3
4
|
bunch of overhead
|
|
4
5
|
|
|
@@ -10,32 +11,32 @@ vitest@2.x.x, use vitest-gwt@2.x.x
|
|
|
10
11
|
## Usage
|
|
11
12
|
|
|
12
13
|
1. Install the package
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
```bash
|
|
15
|
+
npm i --save-dev vitest-gwt
|
|
16
|
+
```
|
|
16
17
|
2. In your test files, import `test`
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
```js
|
|
19
|
+
import test from "vitest-gwt";
|
|
20
|
+
```
|
|
20
21
|
3. Write a test!
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
22
|
+
```js
|
|
23
|
+
describe("test context", () => {
|
|
24
|
+
test("has no expected errors", {
|
|
25
|
+
given: {
|
|
26
|
+
mock_vitest_test_function,
|
|
27
|
+
GOOD_test_case,
|
|
28
|
+
},
|
|
29
|
+
when: {
|
|
30
|
+
executing_test_case,
|
|
31
|
+
},
|
|
32
|
+
then: {
|
|
33
|
+
all_GIVENS_called,
|
|
34
|
+
all_WHENS_called,
|
|
35
|
+
all_THENS_called,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
```
|
|
39
40
|
|
|
40
41
|
## [Scenario Test](https://github.com/devzeebo/gwt-runner/blob/main/README.md#scenario-definition)
|
|
41
42
|
|
|
@@ -81,29 +82,6 @@ In these cases, you can use the scenario definition style which allows chaining
|
|
|
81
82
|
}
|
|
82
83
|
```
|
|
83
84
|
|
|
84
|
-
## Disabling a test
|
|
85
|
-
Sometimes you want a test to be disabled in code. Vitest offers this functionality with
|
|
86
|
-
the `xtest` method, and we've duplicated this logic, but with strong typing so you can
|
|
87
|
-
disable your gwt style tests.
|
|
88
|
-
|
|
89
|
-
```js
|
|
90
|
-
import test, { xtest } from 'vitest-gwt';
|
|
91
|
-
|
|
92
|
-
describe('test context', () => {
|
|
93
|
-
test('this test will run', {
|
|
94
|
-
then: {
|
|
95
|
-
CANARY,
|
|
96
|
-
},
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
xtest('this test will NOT run', {
|
|
100
|
-
when: {
|
|
101
|
-
oops_we_broke_this,
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
```
|
|
106
|
-
|
|
107
85
|
## withAspect
|
|
108
86
|
|
|
109
87
|
`withAspect` wraps up vitest's `beforeEach` and `afterEach` to allow preparing and
|
|
@@ -125,8 +103,10 @@ The `afterEach` has access to whatever values you put on the Context in the
|
|
|
125
103
|
`beforeEach`. It does NOT have access to the values put on the Context during
|
|
126
104
|
the specific test.
|
|
127
105
|
|
|
128
|
-
|
|
129
106
|
## Detailed Usage
|
|
130
107
|
|
|
131
|
-
|
|
132
|
-
|
|
108
|
+
Full guides live in [`docs/`](./docs) — writing tests, expecting errors,
|
|
109
|
+
scenarios, shared context (`withAspect`), and the API reference.
|
|
110
|
+
|
|
111
|
+
For the underlying runner internals, refer to
|
|
112
|
+
[gwt-runner](https://github.com/devzeebo/gwt-runner).
|
package/lib/index.cjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
let vitest = require("vitest");
|
|
6
|
+
let gwt_runner = require("gwt-runner");
|
|
7
|
+
//#region src/withAspect.ts
|
|
8
|
+
const withAspectBuilder = (beforeEach, afterEach) => (before, after) => {
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
gwt_runner.TestContext.createContext();
|
|
11
|
+
await before.bind(gwt_runner.TestContext.context)();
|
|
12
|
+
});
|
|
13
|
+
afterEach(async () => {
|
|
14
|
+
if (after) await after.bind(gwt_runner.TestContext.context)();
|
|
15
|
+
gwt_runner.TestContext.releaseContext();
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/index.ts
|
|
20
|
+
const test = (0, gwt_runner.gwtRunner)(vitest.test);
|
|
21
|
+
const withAspect = withAspectBuilder(vitest.beforeEach, vitest.afterEach);
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.TestContext = gwt_runner.TestContext;
|
|
24
|
+
exports.default = test;
|
|
25
|
+
exports.withAspect = withAspect;
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["TestContext","vitestBeforeEach","vitestAfterEach"],"sources":["../src/withAspect.ts","../src/index.ts"],"sourcesContent":["import type { beforeEach as vitestBeforeEach, afterEach as vitestAfterEach } from \"vitest\";\nimport { TestContext } from \"gwt-runner\";\n\ntype Callback<T> = (this: T) => any;\n\nexport type WithAspectBuilder = (\n beforeEach: typeof vitestBeforeEach,\n afterEach: typeof vitestAfterEach,\n) => <T>(before: Callback<T>, after?: Callback<T>) => void;\n\nconst withAspectBuilder: WithAspectBuilder =\n (beforeEach, afterEach) =>\n <T>(before: Callback<T>, after?: Callback<T>): void => {\n beforeEach(async () => {\n TestContext.createContext();\n\n await (before.bind(TestContext.context as T) as any)();\n });\n\n afterEach(async () => {\n if (after) {\n await (after.bind(TestContext.context as T) as any)();\n }\n\n TestContext.releaseContext();\n });\n };\n\nexport default withAspectBuilder;\n","import {\n test as vitest,\n beforeEach as vitestBeforeEach,\n afterEach as vitestAfterEach,\n} from \"vitest\";\nimport { gwtRunner, TestContext } from \"gwt-runner\";\nimport withAspectBuilder, { type WithAspectBuilder } from \"./withAspect\";\n\nconst test: ReturnType<typeof gwtRunner> = gwtRunner(vitest);\n\nexport default test;\nexport { TestContext };\n\nexport const withAspect: ReturnType<WithAspectBuilder> = withAspectBuilder(\n vitestBeforeEach,\n vitestAfterEach,\n);\n"],"mappings":";;;;;;;AAUA,MAAM,qBACH,YAAY,eACT,QAAqB,UAA8B;CACrD,WAAW,YAAY;EACrB,WAAA,YAAY,cAAc;EAE1B,MAAO,OAAO,KAAKA,WAAAA,YAAY,OAAY,CAAC,CAAS;CACvD,CAAC;CAED,UAAU,YAAY;EACpB,IAAI,OACF,MAAO,MAAM,KAAKA,WAAAA,YAAY,OAAY,CAAC,CAAS;EAGtD,WAAA,YAAY,eAAe;CAC7B,CAAC;AACH;;;AClBF,MAAM,QAAA,GAAA,WAAA,UAAA,CAA+C,OAAA,IAAM;AAK3D,MAAa,aAA4C,kBACvDC,OAAAA,YACAC,OAAAA,SACF"}
|
package/lib/index.d.cts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TestContext, gwtRunner } from "gwt-runner";
|
|
2
|
+
import { afterEach, beforeEach } from "vitest";
|
|
3
|
+
|
|
4
|
+
//#region src/withAspect.d.ts
|
|
5
|
+
type Callback<T> = (this: T) => any;
|
|
6
|
+
type WithAspectBuilder = (beforeEach: typeof beforeEach, afterEach: typeof afterEach) => <T>(before: Callback<T>, after?: Callback<T>) => void;
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/index.d.ts
|
|
9
|
+
declare const test: ReturnType<typeof gwtRunner>;
|
|
10
|
+
declare const withAspect: ReturnType<WithAspectBuilder>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { TestContext, test as default, withAspect };
|
|
13
|
+
//# sourceMappingURL=index.d.cts.map
|
package/lib/index.d.mts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { afterEach, beforeEach } from "vitest";
|
|
2
|
+
import { TestContext, gwtRunner } from "gwt-runner";
|
|
3
|
+
|
|
4
|
+
//#region src/withAspect.d.ts
|
|
5
|
+
type Callback<T> = (this: T) => any;
|
|
6
|
+
type WithAspectBuilder = (beforeEach: typeof beforeEach, afterEach: typeof afterEach) => <T>(before: Callback<T>, after?: Callback<T>) => void;
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/index.d.ts
|
|
9
|
+
declare const test: ReturnType<typeof gwtRunner>;
|
|
10
|
+
declare const withAspect: ReturnType<WithAspectBuilder>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { TestContext, test as default, withAspect };
|
|
13
|
+
//# sourceMappingURL=index.d.mts.map
|
package/lib/index.mjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { afterEach, beforeEach, test as test$1 } from "vitest";
|
|
2
|
+
import { TestContext, TestContext as TestContext$1, gwtRunner } from "gwt-runner";
|
|
3
|
+
//#region src/withAspect.ts
|
|
4
|
+
const withAspectBuilder = (beforeEach, afterEach) => (before, after) => {
|
|
5
|
+
beforeEach(async () => {
|
|
6
|
+
TestContext$1.createContext();
|
|
7
|
+
await before.bind(TestContext$1.context)();
|
|
8
|
+
});
|
|
9
|
+
afterEach(async () => {
|
|
10
|
+
if (after) await after.bind(TestContext$1.context)();
|
|
11
|
+
TestContext$1.releaseContext();
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/index.ts
|
|
16
|
+
const test = gwtRunner(test$1);
|
|
17
|
+
const withAspect = withAspectBuilder(beforeEach, afterEach);
|
|
18
|
+
//#endregion
|
|
19
|
+
export { TestContext, test as default, withAspect };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["TestContext","vitest","vitestBeforeEach","vitestAfterEach"],"sources":["../src/withAspect.ts","../src/index.ts"],"sourcesContent":["import type { beforeEach as vitestBeforeEach, afterEach as vitestAfterEach } from \"vitest\";\nimport { TestContext } from \"gwt-runner\";\n\ntype Callback<T> = (this: T) => any;\n\nexport type WithAspectBuilder = (\n beforeEach: typeof vitestBeforeEach,\n afterEach: typeof vitestAfterEach,\n) => <T>(before: Callback<T>, after?: Callback<T>) => void;\n\nconst withAspectBuilder: WithAspectBuilder =\n (beforeEach, afterEach) =>\n <T>(before: Callback<T>, after?: Callback<T>): void => {\n beforeEach(async () => {\n TestContext.createContext();\n\n await (before.bind(TestContext.context as T) as any)();\n });\n\n afterEach(async () => {\n if (after) {\n await (after.bind(TestContext.context as T) as any)();\n }\n\n TestContext.releaseContext();\n });\n };\n\nexport default withAspectBuilder;\n","import {\n test as vitest,\n beforeEach as vitestBeforeEach,\n afterEach as vitestAfterEach,\n} from \"vitest\";\nimport { gwtRunner, TestContext } from \"gwt-runner\";\nimport withAspectBuilder, { type WithAspectBuilder } from \"./withAspect\";\n\nconst test: ReturnType<typeof gwtRunner> = gwtRunner(vitest);\n\nexport default test;\nexport { TestContext };\n\nexport const withAspect: ReturnType<WithAspectBuilder> = withAspectBuilder(\n vitestBeforeEach,\n vitestAfterEach,\n);\n"],"mappings":";;;AAUA,MAAM,qBACH,YAAY,eACT,QAAqB,UAA8B;CACrD,WAAW,YAAY;EACrB,cAAY,cAAc;EAE1B,MAAO,OAAO,KAAKA,cAAY,OAAY,CAAC,CAAS;CACvD,CAAC;CAED,UAAU,YAAY;EACpB,IAAI,OACF,MAAO,MAAM,KAAKA,cAAY,OAAY,CAAC,CAAS;EAGtD,cAAY,eAAe;CAC7B,CAAC;AACH;;;AClBF,MAAM,OAAqC,UAAUC,MAAM;AAK3D,MAAa,aAA4C,kBACvDC,YACAC,SACF"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest-gwt",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1-beta.3",
|
|
4
4
|
"description": "A small library to help Vitest support given-when-then style testing without a bunch of overhead",
|
|
5
|
-
"
|
|
6
|
-
|
|
5
|
+
"keywords": [
|
|
6
|
+
"given",
|
|
7
|
+
"gwt",
|
|
8
|
+
"testing",
|
|
9
|
+
"then",
|
|
10
|
+
"unit",
|
|
11
|
+
"vitest",
|
|
12
|
+
"when"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/devzeebo/vitest-gwt#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/devzeebo/vitest-gwt/issues"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": "Eric Siebeneich",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/devzeebo/vitest-gwt.git"
|
|
23
|
+
},
|
|
7
24
|
"files": [
|
|
8
25
|
"lib",
|
|
9
26
|
"src",
|
|
10
27
|
"!**/*.spec.ts"
|
|
11
28
|
],
|
|
29
|
+
"type": "module",
|
|
30
|
+
"main": "./lib/index.cjs",
|
|
31
|
+
"module": "./lib/index.mjs",
|
|
32
|
+
"types": "./lib/index.d.cts",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./lib/index.d.mts",
|
|
37
|
+
"default": "./lib/index.mjs"
|
|
38
|
+
},
|
|
39
|
+
"require": {
|
|
40
|
+
"types": "./lib/index.d.cts",
|
|
41
|
+
"default": "./lib/index.cjs"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"./package.json": "./package.json"
|
|
45
|
+
},
|
|
12
46
|
"scripts": {
|
|
13
47
|
"build": "wireit",
|
|
14
48
|
"test": "wireit",
|
|
@@ -16,12 +50,28 @@
|
|
|
16
50
|
"test:coverage": "wireit",
|
|
17
51
|
"prepublishOnly": "wireit"
|
|
18
52
|
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"gwt-runner": "^3.0.0-esm.5"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@types/node": "^25.9.3",
|
|
58
|
+
"@vitest/coverage-v8": "^4.1.9",
|
|
59
|
+
"axios": "^1.18.0",
|
|
60
|
+
"typescript": "^6.0.3",
|
|
61
|
+
"vitest": "^4.1.9",
|
|
62
|
+
"wireit": "^0.14.12"
|
|
63
|
+
},
|
|
64
|
+
"peerDependencies": {
|
|
65
|
+
"vitest": ">=4.0.0"
|
|
66
|
+
},
|
|
67
|
+
"packageManager": "npm@11.12.1",
|
|
19
68
|
"wireit": {
|
|
20
69
|
"build": {
|
|
21
|
-
"command": "
|
|
70
|
+
"command": "vp pack",
|
|
22
71
|
"files": [
|
|
23
72
|
"src/**/*.ts",
|
|
24
|
-
"tsconfig
|
|
73
|
+
"tsconfig.json",
|
|
74
|
+
"vite.config.ts",
|
|
25
75
|
"!src/**/*.spec.ts"
|
|
26
76
|
],
|
|
27
77
|
"output": [
|
|
@@ -29,56 +79,36 @@
|
|
|
29
79
|
]
|
|
30
80
|
},
|
|
31
81
|
"lint": {
|
|
32
|
-
"command": "
|
|
82
|
+
"command": "vp lint src",
|
|
83
|
+
"files": [
|
|
84
|
+
"src/**/*.ts",
|
|
85
|
+
"tsconfig.json",
|
|
86
|
+
"vite.config.ts"
|
|
87
|
+
]
|
|
33
88
|
},
|
|
34
89
|
"test": {
|
|
35
|
-
"command": "
|
|
90
|
+
"command": "vp test run",
|
|
91
|
+
"files": [
|
|
92
|
+
"src/**/*.ts",
|
|
93
|
+
"vite.config.ts"
|
|
94
|
+
]
|
|
36
95
|
},
|
|
37
96
|
"test:coverage": {
|
|
38
|
-
"command": "
|
|
97
|
+
"command": "vp test run --coverage",
|
|
98
|
+
"files": [
|
|
99
|
+
"src/**/*.ts",
|
|
100
|
+
"vite.config.ts"
|
|
101
|
+
],
|
|
102
|
+
"output": [
|
|
103
|
+
"coverage/**"
|
|
104
|
+
]
|
|
39
105
|
},
|
|
40
106
|
"prepublishOnly": {
|
|
41
107
|
"dependencies": [
|
|
42
108
|
"lint",
|
|
43
|
-
"test
|
|
109
|
+
"test",
|
|
44
110
|
"build"
|
|
45
111
|
]
|
|
46
112
|
}
|
|
47
|
-
},
|
|
48
|
-
"repository": {
|
|
49
|
-
"type": "git",
|
|
50
|
-
"url": "git+https://github.com/devzeebo/vitest-gwt.git"
|
|
51
|
-
},
|
|
52
|
-
"peerDependencies": {
|
|
53
|
-
"vitest": ">=4.0.0"
|
|
54
|
-
},
|
|
55
|
-
"keywords": [
|
|
56
|
-
"vitest",
|
|
57
|
-
"gwt",
|
|
58
|
-
"unit",
|
|
59
|
-
"testing",
|
|
60
|
-
"given",
|
|
61
|
-
"when",
|
|
62
|
-
"then"
|
|
63
|
-
],
|
|
64
|
-
"author": "Eric Siebeneich",
|
|
65
|
-
"license": "MIT",
|
|
66
|
-
"bugs": {
|
|
67
|
-
"url": "https://github.com/devzeebo/vitest-gwt/issues"
|
|
68
|
-
},
|
|
69
|
-
"homepage": "https://github.com/devzeebo/vitest-gwt#readme",
|
|
70
|
-
"devDependencies": {
|
|
71
|
-
"@react-ddd/eslint-config": "^0.4.0",
|
|
72
|
-
"@types/lodash": "^4.17.24",
|
|
73
|
-
"@types/node": "^25.9.1",
|
|
74
|
-
"@vitest/coverage-v8": "^4.1.8",
|
|
75
|
-
"axios": "^1.17.0",
|
|
76
|
-
"lodash": "^4.18.1",
|
|
77
|
-
"typescript": "^6.0.3",
|
|
78
|
-
"vitest": ">=4.1.8",
|
|
79
|
-
"wireit": "^0.14.12"
|
|
80
|
-
},
|
|
81
|
-
"dependencies": {
|
|
82
|
-
"gwt-runner": "^2.4.0"
|
|
83
113
|
}
|
|
84
|
-
}
|
|
114
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,11 +2,16 @@ import {
|
|
|
2
2
|
test as vitest,
|
|
3
3
|
beforeEach as vitestBeforeEach,
|
|
4
4
|
afterEach as vitestAfterEach,
|
|
5
|
-
} from
|
|
6
|
-
import gwtRunner,
|
|
7
|
-
import withAspectBuilder from
|
|
5
|
+
} from "vitest";
|
|
6
|
+
import { gwtRunner, TestContext } from "gwt-runner";
|
|
7
|
+
import withAspectBuilder, { type WithAspectBuilder } from "./withAspect";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const test: ReturnType<typeof gwtRunner> = gwtRunner(vitest);
|
|
10
|
+
|
|
11
|
+
export default test;
|
|
10
12
|
export { TestContext };
|
|
11
13
|
|
|
12
|
-
export const withAspect = withAspectBuilder(
|
|
14
|
+
export const withAspect: ReturnType<WithAspectBuilder> = withAspectBuilder(
|
|
15
|
+
vitestBeforeEach,
|
|
16
|
+
vitestAfterEach,
|
|
17
|
+
);
|
package/src/withAspect.ts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
afterEach as vitestAfterEach,
|
|
4
|
-
} from 'vitest';
|
|
5
|
-
import { TestContext } from 'gwt-runner';
|
|
1
|
+
import type { beforeEach as vitestBeforeEach, afterEach as vitestAfterEach } from "vitest";
|
|
2
|
+
import { TestContext } from "gwt-runner";
|
|
6
3
|
|
|
7
4
|
type Callback<T> = (this: T) => any;
|
|
8
5
|
|
|
9
|
-
export
|
|
6
|
+
export type WithAspectBuilder = (
|
|
10
7
|
beforeEach: typeof vitestBeforeEach,
|
|
11
8
|
afterEach: typeof vitestAfterEach,
|
|
12
|
-
) => (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
) => {
|
|
9
|
+
) => <T>(before: Callback<T>, after?: Callback<T>) => void;
|
|
10
|
+
|
|
11
|
+
const withAspectBuilder: WithAspectBuilder =
|
|
12
|
+
(beforeEach, afterEach) =>
|
|
13
|
+
<T>(before: Callback<T>, after?: Callback<T>): void => {
|
|
17
14
|
beforeEach(async () => {
|
|
18
15
|
TestContext.createContext();
|
|
19
16
|
|
|
@@ -27,5 +24,6 @@ export default (
|
|
|
27
24
|
|
|
28
25
|
TestContext.releaseContext();
|
|
29
26
|
});
|
|
30
|
-
}
|
|
31
|
-
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default withAspectBuilder;
|
package/lib/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { TestContext } from 'gwt-runner';
|
|
2
|
-
declare const _default: <TContext>(name: string, gwtDefinition: import("gwt-runner").GwtDefinition<TContext>) => void;
|
|
3
|
-
export default _default;
|
|
4
|
-
export { TestContext };
|
|
5
|
-
export declare const withAspect: <T>(before: (this: T) => any, after?: (this: T) => any) => void;
|
package/lib/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withAspect = exports.TestContext = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const vitest_1 = require("vitest");
|
|
6
|
-
const gwt_runner_1 = tslib_1.__importStar(require("gwt-runner"));
|
|
7
|
-
Object.defineProperty(exports, "TestContext", { enumerable: true, get: function () { return gwt_runner_1.TestContext; } });
|
|
8
|
-
const withAspect_1 = tslib_1.__importDefault(require("./withAspect"));
|
|
9
|
-
exports.default = (0, gwt_runner_1.default)(vitest_1.test);
|
|
10
|
-
exports.withAspect = (0, withAspect_1.default)(vitest_1.beforeEach, vitest_1.afterEach);
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,mCAIgB;AAChB,iEAAoD;AAI3C,4FAJW,wBAAW,OAIX;AAHpB,sEAA6C;AAE7C,kBAAe,IAAA,oBAAS,EAAC,aAAM,CAAC,CAAC;AAGpB,QAAA,UAAU,GAAG,IAAA,oBAAiB,EAAC,mBAAgB,EAAE,kBAAe,CAAC,CAAC"}
|
package/lib/withAspect.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { beforeEach as vitestBeforeEach, afterEach as vitestAfterEach } from 'vitest';
|
|
2
|
-
type Callback<T> = (this: T) => any;
|
|
3
|
-
declare const _default: (beforeEach: typeof vitestBeforeEach, afterEach: typeof vitestAfterEach) => <T>(before: Callback<T>, after?: Callback<T>) => void;
|
|
4
|
-
export default _default;
|
package/lib/withAspect.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const gwt_runner_1 = require("gwt-runner");
|
|
4
|
-
exports.default = (beforeEach, afterEach) => ((before, after) => {
|
|
5
|
-
beforeEach(async () => {
|
|
6
|
-
gwt_runner_1.TestContext.createContext();
|
|
7
|
-
await before.bind(gwt_runner_1.TestContext.context)();
|
|
8
|
-
});
|
|
9
|
-
afterEach(async () => {
|
|
10
|
-
if (after) {
|
|
11
|
-
await after.bind(gwt_runner_1.TestContext.context)();
|
|
12
|
-
}
|
|
13
|
-
gwt_runner_1.TestContext.releaseContext();
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=withAspect.js.map
|
package/lib/withAspect.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withAspect.js","sourceRoot":"","sources":["../src/withAspect.ts"],"names":[],"mappings":";;AAIA,2CAAyC;AAIzC,kBAAe,CACb,UAAmC,EACnC,SAAiC,EACjC,EAAE,CAAC,CACH,CACE,MAAmB,EACnB,KAAmB,EACnB,EAAE;IACF,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,wBAAW,CAAC,aAAa,EAAE,CAAC;QAE5B,MAAO,MAAM,CAAC,IAAI,CAAC,wBAAW,CAAC,OAAY,CAAS,EAAE,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,IAAI,KAAK,EAAE,CAAC;YACV,MAAO,KAAK,CAAC,IAAI,CAAC,wBAAW,CAAC,OAAY,CAAS,EAAE,CAAC;QACxD,CAAC;QAED,wBAAW,CAAC,cAAc,EAAE,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CACF,CAAC"}
|