@hg-ts/tests 0.1.49 → 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.
Files changed (112) hide show
  1. package/.eslintcache +1 -1
  2. package/.turbo/turbo-build.log +2 -0
  3. package/.turbo/turbo-lint$colon$ts.log +2 -0
  4. package/.turbo/turbo-test.log +20 -0
  5. package/dist/decorators/decorate-test.js +1 -2
  6. package/dist/decorators/decorate-test.js.map +1 -1
  7. package/dist/decorators/describe.decorator.d.ts +3 -2
  8. package/dist/decorators/describe.decorator.d.ts.map +1 -1
  9. package/dist/decorators/describe.decorator.js +3 -4
  10. package/dist/decorators/describe.decorator.js.map +1 -1
  11. package/dist/decorators/expect-error.decorator.d.ts +0 -1
  12. package/dist/decorators/expect-error.decorator.d.ts.map +1 -1
  13. package/dist/decorators/expect-error.decorator.js +1 -2
  14. package/dist/decorators/expect-error.decorator.js.map +1 -1
  15. package/dist/decorators/suite.decorator.d.ts +4 -0
  16. package/dist/decorators/suite.decorator.d.ts.map +1 -0
  17. package/dist/decorators/suite.decorator.js +10 -0
  18. package/dist/decorators/suite.decorator.js.map +1 -0
  19. package/dist/decorators/test.decorator.d.ts +2 -9
  20. package/dist/decorators/test.decorator.d.ts.map +1 -1
  21. package/dist/decorators/test.decorator.js +1 -2
  22. package/dist/decorators/test.decorator.js.map +1 -1
  23. package/dist/example.test.d.ts +9 -0
  24. package/dist/example.test.d.ts.map +1 -0
  25. package/dist/example.test.js +54 -0
  26. package/dist/example.test.js.map +1 -0
  27. package/dist/expection.d.ts +0 -3
  28. package/dist/expection.d.ts.map +1 -1
  29. package/dist/expection.js +0 -1
  30. package/dist/expection.js.map +1 -1
  31. package/dist/index.d.ts +1 -2
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +3 -4
  34. package/dist/index.js.map +1 -1
  35. package/dist/runner.d.ts +9 -0
  36. package/dist/runner.d.ts.map +1 -0
  37. package/dist/runner.js +54 -0
  38. package/dist/runner.js.map +1 -0
  39. package/dist/suite.d.ts +11 -0
  40. package/dist/suite.d.ts.map +1 -0
  41. package/dist/suite.js +12 -0
  42. package/dist/suite.js.map +1 -0
  43. package/dist/test-runner.d.ts +5 -5
  44. package/dist/test-runner.d.ts.map +1 -1
  45. package/dist/test-runner.js +18 -37
  46. package/dist/test-runner.js.map +1 -1
  47. package/dist/test-suite.d.ts +4 -3
  48. package/dist/test-suite.d.ts.map +1 -1
  49. package/dist/test-suite.js.map +1 -1
  50. package/dist/types.d.ts +10 -0
  51. package/dist/types.d.ts.map +1 -0
  52. package/dist/types.js +3 -0
  53. package/dist/types.js.map +1 -0
  54. package/eslint.config.mjs +3 -0
  55. package/package.json +23 -24
  56. package/src/decorators/decorate-test.ts +1 -1
  57. package/src/decorators/describe.decorator.ts +6 -7
  58. package/src/decorators/test.decorator.ts +7 -13
  59. package/src/example.test.ts +30 -0
  60. package/src/expection.ts +0 -6
  61. package/src/index.ts +1 -3
  62. package/src/runner.ts +84 -0
  63. package/src/suite.ts +19 -0
  64. package/src/types.ts +11 -0
  65. package/tsconfig.json +1 -1
  66. package/.eslintrc.json +0 -1
  67. package/bin/test-dev.mjs +0 -4
  68. package/bin/test.mjs +0 -1
  69. package/config/base.cjs +0 -30
  70. package/config/common.cjs +0 -6
  71. package/config/esm.cjs +0 -14
  72. package/config/index.cjs +0 -1
  73. package/dist-esm/decorators/decorate-test.d.ts +0 -4
  74. package/dist-esm/decorators/decorate-test.d.ts.map +0 -1
  75. package/dist-esm/decorators/decorate-test.js +0 -15
  76. package/dist-esm/decorators/decorate-test.js.map +0 -1
  77. package/dist-esm/decorators/describe.decorator.d.ts +0 -3
  78. package/dist-esm/decorators/describe.decorator.d.ts.map +0 -1
  79. package/dist-esm/decorators/describe.decorator.js +0 -7
  80. package/dist-esm/decorators/describe.decorator.js.map +0 -1
  81. package/dist-esm/decorators/expect-error.decorator.d.ts +0 -3
  82. package/dist-esm/decorators/expect-error.decorator.d.ts.map +0 -1
  83. package/dist-esm/decorators/expect-error.decorator.js +0 -18
  84. package/dist-esm/decorators/expect-error.decorator.js.map +0 -1
  85. package/dist-esm/decorators/index.d.ts +0 -4
  86. package/dist-esm/decorators/index.d.ts.map +0 -1
  87. package/dist-esm/decorators/index.js +0 -4
  88. package/dist-esm/decorators/index.js.map +0 -1
  89. package/dist-esm/decorators/test.decorator.d.ts +0 -10
  90. package/dist-esm/decorators/test.decorator.d.ts.map +0 -1
  91. package/dist-esm/decorators/test.decorator.js +0 -8
  92. package/dist-esm/decorators/test.decorator.js.map +0 -1
  93. package/dist-esm/expection.d.ts +0 -6
  94. package/dist-esm/expection.d.ts.map +0 -1
  95. package/dist-esm/expection.js +0 -4
  96. package/dist-esm/expection.js.map +0 -1
  97. package/dist-esm/index.d.ts +0 -5
  98. package/dist-esm/index.d.ts.map +0 -1
  99. package/dist-esm/index.js +0 -5
  100. package/dist-esm/index.js.map +0 -1
  101. package/dist-esm/test-runner.d.ts +0 -16
  102. package/dist-esm/test-runner.d.ts.map +0 -1
  103. package/dist-esm/test-runner.js +0 -69
  104. package/dist-esm/test-runner.js.map +0 -1
  105. package/dist-esm/test-suite.d.ts +0 -10
  106. package/dist-esm/test-suite.d.ts.map +0 -1
  107. package/dist-esm/test-suite.js +0 -8
  108. package/dist-esm/test-suite.js.map +0 -1
  109. package/eslint.junit.xml +0 -31
  110. package/src/test-runner.ts +0 -117
  111. package/src/test-suite.ts +0 -17
  112. package/tsconfig.esm.json +0 -9
@@ -1,16 +0,0 @@
1
- import type { TestSuiteConstructor } from './test-suite';
2
- export type TestRunnerOptions = {
3
- name?: string;
4
- only?: boolean;
5
- skip?: boolean;
6
- };
7
- export type TestMethod = (...args: unknown[]) => Promise<void>;
8
- export declare class TestRunner {
9
- static run(suiteConstructor: TestSuiteConstructor, options?: TestRunnerOptions): void;
10
- private static getDescribeFunction;
11
- private static describe;
12
- private static registerTests;
13
- private static getTestMethod;
14
- private static getTestRegisterMethod;
15
- }
16
- //# sourceMappingURL=test-runner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-runner.d.ts","sourceRoot":"","sources":["../src/test-runner.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAa,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpE,MAAM,MAAM,iBAAiB,GAAG;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAI/D,qBAAa,UAAU;WACR,GAAG,CAChB,gBAAgB,EAAE,oBAAoB,EACtC,OAAO,GAAE,iBAAsB,GAC7B,IAAI;IAUP,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAiBlC,OAAO,CAAC,MAAM,CAAC,QAAQ;IAqBvB,OAAO,CAAC,MAAM,CAAC,aAAa;IAe5B,OAAO,CAAC,MAAM,CAAC,aAAa;IAa5B,OAAO,CAAC,MAAM,CAAC,qBAAqB;CAWpC"}
@@ -1,69 +0,0 @@
1
- import { expect } from './expection';
2
- export class TestRunner {
3
- static run(suiteConstructor, options = {}) {
4
- const suite = new suiteConstructor();
5
- suite.testsMap = suiteConstructor.prototype.testsMap;
6
- const { name = suite.constructor.name } = options;
7
- const describeFunction = this.getDescribeFunction(options);
8
- describeFunction(name, this.describe.bind(this, suite));
9
- }
10
- static getDescribeFunction(options = {}) {
11
- const { only = false, skip = false, } = options;
12
- let describeFunction = describe;
13
- if (only) {
14
- describeFunction = describe.only;
15
- }
16
- else if (skip) {
17
- describeFunction = describe.skip;
18
- }
19
- return describeFunction;
20
- }
21
- static describe(suite) {
22
- before(async () => suite.setUp());
23
- after(async () => suite.tearDown());
24
- beforeEach(async () => suite.beforeEach());
25
- afterEach(async () => {
26
- expect.setState({
27
- assertionCalls: 0,
28
- expectedAssertionsNumber: null,
29
- isExpectingAssertions: false,
30
- });
31
- await suite.afterEach();
32
- });
33
- if (!suite.testsMap) {
34
- suite.testsMap = new Map();
35
- }
36
- suite.testsMap.forEach((options, methodName) => this.registerTests(suite, options, methodName));
37
- }
38
- static registerTests(suite, options, testName) {
39
- const { name = testName.toString() } = options;
40
- if (options.todo) {
41
- it.skip(`TODO: ${name}`);
42
- return;
43
- }
44
- const method = this.getTestMethod(suite, testName);
45
- const registerMethod = this.getTestRegisterMethod(options);
46
- registerMethod(name, method);
47
- }
48
- static getTestMethod(suite, methodName) {
49
- const testMethod = suite[methodName].bind(suite);
50
- return async (...args) => {
51
- await testMethod(...args);
52
- const { expectedAssertionsNumber, assertionCalls } = expect.getState();
53
- if (typeof expectedAssertionsNumber === 'number') {
54
- expect(assertionCalls).toBe(expectedAssertionsNumber);
55
- }
56
- };
57
- }
58
- static getTestRegisterMethod(options) {
59
- let registerMethod = it;
60
- if (options.skip) {
61
- registerMethod = it.skip;
62
- }
63
- else if (options.only) {
64
- registerMethod = it.only;
65
- }
66
- return registerMethod;
67
- }
68
- }
69
- //# sourceMappingURL=test-runner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-runner.js","sourceRoot":"","sources":["../src/test-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAyBrC,MAAM,OAAO,UAAU;IACf,MAAM,CAAC,GAAG,CAChB,gBAAsC,EACtC,UAA6B,EAAE;QAE/B,MAAM,KAAK,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACrC,KAAK,CAAC,QAAQ,GAAG,gBAAgB,CAAC,SAAS,CAAC,QAAQ,CAAC;QACrD,MAAM,EAAE,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,OAAO,CAAC;QAElD,MAAM,gBAAgB,GAAG,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAE3D,gBAAgB,CAAC,IAAI,EAAE,IAAI,CA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
- import type { MethodName, Options } from './decorators';
2
- export type TestSuiteConstructor = new () => TestSuite;
3
- export declare abstract class TestSuite {
4
- testsMap: Map<MethodName, Options> | null;
5
- setUp(): Promise<void>;
6
- tearDown(): Promise<void>;
7
- beforeEach(): Promise<void>;
8
- afterEach(): Promise<void>;
9
- }
10
- //# sourceMappingURL=test-suite.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-suite.d.ts","sourceRoot":"","sources":["../src/test-suite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,UAAU,EACV,OAAO,EACP,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,oBAAoB,GAAG,UAAU,SAAS,CAAC;AACvD,8BAAsB,SAAS;IACvB,QAAQ,EAAE,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAEpC,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"}
@@ -1,8 +0,0 @@
1
- export class TestSuite {
2
- testsMap;
3
- async setUp() { }
4
- async tearDown() { }
5
- async beforeEach() { }
6
- async afterEach() { }
7
- }
8
- //# sourceMappingURL=test-suite.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-suite.js","sourceRoot":"","sources":["../src/test-suite.ts"],"names":[],"mappings":"AAMA,MAAM,OAAgB,SAAS;IACvB,QAAQ,CAAkC;IAE1C,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"}
package/eslint.junit.xml DELETED
@@ -1,31 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <testsuites>
3
- <testsuite package="org.eslint" time="0" tests="1" errors="0" name="/Volumes/Work/ts/hg/framework/packages/tests/src/decorators/decorate-test.ts">
4
- <testcase time="0" name="/Volumes/Work/ts/hg/framework/packages/tests/src/decorators/decorate-test.ts" classname="/Volumes/Work/ts/hg/framework/packages/tests/src/decorators/decorate-test" />
5
- </testsuite>
6
- <testsuite package="org.eslint" time="0" tests="1" errors="0" name="/Volumes/Work/ts/hg/framework/packages/tests/src/decorators/describe.decorator.ts">
7
- <testcase time="0" name="/Volumes/Work/ts/hg/framework/packages/tests/src/decorators/describe.decorator.ts" classname="/Volumes/Work/ts/hg/framework/packages/tests/src/decorators/describe.decorator" />
8
- </testsuite>
9
- <testsuite package="org.eslint" time="0" tests="1" errors="0" name="/Volumes/Work/ts/hg/framework/packages/tests/src/decorators/expect-error.decorator.ts">
10
- <testcase time="0" name="/Volumes/Work/ts/hg/framework/packages/tests/src/decorators/expect-error.decorator.ts" classname="/Volumes/Work/ts/hg/framework/packages/tests/src/decorators/expect-error.decorator" />
11
- </testsuite>
12
- <testsuite package="org.eslint" time="0" tests="1" errors="0" name="/Volumes/Work/ts/hg/framework/packages/tests/src/decorators/index.ts">
13
- <testcase time="0" name="/Volumes/Work/ts/hg/framework/packages/tests/src/decorators/index.ts" classname="/Volumes/Work/ts/hg/framework/packages/tests/src/decorators/index" />
14
- </testsuite>
15
- <testsuite package="org.eslint" time="0" tests="1" errors="0" name="/Volumes/Work/ts/hg/framework/packages/tests/src/decorators/test.decorator.ts">
16
- <testcase time="0" name="/Volumes/Work/ts/hg/framework/packages/tests/src/decorators/test.decorator.ts" classname="/Volumes/Work/ts/hg/framework/packages/tests/src/decorators/test.decorator" />
17
- </testsuite>
18
- <testsuite package="org.eslint" time="0" tests="1" errors="0" name="/Volumes/Work/ts/hg/framework/packages/tests/src/expection.ts">
19
- <testcase time="0" name="/Volumes/Work/ts/hg/framework/packages/tests/src/expection.ts" classname="/Volumes/Work/ts/hg/framework/packages/tests/src/expection" />
20
- </testsuite>
21
- <testsuite package="org.eslint" time="0" tests="1" errors="0" name="/Volumes/Work/ts/hg/framework/packages/tests/src/index.ts">
22
- <testcase time="0" name="/Volumes/Work/ts/hg/framework/packages/tests/src/index.ts" classname="/Volumes/Work/ts/hg/framework/packages/tests/src/index" />
23
- </testsuite>
24
- <testsuite package="org.eslint" time="0" tests="1" errors="0" name="/Volumes/Work/ts/hg/framework/packages/tests/src/test-runner.ts">
25
- <testcase time="0" name="/Volumes/Work/ts/hg/framework/packages/tests/src/test-runner.ts" classname="/Volumes/Work/ts/hg/framework/packages/tests/src/test-runner" />
26
- </testsuite>
27
- <testsuite package="org.eslint" time="0" tests="1" errors="0" name="/Volumes/Work/ts/hg/framework/packages/tests/src/test-suite.ts">
28
- <testcase time="0" name="/Volumes/Work/ts/hg/framework/packages/tests/src/test-suite.ts" classname="/Volumes/Work/ts/hg/framework/packages/tests/src/test-suite" />
29
- </testsuite>
30
- </testsuites>
31
-
@@ -1,117 +0,0 @@
1
- import { expect } from './expection';
2
- import type {
3
- ExclusiveSuiteFunction,
4
- ExclusiveTestFunction,
5
- PendingSuiteFunction,
6
- PendingTestFunction,
7
- SuiteFunction,
8
- TestFunction,
9
- } from 'mocha';
10
- import type {
11
- MethodName,
12
- Options,
13
- } from './decorators';
14
- import type { TestSuite, TestSuiteConstructor } from './test-suite';
15
-
16
- export type TestRunnerOptions = {
17
- name?: string;
18
- only?: boolean;
19
- skip?: boolean;
20
- };
21
-
22
- export type TestMethod = (...args: unknown[]) => Promise<void>;
23
- type Describe = ExclusiveSuiteFunction | PendingSuiteFunction | SuiteFunction;
24
- type ItFunction = ExclusiveTestFunction | PendingTestFunction | TestFunction;
25
-
26
- export class TestRunner {
27
- public static run(
28
- suiteConstructor: TestSuiteConstructor,
29
- options: TestRunnerOptions = {},
30
- ): void {
31
- const suite = new suiteConstructor();
32
- suite.testsMap = suiteConstructor.prototype.testsMap;
33
- const { name = suite.constructor.name } = options;
34
-
35
- const describeFunction = this.getDescribeFunction(options);
36
-
37
- describeFunction(name, this.describe.bind(this, suite));
38
- }
39
-
40
- private static getDescribeFunction(options: TestRunnerOptions = {}): Describe {
41
- const {
42
- only = false,
43
- skip = false,
44
- } = options;
45
-
46
- let describeFunction: Describe = describe;
47
-
48
- if (only) {
49
- describeFunction = describe.only;
50
- } else if (skip) {
51
- describeFunction = describe.skip;
52
- }
53
-
54
- return describeFunction;
55
- }
56
-
57
- private static describe(suite: TestSuite): void {
58
- before(async() => suite.setUp());
59
- after(async() => suite.tearDown());
60
-
61
- beforeEach(async() => suite.beforeEach());
62
- afterEach(async() => {
63
- expect.setState({
64
- assertionCalls: 0,
65
- expectedAssertionsNumber: null,
66
- isExpectingAssertions: false,
67
- });
68
- await suite.afterEach();
69
- });
70
-
71
- if (!suite.testsMap) {
72
- suite.testsMap = new Map();
73
- }
74
-
75
- suite.testsMap.forEach((options, methodName) => this.registerTests(suite, options, methodName));
76
- }
77
-
78
- private static registerTests(suite: TestSuite, options: Options, testName: MethodName): void {
79
- const { name = testName.toString() } = options;
80
-
81
- if (options.todo) {
82
- it.skip(`TODO: ${name}`);
83
- return;
84
- }
85
-
86
- const method = this.getTestMethod(suite, testName);
87
-
88
- const registerMethod = this.getTestRegisterMethod(options);
89
-
90
- registerMethod(name, method);
91
- }
92
-
93
- private static getTestMethod(suite: TestSuite, methodName: MethodName): TestMethod {
94
- const testMethod = ((suite as any)[methodName] as (...args: unknown[]) => Promise<void>).bind(suite);
95
-
96
- return async(...args: any[]): Promise<void> => {
97
- await testMethod(...args);
98
- const { expectedAssertionsNumber, assertionCalls } = expect.getState();
99
-
100
- if (typeof expectedAssertionsNumber === 'number') {
101
- expect(assertionCalls).toBe(expectedAssertionsNumber);
102
- }
103
- };
104
- }
105
-
106
- private static getTestRegisterMethod(options: Options): ItFunction {
107
- let registerMethod: ItFunction = it;
108
-
109
- if (options.skip) {
110
- registerMethod = it.skip;
111
- } else if (options.only) {
112
- registerMethod = it.only;
113
- }
114
-
115
- return registerMethod;
116
- }
117
- }
package/src/test-suite.ts DELETED
@@ -1,17 +0,0 @@
1
- import type {
2
- MethodName,
3
- Options,
4
- } from './decorators';
5
-
6
- export type TestSuiteConstructor = new () => TestSuite;
7
- export abstract class TestSuite {
8
- public testsMap: Map<MethodName, Options> | null;
9
-
10
- public async setUp(): Promise<void> {}
11
-
12
- public async tearDown(): Promise<void> {}
13
-
14
- public async beforeEach(): Promise<void> {}
15
-
16
- public async afterEach(): Promise<void> {}
17
- }
package/tsconfig.esm.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "@hg-ts-config/typescript/esm",
3
- "compilerOptions": {
4
- "baseUrl": "src",
5
- "rootDir": "src",
6
- "outDir": "dist-esm"
7
- },
8
- "exclude": ["dist-esm", "dist"]
9
- }