vitest-gwt 0.0.1 → 0.0.2

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/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { TestContext } from 'gwt-runner';
2
- declare const _default: <TContext>(name: string, gwtDefinition: import("gwt-runner").GwtDefinition<TContext>) => void;
1
+ import gwtRunner, { TestContext } from 'gwt-runner';
2
+ declare const _default: <TContext>(name: string, gwtDefinition: gwtRunner.GwtDefinition<TContext>) => void;
3
3
  export default _default;
4
4
  export { TestContext };
5
5
  export declare const withAspect: <T>(before: (this: T) => any, after?: (this: T) => any) => void;
package/lib/index.js CHANGED
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withAspect = exports.TestContext = void 0;
4
- var tslib_1 = require("tslib");
5
- var vitest_1 = require("vitest");
6
- var gwt_runner_1 = tslib_1.__importStar(require("gwt-runner"));
7
- Object.defineProperty(exports, "TestContext", { enumerable: true, get: function () { return gwt_runner_1.TestContext; } });
8
- var 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);
1
+ import { test as vitest, beforeEach as vitestBeforeEach, afterEach as vitestAfterEach, } from 'vitest';
2
+ import { defaultImport } from 'default-import';
3
+ import gwtRunner, { TestContext } from 'gwt-runner';
4
+ import withAspectBuilder from './withAspect.js';
5
+ export default defaultImport(gwtRunner)(vitest);
6
+ export { TestContext };
7
+ export const withAspect = withAspectBuilder(vitestBeforeEach, vitestAfterEach);
11
8
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,iCAIgB;AAChB,+DAAoD;AAI3C,4FAJW,wBAAW,OAIX;AAHpB,oEAA6C;AAE7C,kBAAe,IAAA,oBAAS,EAAC,aAAM,CAAC,CAAC;AAGpB,QAAA,UAAU,GAAG,IAAA,oBAAiB,EAAC,mBAAgB,EAAE,kBAAe,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,IAAI,MAAM,EACd,UAAU,IAAI,gBAAgB,EAC9B,SAAS,IAAI,eAAe,GAC7B,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,SAAS,EAAE,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,iBAAiB,MAAM,iBAAiB,CAAC;AAEhD,eAAe,aAAa,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC"}
package/lib/withAspect.js CHANGED
@@ -1,34 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var gwt_runner_1 = require("gwt-runner");
5
- exports.default = (function (beforeEach, afterEach) { return (function (before, after) {
6
- beforeEach(function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
7
- return tslib_1.__generator(this, function (_a) {
8
- switch (_a.label) {
9
- case 0:
10
- gwt_runner_1.TestContext.createContext();
11
- return [4 /*yield*/, before.bind(gwt_runner_1.TestContext.context)()];
12
- case 1:
13
- _a.sent();
14
- return [2 /*return*/];
15
- }
16
- });
17
- }); });
18
- afterEach(function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
19
- return tslib_1.__generator(this, function (_a) {
20
- switch (_a.label) {
21
- case 0:
22
- if (!after) return [3 /*break*/, 2];
23
- return [4 /*yield*/, after.bind(gwt_runner_1.TestContext.context)()];
24
- case 1:
25
- _a.sent();
26
- _a.label = 2;
27
- case 2:
28
- gwt_runner_1.TestContext.releaseContext();
29
- return [2 /*return*/];
30
- }
31
- });
32
- }); });
33
- }); });
1
+ import { TestContext } from 'gwt-runner';
2
+ export default (beforeEach, afterEach) => ((before, after) => {
3
+ beforeEach(async () => {
4
+ TestContext.createContext();
5
+ await before.bind(TestContext.context)();
6
+ });
7
+ afterEach(async () => {
8
+ if (after) {
9
+ await after.bind(TestContext.context)();
10
+ }
11
+ TestContext.releaseContext();
12
+ });
13
+ });
34
14
  //# sourceMappingURL=withAspect.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"withAspect.js","sourceRoot":"","sources":["../src/withAspect.ts"],"names":[],"mappings":";;;AAIA,yCAAyC;AAIzC,mBAAe,UACb,UAAmC,EACnC,SAAiC,IAC9B,OAAA,CACH,UACE,MAAmB,EACnB,KAAmB;IAEnB,UAAU,CAAC;;;;oBACT,wBAAW,CAAC,aAAa,EAAE,CAAC;oBAE5B,qBAAO,MAAM,CAAC,IAAI,CAAC,wBAAW,CAAC,OAAY,CAAS,EAAE,EAAA;;oBAAtD,SAAsD,CAAC;;;;SACxD,CAAC,CAAC;IAEH,SAAS,CAAC;;;;yBACJ,KAAK,EAAL,wBAAK;oBACP,qBAAO,KAAK,CAAC,IAAI,CAAC,wBAAW,CAAC,OAAY,CAAS,EAAE,EAAA;;oBAArD,SAAqD,CAAC;;;oBAGxD,wBAAW,CAAC,cAAc,EAAE,CAAC;;;;SAC9B,CAAC,CAAC;AACL,CAAC,CACF,EAnBI,CAmBJ,EAAC"}
1
+ {"version":3,"file":"withAspect.js","sourceRoot":"","sources":["../src/withAspect.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAIzC,eAAe,CACb,UAAmC,EACnC,SAAiC,EACjC,EAAE,CAAC,CACH,CACE,MAAmB,EACnB,KAAmB,EACnB,EAAE;IACF,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,WAAW,CAAC,aAAa,EAAE,CAAC;QAE5B,MAAO,MAAM,CAAC,IAAI,CAAC,WAAW,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,WAAW,CAAC,OAAY,CAAS,EAAE,CAAC;QACxD,CAAC;QAED,WAAW,CAAC,cAAc,EAAE,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-gwt",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "A small library to help Vitest support given-when-then style testing without a bunch of overhead",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -9,6 +9,7 @@
9
9
  "src",
10
10
  "!**/*.spec.ts"
11
11
  ],
12
+ "type": "module",
12
13
  "scripts": {
13
14
  "build": "wireit",
14
15
  "test": "wireit",
@@ -69,6 +70,8 @@
69
70
  "homepage": "https://github.com/devzeebo/vitest-gwt#readme",
70
71
  "devDependencies": {
71
72
  "@react-ddd/eslint-config": "^0.3.1",
73
+ "@tsconfig/node20": "^20.1.4",
74
+ "@tsconfig/node22": "^22.0.0",
72
75
  "@types/lodash": "^4.14.198",
73
76
  "@types/node": "^20.6.0",
74
77
  "@vitest/coverage-v8": "^2.0.5",
@@ -79,6 +82,7 @@
79
82
  "wireit": "^0.13.0"
80
83
  },
81
84
  "dependencies": {
85
+ "default-import": "^2.0.1",
82
86
  "gwt-runner": "^2.4.0"
83
87
  }
84
88
  }
package/src/index.ts CHANGED
@@ -3,10 +3,11 @@ import {
3
3
  beforeEach as vitestBeforeEach,
4
4
  afterEach as vitestAfterEach,
5
5
  } from 'vitest';
6
+ import { defaultImport } from 'default-import';
6
7
  import gwtRunner, { TestContext } from 'gwt-runner';
7
- import withAspectBuilder from './withAspect';
8
+ import withAspectBuilder from './withAspect.js';
8
9
 
9
- export default gwtRunner(vitest);
10
+ export default defaultImport(gwtRunner)(vitest);
10
11
  export { TestContext };
11
12
 
12
13
  export const withAspect = withAspectBuilder(vitestBeforeEach, vitestAfterEach);
package/src/withAspect.ts CHANGED
@@ -4,13 +4,13 @@ import type {
4
4
  } from 'vitest';
5
5
  import { TestContext } from 'gwt-runner';
6
6
 
7
- type Callback<T> = (this: T) => any;
7
+ type Callback<T,> = (this: T) => any;
8
8
 
9
9
  export default (
10
10
  beforeEach: typeof vitestBeforeEach,
11
11
  afterEach: typeof vitestAfterEach,
12
12
  ) => (
13
- <T>(
13
+ <T,>(
14
14
  before: Callback<T>,
15
15
  after?: Callback<T>,
16
16
  ) => {