@hg-ts/tests 0.1.53 → 0.1.55
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/package.json +4 -4
- package/.eslintcache +0 -1
- package/.turbo/turbo-build.log +0 -2
- package/.turbo/turbo-lint$colon$ts.log +0 -2
- package/.turbo/turbo-test.log +0 -20
- package/src/decorators/decorate-test.ts +0 -22
- package/src/decorators/describe.decorator.ts +0 -9
- package/src/decorators/expect-error.decorator.ts +0 -17
- package/src/decorators/index.ts +0 -3
- package/src/decorators/test.decorator.ts +0 -17
- package/src/example.test.ts +0 -30
- package/src/expection.ts +0 -7
- package/src/index.ts +0 -4
- package/src/runner.ts +0 -84
- package/src/suite.ts +0 -19
- package/src/types.ts +0 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hg-ts/tests",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.55",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js"
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"lint:ts:fix": "lint-ts --fix"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@hg-ts-config/typescript": "0.1.
|
|
19
|
-
"@hg-ts/linter": "0.1.
|
|
20
|
-
"@hg-ts/types": "0.1.
|
|
18
|
+
"@hg-ts-config/typescript": "0.1.55",
|
|
19
|
+
"@hg-ts/linter": "0.1.55",
|
|
20
|
+
"@hg-ts/types": "0.1.55",
|
|
21
21
|
"@types/node": "22.10.6",
|
|
22
22
|
"eslint": "9.18.0",
|
|
23
23
|
"reflect-metadata": "0.2.2",
|
package/.eslintcache
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[{"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/decorators/decorate-test.js":"1","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/decorators/describe.decorator.js":"2","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/decorators/expect-error.decorator.js":"3","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/decorators/index.js":"4","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/decorators/suite.decorator.js":"5","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/decorators/test.decorator.js":"6","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/example.test.js":"7","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/expection.js":"8","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/index.js":"9","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/runner.js":"10","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/suite.js":"11","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/test-runner.js":"12","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/test-suite.js":"13","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/types.js":"14","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/eslint.config.mjs":"15","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/decorators/decorate-test.ts":"16","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/decorators/describe.decorator.ts":"17","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/decorators/expect-error.decorator.ts":"18","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/decorators/index.ts":"19","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/decorators/test.decorator.ts":"20","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/example.test.ts":"21","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/expection.ts":"22","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/index.ts":"23","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/runner.ts":"24","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/suite.ts":"25","/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/types.ts":"26"},{"size":584,"mtime":1746294715588,"results":"27","hashOfConfig":"28"},{"size":305,"mtime":1746294715597,"results":"29","hashOfConfig":"28"},{"size":690,"mtime":1746294715590,"results":"30","hashOfConfig":"28"},{"size":336,"mtime":1746294715600,"results":"31","hashOfConfig":"28"},{"size":312,"mtime":1746286930302,"results":"32","hashOfConfig":"28"},{"size":335,"mtime":1746294715598,"results":"33","hashOfConfig":"28"},{"size":2108,"mtime":1746294715603,"results":"34","hashOfConfig":"28"},{"size":269,"mtime":1746294715585,"results":"35","hashOfConfig":"28"},{"size":911,"mtime":1746294715604,"results":"36","hashOfConfig":"28"},{"size":2219,"mtime":1746294715596,"results":"37","hashOfConfig":"28"},{"size":287,"mtime":1746294715593,"results":"38","hashOfConfig":"28"},{"size":2240,"mtime":1746286930306,"results":"39","hashOfConfig":"28"},{"size":308,"mtime":1746286930307,"results":"40","hashOfConfig":"28"},{"size":110,"mtime":1746294715591,"results":"41","hashOfConfig":"28"},{"size":59,"mtime":1736896000127,"results":"42","hashOfConfig":"28"},{"size":683,"mtime":1736893466021,"results":"43","hashOfConfig":"44"},{"size":301,"mtime":1739849068953,"results":"45","hashOfConfig":"44"},{"size":448,"mtime":1736876770679,"results":"46","hashOfConfig":"44"},{"size":114,"mtime":1739849068897,"results":"47","hashOfConfig":"44"},{"size":352,"mtime":1739848974334,"results":"48","hashOfConfig":"44"},{"size":579,"mtime":1739865909461,"results":"49","hashOfConfig":"44"},{"size":123,"mtime":1739865923099,"results":"50","hashOfConfig":"44"},{"size":136,"mtime":1739849081534,"results":"51","hashOfConfig":"44"},{"size":2202,"mtime":1739848925318,"results":"52","hashOfConfig":"44"},{"size":435,"mtime":1739849355780,"results":"53","hashOfConfig":"44"},{"size":254,"mtime":1739848929342,"results":"54","hashOfConfig":"44"},{"filePath":"55","messages":"56","suppressedMessages":"57","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1gtnk1i",{"filePath":"58","messages":"59","suppressedMessages":"60","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"61","messages":"62","suppressedMessages":"63","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"64","messages":"65","suppressedMessages":"66","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"67","messages":"68","suppressedMessages":"69","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"70","messages":"71","suppressedMessages":"72","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"73","messages":"74","suppressedMessages":"75","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"76","messages":"77","suppressedMessages":"78","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"79","messages":"80","suppressedMessages":"81","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"82","messages":"83","suppressedMessages":"84","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"85","messages":"86","suppressedMessages":"87","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"88","messages":"89","suppressedMessages":"90","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"91","messages":"92","suppressedMessages":"93","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"94","messages":"95","suppressedMessages":"96","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"97","messages":"98","suppressedMessages":"99","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"100","messages":"101","suppressedMessages":"102","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"i5df87",{"filePath":"103","messages":"104","suppressedMessages":"105","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"106","messages":"107","suppressedMessages":"108","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"109","messages":"110","suppressedMessages":"111","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"112","messages":"113","suppressedMessages":"114","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"115","messages":"116","suppressedMessages":"117","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"118","messages":"119","suppressedMessages":"120","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"121","messages":"122","suppressedMessages":"123","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"124","messages":"125","suppressedMessages":"126","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"127","messages":"128","suppressedMessages":"129","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"130","messages":"131","suppressedMessages":"132","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/decorators/decorate-test.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/decorators/describe.decorator.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/decorators/expect-error.decorator.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/decorators/index.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/decorators/suite.decorator.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/decorators/test.decorator.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/example.test.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/expection.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/index.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/runner.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/suite.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/test-runner.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/test-suite.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/dist/types.js",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/eslint.config.mjs",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/decorators/decorate-test.ts",[],["133"],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/decorators/describe.decorator.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/decorators/expect-error.decorator.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/decorators/index.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/decorators/test.decorator.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/example.test.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/expection.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/index.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/runner.ts",[],["134","135"],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/suite.ts",[],[],"/Users/atsapko/WebstormProjects/personnal/framework/packages/tests/src/types.ts",[],[],{"ruleId":"136","severity":2,"message":"137","line":12,"column":11,"nodeType":"138","messageId":"139","endLine":12,"endColumn":15,"suppressions":"140"},{"ruleId":"141","severity":2,"message":"142","line":24,"column":3,"nodeType":"143","messageId":"144","endLine":32,"endColumn":5,"suggestions":"145","suppressions":"146"},{"ruleId":"141","severity":2,"message":"142","line":65,"column":3,"nodeType":"143","messageId":"144","endLine":69,"endColumn":14,"suggestions":"147","suppressions":"148"},"@typescript/no-this-alias","Unexpected aliasing of 'this' to local variable.","Identifier","thisAssignment",["149"],"@typescript/no-floating-promises","Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator.","ExpressionStatement","floatingVoid",["150","151"],["152"],["153","154"],["155"],{"kind":"156","justification":"157"},{"messageId":"158","fix":"159","desc":"160"},{"messageId":"161","fix":"162","desc":"163"},{"kind":"156","justification":"157"},{"messageId":"158","fix":"164","desc":"160"},{"messageId":"161","fix":"165","desc":"163"},{"kind":"156","justification":"157"},"directive","","floatingFixVoid",{"range":"166","text":"167"},"Add void operator to ignore.","floatingFixAwait",{"range":"168","text":"169"},"Add await operator.",{"range":"170","text":"167"},{"range":"171","text":"169"},[456,456],"void ",[456,456],"await ",[1602,1602],[1602,1602]]
|
package/.turbo/turbo-build.log
DELETED
package/.turbo/turbo-test.log
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
[32m✔ dist/decorators/decorate-test.js [90m(125.202167ms)[39m[39m
|
|
3
|
-
▶ ExampleTestSuite
|
|
4
|
-
[32m✔ success [90m(0.710875ms)[39m[39m
|
|
5
|
-
[32m✔ failed [90m(0.867042ms)[39m[39m
|
|
6
|
-
[32m✔ todo [90m(0.334625ms)[39m # TODO[39m
|
|
7
|
-
[90m﹣ skip [90m(0.082542ms)[39m # SKIP[39m
|
|
8
|
-
[32m✔ only [90m(0.161541ms)[39m[39m
|
|
9
|
-
[34m ℹ 'only' and 'runOnly' require the --test-only command-line option.[39m
|
|
10
|
-
[32m✔ ExampleTestSuite [90m(2.91725ms)[39m[39m
|
|
11
|
-
[32m✔ dist/test-runner.js [90m(197.480417ms)[39m[39m
|
|
12
|
-
[32m✔ dist/test-suite.js [90m(125.113875ms)[39m[39m
|
|
13
|
-
[34mℹ tests 8[39m
|
|
14
|
-
[34mℹ suites 1[39m
|
|
15
|
-
[34mℹ pass 6[39m
|
|
16
|
-
[34mℹ fail 0[39m
|
|
17
|
-
[34mℹ cancelled 0[39m
|
|
18
|
-
[34mℹ skipped 1[39m
|
|
19
|
-
[34mℹ todo 1[39m
|
|
20
|
-
[34mℹ duration_ms 237.942291[39m
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
type TestDecorator = (callback: () => Promise<void>) => Promise<void>;
|
|
2
|
-
|
|
3
|
-
export function createTestDecorator(decorator: TestDecorator): MethodDecorator {
|
|
4
|
-
function result(
|
|
5
|
-
_target: unknown,
|
|
6
|
-
_key: string,
|
|
7
|
-
descriptor: TypedPropertyDescriptor<(...args: unknown[]) => Promise<void>>,
|
|
8
|
-
): TypedPropertyDescriptor<(...args: unknown[]) => Promise<void>> {
|
|
9
|
-
return {
|
|
10
|
-
async value(...args: unknown[]): Promise<void> {
|
|
11
|
-
// eslint-disable-next-line @typescript/no-this-alias
|
|
12
|
-
const self = this;
|
|
13
|
-
const method = descriptor.value;
|
|
14
|
-
if (typeof method === 'function') {
|
|
15
|
-
await decorator(method.bind(self, ...args));
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return result as MethodDecorator;
|
|
22
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Runner } from '../runner';
|
|
2
|
-
import type { SuiteConstructor } from '../suite';
|
|
3
|
-
import { TestOptions } from '../types';
|
|
4
|
-
|
|
5
|
-
export function Describe<T extends SuiteConstructor>(options: TestOptions = {}): TypedClassDecorator<T> {
|
|
6
|
-
return (target: T): void => {
|
|
7
|
-
Runner.run(target, options);
|
|
8
|
-
};
|
|
9
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { expect } from '../expection';
|
|
2
|
-
import { createTestDecorator } from './decorate-test';
|
|
3
|
-
|
|
4
|
-
export function ExpectException(error: Class<any, any[]>): MethodDecorator {
|
|
5
|
-
return createTestDecorator(async(method: () => Promise<void>) => {
|
|
6
|
-
let isThrowError = false;
|
|
7
|
-
|
|
8
|
-
try {
|
|
9
|
-
await method();
|
|
10
|
-
} catch (err: unknown) {
|
|
11
|
-
isThrowError = true;
|
|
12
|
-
expect(err).toBeInstanceOf(error);
|
|
13
|
-
} finally {
|
|
14
|
-
expect(isThrowError).toBeTruthy();
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
package/src/decorators/index.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
MethodName,
|
|
3
|
-
TestOptions,
|
|
4
|
-
} from '../types';
|
|
5
|
-
import type { Suite } from '../suite';
|
|
6
|
-
|
|
7
|
-
export function Test(options: TestOptions = {}): MethodDecorator {
|
|
8
|
-
return (
|
|
9
|
-
target: Object,
|
|
10
|
-
propertyKey: MethodName,
|
|
11
|
-
): void => {
|
|
12
|
-
const suite = target as Suite;
|
|
13
|
-
|
|
14
|
-
suite.testsMap ??= new Map();
|
|
15
|
-
suite.testsMap.set(propertyKey, options);
|
|
16
|
-
};
|
|
17
|
-
}
|
package/src/example.test.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
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
DELETED
package/src/index.ts
DELETED
package/src/runner.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
};
|