@hg-ts/tests 0.1.50 → 0.1.51
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/.eslintcache +1 -1
- package/.turbo/turbo-build.log +2 -0
- package/.turbo/turbo-lint$colon$ts.log +2 -0
- package/.turbo/turbo-test.log +20 -0
- package/dist/decorators/decorate-test.js +1 -2
- package/dist/decorators/decorate-test.js.map +1 -1
- package/dist/decorators/describe.decorator.d.ts +3 -2
- package/dist/decorators/describe.decorator.d.ts.map +1 -1
- package/dist/decorators/describe.decorator.js +3 -4
- package/dist/decorators/describe.decorator.js.map +1 -1
- package/dist/decorators/expect-error.decorator.d.ts +0 -1
- package/dist/decorators/expect-error.decorator.d.ts.map +1 -1
- package/dist/decorators/expect-error.decorator.js +1 -2
- package/dist/decorators/expect-error.decorator.js.map +1 -1
- package/dist/decorators/suite.decorator.d.ts +4 -0
- package/dist/decorators/suite.decorator.d.ts.map +1 -0
- package/dist/decorators/suite.decorator.js +10 -0
- package/dist/decorators/suite.decorator.js.map +1 -0
- package/dist/decorators/test.decorator.d.ts +2 -9
- package/dist/decorators/test.decorator.d.ts.map +1 -1
- package/dist/decorators/test.decorator.js +1 -2
- package/dist/decorators/test.decorator.js.map +1 -1
- package/dist/example.test.d.ts +9 -0
- package/dist/example.test.d.ts.map +1 -0
- package/dist/example.test.js +54 -0
- package/dist/example.test.js.map +1 -0
- package/dist/expection.d.ts +0 -3
- package/dist/expection.d.ts.map +1 -1
- package/dist/expection.js +0 -1
- package/dist/expection.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/runner.d.ts +9 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +54 -0
- package/dist/runner.js.map +1 -0
- package/dist/suite.d.ts +11 -0
- package/dist/suite.d.ts.map +1 -0
- package/dist/suite.js +12 -0
- package/dist/suite.js.map +1 -0
- package/dist/test-runner.d.ts +5 -5
- package/dist/test-runner.d.ts.map +1 -1
- package/dist/test-runner.js +18 -37
- package/dist/test-runner.js.map +1 -1
- package/dist/test-suite.d.ts +4 -3
- package/dist/test-suite.d.ts.map +1 -1
- package/dist/test-suite.js.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/eslint.config.mjs +3 -0
- package/package.json +23 -24
- package/src/decorators/decorate-test.ts +1 -1
- package/src/decorators/describe.decorator.ts +6 -7
- package/src/decorators/test.decorator.ts +7 -13
- package/src/example.test.ts +30 -0
- package/src/expection.ts +0 -6
- package/src/index.ts +1 -3
- package/src/runner.ts +84 -0
- package/src/suite.ts +19 -0
- package/src/types.ts +11 -0
- package/tsconfig.json +1 -1
- package/.eslintrc.json +0 -1
- package/bin/test-dev.mjs +0 -4
- package/bin/test.mjs +0 -1
- package/config/base.cjs +0 -30
- package/config/common.cjs +0 -6
- package/config/esm.cjs +0 -14
- package/config/index.cjs +0 -1
- package/dist-esm/decorators/decorate-test.d.ts +0 -4
- package/dist-esm/decorators/decorate-test.d.ts.map +0 -1
- package/dist-esm/decorators/decorate-test.js +0 -15
- package/dist-esm/decorators/decorate-test.js.map +0 -1
- package/dist-esm/decorators/describe.decorator.d.ts +0 -3
- package/dist-esm/decorators/describe.decorator.d.ts.map +0 -1
- package/dist-esm/decorators/describe.decorator.js +0 -7
- package/dist-esm/decorators/describe.decorator.js.map +0 -1
- package/dist-esm/decorators/expect-error.decorator.d.ts +0 -3
- package/dist-esm/decorators/expect-error.decorator.d.ts.map +0 -1
- package/dist-esm/decorators/expect-error.decorator.js +0 -18
- package/dist-esm/decorators/expect-error.decorator.js.map +0 -1
- package/dist-esm/decorators/index.d.ts +0 -4
- package/dist-esm/decorators/index.d.ts.map +0 -1
- package/dist-esm/decorators/index.js +0 -4
- package/dist-esm/decorators/index.js.map +0 -1
- package/dist-esm/decorators/test.decorator.d.ts +0 -10
- package/dist-esm/decorators/test.decorator.d.ts.map +0 -1
- package/dist-esm/decorators/test.decorator.js +0 -8
- package/dist-esm/decorators/test.decorator.js.map +0 -1
- package/dist-esm/expection.d.ts +0 -6
- package/dist-esm/expection.d.ts.map +0 -1
- package/dist-esm/expection.js +0 -4
- package/dist-esm/expection.js.map +0 -1
- package/dist-esm/index.d.ts +0 -5
- package/dist-esm/index.d.ts.map +0 -1
- package/dist-esm/index.js +0 -5
- package/dist-esm/index.js.map +0 -1
- package/dist-esm/test-runner.d.ts +0 -16
- package/dist-esm/test-runner.d.ts.map +0 -1
- package/dist-esm/test-runner.js +0 -69
- package/dist-esm/test-runner.js.map +0 -1
- package/dist-esm/test-suite.d.ts +0 -10
- package/dist-esm/test-suite.d.ts.map +0 -1
- package/dist-esm/test-suite.js +0 -8
- package/dist-esm/test-suite.js.map +0 -1
- package/eslint.junit.xml +0 -31
- package/src/test-runner.ts +0 -117
- package/src/test-suite.ts +0 -17
- package/tsconfig.esm.json +0 -9
package/dist/test-runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-runner.js","sourceRoot":"","sources":["../src/test-runner.ts"],"names":[],"mappings":";;;AAAA,2CAAqC;
|
|
1
|
+
{"version":3,"file":"test-runner.js","sourceRoot":"","sources":["../src/test-runner.ts"],"names":[],"mappings":";;;AAAA,yCAQmB;AACnB,2CAAqC;AAarC,MAAa,UAAU;IACf,MAAM,CAAC,GAAG,CAChB,gBAAsC,EACtC,UAAuB,EAAE;QAGzB,IAAA,oBAAQ,EACP,OAAO,CAAC,IAAI,IAAI,gBAAgB,CAAC,IAAI,EACrC;YACC,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,KAAK;YAC3B,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,KAAK;YAC3B,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,KAAK;SAC3B,EACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAC1C,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,QAAQ,CAAC,gBAAsC,EAAE,OAAqB;QACpF,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC5C,KAAK,CAAC,QAAQ,GAAG,gBAAgB,CAAC,SAAS,CAAC,QAAQ,CAAC;QACrD,IAAA,kBAAM,EAAC,KAAK,IAAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QACjC,IAAA,iBAAK,EAAC,KAAK,IAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEnC,IAAA,sBAAU,EAAC,KAAK,IAAG,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;QAC1C,IAAA,qBAAS,EAAC,KAAK,IAAG,EAAE;YACnB,kBAAM,CAAC,QAAQ,CAAC;gBACf,cAAc,EAAE,CAAC;gBACjB,wBAAwB,EAAE,IAAI;gBAC9B,qBAAqB,EAAE,KAAK;aAC5B,CAAC,CAAC;YACH,MAAM,KAAK,CAAC,SAAS,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACrB,KAAK,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;QAC5B,CAAC;QAED,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;IACjG,CAAC;IAEO,MAAM,CAAC,aAAa,CAAC,KAAgB,EAAE,OAAoB,EAAE,QAAoB;QACxF,MAAM,EAAE,IAAI,GAAG,QAAQ,CAAC,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC;QAE/C,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAGnD,IAAA,gBAAI,EAAC,IAAI,EAAE;YACV,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,KAAK;YAC3B,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,KAAK;YAC3B,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,KAAK;SAC3B,EAAE,MAAM,CAAC,CAAC;IACZ,CAAC;IAEO,MAAM,CAAC,aAAa,CAAC,KAAgB,EAAE,UAAsB;QACpE,MAAM,UAAU,GAAK,KAAa,CAAC,UAAU,CAA2C,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAErG,OAAO,KAAK,EAAC,GAAG,IAAW,EAAiB,EAAE;YAC7C,MAAM,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;YAC1B,MAAM,EAAE,wBAAwB,EAAE,cAAc,EAAE,GAAG,kBAAM,CAAC,QAAQ,EAAE,CAAC;YAEvE,IAAI,OAAO,wBAAwB,KAAK,QAAQ,EAAE,CAAC;gBAClD,IAAA,kBAAM,EAAC,cAAc,CAAC,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;YACvD,CAAC;QACF,CAAC,CAAC;IACH,CAAC;CACD;AAjED,gCAiEC"}
|
package/dist/test-suite.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { SuiteContext } from 'node:test';
|
|
2
|
+
import type { MethodName, TestOptions } from './test-runner';
|
|
3
|
+
export type TestSuiteConstructor = new (context: SuiteContext) => TestSuite;
|
|
3
4
|
export declare abstract class TestSuite {
|
|
4
|
-
testsMap: Map<MethodName,
|
|
5
|
+
testsMap: Map<MethodName, TestOptions> | null;
|
|
5
6
|
setUp(): Promise<void>;
|
|
6
7
|
tearDown(): Promise<void>;
|
|
7
8
|
beforeEach(): Promise<void>;
|
package/dist/test-suite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-suite.d.ts","sourceRoot":"","sources":["../src/test-suite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,UAAU,EACV,
|
|
1
|
+
{"version":3,"file":"test-suite.d.ts","sourceRoot":"","sources":["../src/test-suite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EACX,UAAU,EACV,WAAW,EACX,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,oBAAoB,GAAG,KAAK,OAAO,EAAE,YAAY,KAAK,SAAS,CAAC;AAC5E,8BAAsB,SAAS;IACvB,QAAQ,EAAE,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,GAAG,IAAI,CAAC;IAExC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAEtB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAEzB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAE3B,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CACvC"}
|
package/dist/test-suite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-suite.js","sourceRoot":"","sources":["../src/test-suite.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"test-suite.js","sourceRoot":"","sources":["../src/test-suite.ts"],"names":[],"mappings":";;;AAOA,MAAsB,SAAS;IACvB,QAAQ,CAAsC;IAE9C,KAAK,CAAC,KAAK,KAAmB,CAAC;IAE/B,KAAK,CAAC,QAAQ,KAAmB,CAAC;IAElC,KAAK,CAAC,UAAU,KAAmB,CAAC;IAEpC,KAAK,CAAC,SAAS,KAAmB,CAAC;CAC1C;AAVD,8BAUC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TestContext } from 'node:test';
|
|
2
|
+
export type TestMethod = (context: TestContext) => Promise<void>;
|
|
3
|
+
export type MethodName = string | symbol;
|
|
4
|
+
export type TestOptions = {
|
|
5
|
+
name?: string;
|
|
6
|
+
only?: boolean;
|
|
7
|
+
skip?: boolean;
|
|
8
|
+
todo?: boolean;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzC,MAAM,MAAM,WAAW,GAAG;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CACf,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,36 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hg-ts/tests",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.51",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
|
-
"
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./dist/index.js"
|
|
7
|
+
},
|
|
6
8
|
"repository": "git@gitlab.com:hyper-graph/framework.git",
|
|
7
9
|
"scripts": {
|
|
8
|
-
"prepack": "yarn build && yarn lint",
|
|
9
|
-
"build": "
|
|
10
|
-
"build:dev": "
|
|
11
|
-
"
|
|
12
|
-
"lint:
|
|
10
|
+
"prepack": "yarn build && yarn lint:ts",
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"build:dev": "tsc-watch",
|
|
13
|
+
"test": "node --test",
|
|
14
|
+
"lint:ts": "lint-ts",
|
|
15
|
+
"lint:ts:fix": "lint-ts --fix"
|
|
13
16
|
},
|
|
14
17
|
"devDependencies": {
|
|
15
|
-
"@hg-ts-config/
|
|
16
|
-
"@hg-ts
|
|
17
|
-
"@hg-ts/
|
|
18
|
-
"@
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"tsc-watch": "6.0.4",
|
|
27
|
-
"tslib": "2.6.2",
|
|
28
|
-
"typescript": "5.2.2"
|
|
18
|
+
"@hg-ts-config/typescript": "0.1.51",
|
|
19
|
+
"@hg-ts/linter": "0.1.51",
|
|
20
|
+
"@hg-ts/types": "0.1.51",
|
|
21
|
+
"@types/node": "22.10.6",
|
|
22
|
+
"eslint": "9.18.0",
|
|
23
|
+
"reflect-metadata": "0.2.2",
|
|
24
|
+
"ts-node": "10.9.2",
|
|
25
|
+
"tsc-watch": "6.3.0",
|
|
26
|
+
"tslib": "2.8.1",
|
|
27
|
+
"tsx": "4.19.2",
|
|
28
|
+
"typescript": "5.7.3"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"reflect-metadata": "*"
|
|
31
|
+
"reflect-metadata": "*",
|
|
32
|
+
"tslib": "*"
|
|
34
33
|
},
|
|
35
34
|
"dependencies": {
|
|
36
35
|
"expect": "29.7.0"
|
|
@@ -8,7 +8,7 @@ export function createTestDecorator(decorator: TestDecorator): MethodDecorator {
|
|
|
8
8
|
): TypedPropertyDescriptor<(...args: unknown[]) => Promise<void>> {
|
|
9
9
|
return {
|
|
10
10
|
async value(...args: unknown[]): Promise<void> {
|
|
11
|
-
// eslint-disable-next-line @typescript
|
|
11
|
+
// eslint-disable-next-line @typescript/no-this-alias
|
|
12
12
|
const self = this;
|
|
13
13
|
const method = descriptor.value;
|
|
14
14
|
if (typeof method === 'function') {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from '../test-runner';
|
|
1
|
+
import { Runner } from '../runner';
|
|
2
|
+
import type { SuiteConstructor } from '../suite';
|
|
3
|
+
import { TestOptions } from '../types';
|
|
5
4
|
|
|
6
|
-
export function Describe(options:
|
|
7
|
-
return (target:
|
|
8
|
-
|
|
5
|
+
export function Describe<T extends SuiteConstructor>(options: TestOptions = {}): TypedClassDecorator<T> {
|
|
6
|
+
return (target: T): void => {
|
|
7
|
+
Runner.run(target, options);
|
|
9
8
|
};
|
|
10
9
|
}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
MethodName,
|
|
3
|
+
TestOptions,
|
|
4
|
+
} from '../types';
|
|
5
|
+
import type { Suite } from '../suite';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
export type MethodName = string | symbol;
|
|
5
|
-
export type Options = {
|
|
6
|
-
name?: string;
|
|
7
|
-
only?: boolean;
|
|
8
|
-
skip?: boolean;
|
|
9
|
-
todo?: boolean;
|
|
10
|
-
};
|
|
11
|
-
export type Method<Arguments extends any[] = never> = (...args: Arguments) => Promise<void> | void;
|
|
12
|
-
|
|
13
|
-
export function Test(options: Options = {}): MethodDecorator {
|
|
7
|
+
export function Test(options: TestOptions = {}): MethodDecorator {
|
|
14
8
|
return (
|
|
15
9
|
target: Object,
|
|
16
10
|
propertyKey: MethodName,
|
|
17
11
|
): void => {
|
|
18
|
-
const suite = target as
|
|
12
|
+
const suite = target as Suite;
|
|
19
13
|
|
|
20
14
|
suite.testsMap ??= new Map();
|
|
21
15
|
suite.testsMap.set(propertyKey, options);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ExpectException,
|
|
3
|
+
Describe,
|
|
4
|
+
Test,
|
|
5
|
+
} from './decorators';
|
|
6
|
+
import { expect } from './expection';
|
|
7
|
+
import { Suite } from './suite';
|
|
8
|
+
|
|
9
|
+
@Describe()
|
|
10
|
+
export class ExampleTestSuite extends Suite {
|
|
11
|
+
@Test()
|
|
12
|
+
public async success(): Promise<void> {
|
|
13
|
+
expect(true).toBeTruthy();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@ExpectException(Error)
|
|
17
|
+
@Test()
|
|
18
|
+
public async failed(): Promise<void> {
|
|
19
|
+
expect(false).toBeTruthy();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@Test({ todo: true })
|
|
23
|
+
public async todo(): Promise<void> {}
|
|
24
|
+
|
|
25
|
+
@Test({ skip: true })
|
|
26
|
+
public async skip(): Promise<void> {}
|
|
27
|
+
|
|
28
|
+
@Test({ only: true })
|
|
29
|
+
public async only(): Promise<void> {}
|
|
30
|
+
}
|
package/src/expection.ts
CHANGED
package/src/index.ts
CHANGED
package/src/runner.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
describe,
|
|
3
|
+
test,
|
|
4
|
+
before,
|
|
5
|
+
after,
|
|
6
|
+
beforeEach,
|
|
7
|
+
afterEach,
|
|
8
|
+
SuiteContext,
|
|
9
|
+
} from 'node:test';
|
|
10
|
+
import { expect } from './expection';
|
|
11
|
+
import type { Suite, SuiteConstructor } from './suite';
|
|
12
|
+
import type {
|
|
13
|
+
MethodName,
|
|
14
|
+
TestMethod,
|
|
15
|
+
TestOptions,
|
|
16
|
+
} from './types';
|
|
17
|
+
|
|
18
|
+
export class Runner {
|
|
19
|
+
public static run(
|
|
20
|
+
suiteConstructor: SuiteConstructor,
|
|
21
|
+
options: TestOptions = {},
|
|
22
|
+
): void {
|
|
23
|
+
// eslint-disable-next-line @typescript/no-floating-promises
|
|
24
|
+
describe(
|
|
25
|
+
options.name ?? suiteConstructor.name,
|
|
26
|
+
{
|
|
27
|
+
skip: options.skip ?? false,
|
|
28
|
+
todo: options.todo ?? false,
|
|
29
|
+
only: options.only ?? false,
|
|
30
|
+
},
|
|
31
|
+
this.describe.bind(this, suiteConstructor),
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private static describe(suiteConstructor: SuiteConstructor, context: SuiteContext): void {
|
|
36
|
+
const suite = new suiteConstructor(context);
|
|
37
|
+
suite.testsMap = suiteConstructor.prototype.testsMap;
|
|
38
|
+
|
|
39
|
+
before(async() => suite.setUp());
|
|
40
|
+
after(async() => suite.tearDown());
|
|
41
|
+
|
|
42
|
+
beforeEach(async() => suite.beforeEach());
|
|
43
|
+
afterEach(async() => {
|
|
44
|
+
expect.setState({
|
|
45
|
+
assertionCalls: 0,
|
|
46
|
+
expectedAssertionsNumber: null,
|
|
47
|
+
isExpectingAssertions: false,
|
|
48
|
+
});
|
|
49
|
+
await suite.afterEach();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (!suite.testsMap) {
|
|
53
|
+
suite.testsMap = new Map();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
suite.testsMap.forEach((options, methodName) => this.registerTests(suite, options, methodName));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private static registerTests(suite: Suite, options: TestOptions, testName: MethodName): void {
|
|
60
|
+
const { name = testName.toString() } = options;
|
|
61
|
+
|
|
62
|
+
const method = this.getTestMethod(suite, testName);
|
|
63
|
+
|
|
64
|
+
// eslint-disable-next-line @typescript/no-floating-promises
|
|
65
|
+
test(name, {
|
|
66
|
+
only: options.only ?? false,
|
|
67
|
+
todo: options.todo ?? false,
|
|
68
|
+
skip: options.skip ?? false,
|
|
69
|
+
}, method);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private static getTestMethod(suite: Suite, methodName: MethodName): TestMethod {
|
|
73
|
+
const testMethod = ((suite as any)[methodName] as (...args: unknown[]) => Promise<void>).bind(suite);
|
|
74
|
+
|
|
75
|
+
return async(...args: any[]): Promise<void> => {
|
|
76
|
+
await testMethod(...args);
|
|
77
|
+
const { expectedAssertionsNumber, assertionCalls } = expect.getState();
|
|
78
|
+
|
|
79
|
+
if (typeof expectedAssertionsNumber === 'number') {
|
|
80
|
+
expect(assertionCalls).toBe(expectedAssertionsNumber);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
package/src/suite.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SuiteContext } from 'node:test';
|
|
2
|
+
import type {
|
|
3
|
+
MethodName,
|
|
4
|
+
TestOptions,
|
|
5
|
+
} from './types';
|
|
6
|
+
|
|
7
|
+
export type SuiteConstructor = new (context: SuiteContext) => Suite;
|
|
8
|
+
|
|
9
|
+
export abstract class Suite {
|
|
10
|
+
public testsMap: Map<MethodName, TestOptions> | null;
|
|
11
|
+
|
|
12
|
+
public async setUp(): Promise<void> {}
|
|
13
|
+
|
|
14
|
+
public async tearDown(): Promise<void> {}
|
|
15
|
+
|
|
16
|
+
public async beforeEach(): Promise<void> {}
|
|
17
|
+
|
|
18
|
+
public async afterEach(): Promise<void> {}
|
|
19
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TestContext } from 'node:test';
|
|
2
|
+
|
|
3
|
+
export type TestMethod = (context: TestContext) => Promise<void>;
|
|
4
|
+
export type MethodName = string | symbol;
|
|
5
|
+
|
|
6
|
+
export type TestOptions = {
|
|
7
|
+
name?: string;
|
|
8
|
+
only?: boolean;
|
|
9
|
+
skip?: boolean;
|
|
10
|
+
todo?: boolean;
|
|
11
|
+
};
|
package/tsconfig.json
CHANGED
package/.eslintrc.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{ "extends": "@hg-ts-config/eslint-config" }
|
package/bin/test-dev.mjs
DELETED
package/bin/test.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import('mocha/bin/mocha.js');
|
package/config/base.cjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const { resolve } = require('path');
|
|
2
|
-
|
|
3
|
-
module.exports.baseNodeOptions = [
|
|
4
|
-
'enable-source-maps',
|
|
5
|
-
'abort-on-uncaught-exception',
|
|
6
|
-
];
|
|
7
|
-
|
|
8
|
-
const baseConfig = {
|
|
9
|
-
'async-only': true,
|
|
10
|
-
extension: [
|
|
11
|
-
'ts',
|
|
12
|
-
'tsx',
|
|
13
|
-
],
|
|
14
|
-
spec: [
|
|
15
|
-
'dist/**/*.test.js',
|
|
16
|
-
'dist/**/*.test-suite.js',
|
|
17
|
-
'dist/**/*TestSuite.js',
|
|
18
|
-
],
|
|
19
|
-
'trace-warnings': true,
|
|
20
|
-
checkLeaks: true,
|
|
21
|
-
exit: true,
|
|
22
|
-
file: [require.resolve('reflect-metadata')]
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
if (process.env.CI) {
|
|
26
|
-
baseConfig.reporter = 'mocha-junit-reporter';
|
|
27
|
-
baseConfig['reporter-options'] = `mochaFile=${resolve('mocha.junit.xml')}`;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
module.exports.baseConfig = baseConfig;
|
package/config/common.cjs
DELETED
package/config/esm.cjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const { baseNodeOptions, baseConfig } = require('./base.cjs');
|
|
2
|
-
|
|
3
|
-
const nodeOptions = [
|
|
4
|
-
...baseNodeOptions,
|
|
5
|
-
'experimental-import-meta-resolve',
|
|
6
|
-
'experimental-json-modules',
|
|
7
|
-
'experimental-specifier-resolution=node',
|
|
8
|
-
'no-warnings'
|
|
9
|
-
];
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
...baseConfig,
|
|
13
|
-
'node-option': nodeOptions.join(','),
|
|
14
|
-
};
|
package/config/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./esm');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decorate-test.d.ts","sourceRoot":"","sources":["../../src/decorators/decorate-test.ts"],"names":[],"mappings":"AAAA,KAAK,aAAa,GAAG,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEtE,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,aAAa,GAAG,eAAe,CAmB7E"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export function createTestDecorator(decorator) {
|
|
2
|
-
function result(_target, _key, descriptor) {
|
|
3
|
-
return {
|
|
4
|
-
async value(...args) {
|
|
5
|
-
const self = this;
|
|
6
|
-
const method = descriptor.value;
|
|
7
|
-
if (typeof method === 'function') {
|
|
8
|
-
await decorator(method.bind(self, ...args));
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
return result;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=decorate-test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decorate-test.js","sourceRoot":"","sources":["../../src/decorators/decorate-test.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,mBAAmB,CAAC,SAAwB;IAC3D,SAAS,MAAM,CACd,OAAgB,EAChB,IAAY,EACZ,UAA0E;QAE1E,OAAO;YACN,KAAK,CAAC,KAAK,CAAC,GAAG,IAAe;gBAE7B,MAAM,IAAI,GAAG,IAAI,CAAC;gBAClB,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC;gBAChC,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;oBACjC,MAAM,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;iBAC5C;YACF,CAAC;SACD,CAAC;IACH,CAAC;IAED,OAAO,MAAyB,CAAC;AAClC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"describe.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/describe.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,iBAAiB,EACjB,MAAM,gBAAgB,CAAC;AAExB,wBAAgB,QAAQ,CAAC,OAAO,GAAE,iBAAsB,GAAG,cAAc,CAIxE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"describe.decorator.js","sourceRoot":"","sources":["../../src/decorators/describe.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,GAEV,MAAM,gBAAgB,CAAC;AAExB,MAAM,UAAU,QAAQ,CAAC,UAA6B,EAAE;IACvD,OAAO,CAAC,MAAW,EAAQ,EAAE;QAC5B,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expect-error.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/expect-error.decorator.ts"],"names":[],"mappings":";AAGA,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,eAAe,CAazE"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { expect } from '../expection';
|
|
2
|
-
import { createTestDecorator } from './decorate-test';
|
|
3
|
-
export function ExpectException(error) {
|
|
4
|
-
return createTestDecorator(async (method) => {
|
|
5
|
-
let isThrowError = false;
|
|
6
|
-
try {
|
|
7
|
-
await method();
|
|
8
|
-
}
|
|
9
|
-
catch (err) {
|
|
10
|
-
isThrowError = true;
|
|
11
|
-
expect(err).toBeInstanceOf(error);
|
|
12
|
-
}
|
|
13
|
-
finally {
|
|
14
|
-
expect(isThrowError).toBeTruthy();
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=expect-error.decorator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expect-error.decorator.js","sourceRoot":"","sources":["../../src/decorators/expect-error.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,UAAU,eAAe,CAAC,KAAwB;IACvD,OAAO,mBAAmB,CAAC,KAAK,EAAC,MAA2B,EAAE,EAAE;QAC/D,IAAI,YAAY,GAAG,KAAK,CAAC;QAEzB,IAAI;YACH,MAAM,MAAM,EAAE,CAAC;SACf;QAAC,OAAO,GAAY,EAAE;YACtB,YAAY,GAAG,IAAI,CAAC;YACpB,MAAM,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;SAClC;gBAAS;YACT,MAAM,CAAC,YAAY,CAAC,CAAC,UAAU,EAAE,CAAC;SAClC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type MethodName = string | symbol;
|
|
2
|
-
export type Options = {
|
|
3
|
-
name?: string;
|
|
4
|
-
only?: boolean;
|
|
5
|
-
skip?: boolean;
|
|
6
|
-
todo?: boolean;
|
|
7
|
-
};
|
|
8
|
-
export type Method<Arguments extends any[] = never> = (...args: Arguments) => Promise<void> | void;
|
|
9
|
-
export declare function Test(options?: Options): MethodDecorator;
|
|
10
|
-
//# sourceMappingURL=test.decorator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/test.decorator.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AACzC,MAAM,MAAM,OAAO,GAAG;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AACF,MAAM,MAAM,MAAM,CAAC,SAAS,SAAS,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC,GAAG,IAAI,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAEnG,wBAAgB,IAAI,CAAC,OAAO,GAAE,OAAY,GAAG,eAAe,CAU3D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test.decorator.js","sourceRoot":"","sources":["../../src/decorators/test.decorator.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,IAAI,CAAC,UAAmB,EAAE;IACzC,OAAO,CACN,MAAc,EACd,WAAuB,EAChB,EAAE;QACT,MAAM,KAAK,GAAG,MAAmB,CAAC;QAElC,KAAK,CAAC,QAAQ,KAAK,IAAI,GAAG,EAAE,CAAC;QAC7B,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC,CAAC;AACH,CAAC"}
|
package/dist-esm/expection.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expection.d.ts","sourceRoot":"","sources":["../src/expection.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,QAAQ,CAAC;AAIhC,OAAO,CAAC,MAAM,CAAC;IACX,MAAM,MAAM,EAAE,OAAO,UAAU,CAAC;CACnC;AAMD,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,CAAC"}
|
package/dist-esm/expection.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expection.js","sourceRoot":"","sources":["../src/expection.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,QAAQ,CAAC;AAE/B,MAAc,CAAC,MAAM,GAAG,UAAU,CAAC;AAUpC,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,CAAC"}
|
package/dist-esm/index.d.ts
DELETED
package/dist-esm/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
package/dist-esm/index.js
DELETED
package/dist-esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|