xunit.ts 2.0.0 → 3.0.0
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 +25 -2
- package/cli.ts +9 -4
- package/dist/cli.js +4 -4
- package/dist/cli.js.map +1 -1
- package/dist/eslint.config.d.ts +3 -0
- package/dist/eslint.config.d.ts.map +1 -0
- package/dist/eslint.config.js +46 -0
- package/dist/eslint.config.js.map +1 -0
- package/dist/src/Assertions/Contains.d.ts +1 -1
- package/dist/src/Assertions/Contains.d.ts.map +1 -1
- package/dist/src/Assertions/Contains.js +2 -2
- package/dist/src/Assertions/Contains.js.map +1 -1
- package/dist/src/Assertions/Count.d.ts +1 -1
- package/dist/src/Assertions/Count.d.ts.map +1 -1
- package/dist/src/Assertions/Count.js +2 -2
- package/dist/src/Assertions/Count.js.map +1 -1
- package/dist/src/Assertions/Defined.d.ts +1 -1
- package/dist/src/Assertions/Defined.d.ts.map +1 -1
- package/dist/src/Assertions/Defined.js +2 -2
- package/dist/src/Assertions/Defined.js.map +1 -1
- package/dist/src/Assertions/DoesNotContain.d.ts +1 -1
- package/dist/src/Assertions/DoesNotContain.d.ts.map +1 -1
- package/dist/src/Assertions/DoesNotContain.js +2 -2
- package/dist/src/Assertions/DoesNotContain.js.map +1 -1
- package/dist/src/Assertions/DoesNotThrow.d.ts +1 -1
- package/dist/src/Assertions/DoesNotThrow.d.ts.map +1 -1
- package/dist/src/Assertions/DoesNotThrow.js +2 -2
- package/dist/src/Assertions/DoesNotThrow.js.map +1 -1
- package/dist/src/Assertions/Empty.d.ts +1 -1
- package/dist/src/Assertions/Empty.d.ts.map +1 -1
- package/dist/src/Assertions/Empty.js +2 -2
- package/dist/src/Assertions/Empty.js.map +1 -1
- package/dist/src/Assertions/Equal.d.ts +1 -1
- package/dist/src/Assertions/Equal.d.ts.map +1 -1
- package/dist/src/Assertions/Equal.js +2 -2
- package/dist/src/Assertions/Equal.js.map +1 -1
- package/dist/src/Assertions/False.d.ts +1 -1
- package/dist/src/Assertions/False.d.ts.map +1 -1
- package/dist/src/Assertions/False.js +2 -2
- package/dist/src/Assertions/False.js.map +1 -1
- package/dist/src/Assertions/InstanceOf.d.ts +1 -1
- package/dist/src/Assertions/InstanceOf.d.ts.map +1 -1
- package/dist/src/Assertions/InstanceOf.js +2 -2
- package/dist/src/Assertions/InstanceOf.js.map +1 -1
- package/dist/src/Assertions/NotEmpty.d.ts +1 -1
- package/dist/src/Assertions/NotEmpty.d.ts.map +1 -1
- package/dist/src/Assertions/NotEmpty.js +2 -2
- package/dist/src/Assertions/NotEmpty.js.map +1 -1
- package/dist/src/Assertions/NotEqual.d.ts +1 -1
- package/dist/src/Assertions/NotEqual.d.ts.map +1 -1
- package/dist/src/Assertions/NotEqual.js +2 -2
- package/dist/src/Assertions/NotEqual.js.map +1 -1
- package/dist/src/Assertions/NotNull.d.ts +1 -1
- package/dist/src/Assertions/NotNull.d.ts.map +1 -1
- package/dist/src/Assertions/NotNull.js +2 -2
- package/dist/src/Assertions/NotNull.js.map +1 -1
- package/dist/src/Assertions/Null.d.ts +1 -1
- package/dist/src/Assertions/Null.d.ts.map +1 -1
- package/dist/src/Assertions/Null.js +2 -2
- package/dist/src/Assertions/Null.js.map +1 -1
- package/dist/src/Assertions/StringContains.js +3 -3
- package/dist/src/Assertions/StringContains.js.map +1 -1
- package/dist/src/Assertions/StringDoesNotContain.js +3 -3
- package/dist/src/Assertions/StringDoesNotContain.js.map +1 -1
- package/dist/src/Assertions/StringDoesNotEndWith.d.ts.map +1 -1
- package/dist/src/Assertions/StringDoesNotEndWith.js +3 -5
- package/dist/src/Assertions/StringDoesNotEndWith.js.map +1 -1
- package/dist/src/Assertions/StringDoesNotMatch.d.ts +1 -1
- package/dist/src/Assertions/StringDoesNotMatch.d.ts.map +1 -1
- package/dist/src/Assertions/StringDoesNotMatch.js +2 -2
- package/dist/src/Assertions/StringDoesNotMatch.js.map +1 -1
- package/dist/src/Assertions/StringDoesNotStartWith.js +2 -2
- package/dist/src/Assertions/StringDoesNotStartWith.js.map +1 -1
- package/dist/src/Assertions/StringEndsWith.d.ts.map +1 -1
- package/dist/src/Assertions/StringEndsWith.js +3 -5
- package/dist/src/Assertions/StringEndsWith.js.map +1 -1
- package/dist/src/Assertions/StringMatches.d.ts +1 -1
- package/dist/src/Assertions/StringMatches.d.ts.map +1 -1
- package/dist/src/Assertions/StringMatches.js +2 -2
- package/dist/src/Assertions/StringMatches.js.map +1 -1
- package/dist/src/Assertions/StringStartsWith.js +2 -2
- package/dist/src/Assertions/StringStartsWith.js.map +1 -1
- package/dist/src/Assertions/Throws.d.ts +1 -1
- package/dist/src/Assertions/Throws.d.ts.map +1 -1
- package/dist/src/Assertions/Throws.js +3 -3
- package/dist/src/Assertions/Throws.js.map +1 -1
- package/dist/src/Assertions/True.d.ts +1 -1
- package/dist/src/Assertions/True.d.ts.map +1 -1
- package/dist/src/Assertions/True.js +2 -2
- package/dist/src/Assertions/True.js.map +1 -1
- package/dist/src/Assertions/Undefined.d.ts +1 -1
- package/dist/src/Assertions/Undefined.d.ts.map +1 -1
- package/dist/src/Assertions/Undefined.js +2 -2
- package/dist/src/Assertions/Undefined.js.map +1 -1
- package/dist/src/Assertions/index.d.ts +15 -15
- package/dist/src/Assertions/index.d.ts.map +1 -1
- package/dist/src/Assertions/index.js +15 -15
- package/dist/src/Assertions/index.js.map +1 -1
- package/dist/src/CLI.d.ts +1 -1
- package/dist/src/CLI.d.ts.map +1 -1
- package/dist/src/CLI.js +7 -6
- package/dist/src/CLI.js.map +1 -1
- package/dist/src/Factory.d.ts +1 -1
- package/dist/src/Factory.d.ts.map +1 -1
- package/dist/src/Factory.js +7 -7
- package/dist/src/Factory.js.map +1 -1
- package/dist/src/Framework/Test.d.ts +1 -1
- package/dist/src/Framework/Test.d.ts.map +1 -1
- package/dist/src/Framework/Test.js.map +1 -1
- package/dist/src/Framework/TestInfo.d.ts +5 -1
- package/dist/src/Framework/TestInfo.d.ts.map +1 -1
- package/dist/src/Framework/TestName.js +2 -2
- package/dist/src/Framework/TestName.js.map +1 -1
- package/dist/src/Framework/TestSuite.d.ts +2 -2
- package/dist/src/Framework/TestSuite.d.ts.map +1 -1
- package/dist/src/Framework/TestSuite.js +7 -6
- package/dist/src/Framework/TestSuite.js.map +1 -1
- package/dist/src/IO/FileSystem.d.ts +1 -1
- package/dist/src/IO/FileSystem.d.ts.map +1 -1
- package/dist/src/IO/FileSystem.js +4 -4
- package/dist/src/IO/FileSystem.js.map +1 -1
- package/dist/src/IO/Output.d.ts +1 -1
- package/dist/src/IO/Output.d.ts.map +1 -1
- package/dist/src/Reporters/ConsoleReporter.d.ts +4 -4
- package/dist/src/Reporters/ConsoleReporter.d.ts.map +1 -1
- package/dist/src/Reporters/ConsoleReporter.js +39 -28
- package/dist/src/Reporters/ConsoleReporter.js.map +1 -1
- package/dist/src/Reporters/FileReporter.d.ts +4 -4
- package/dist/src/Reporters/FileReporter.d.ts.map +1 -1
- package/dist/src/Reporters/FileReporter.js +0 -1
- package/dist/src/Reporters/FileReporter.js.map +1 -1
- package/dist/src/Reporters/JUnitReporter.d.ts.map +1 -1
- package/dist/src/Reporters/JUnitReporter.js +1 -1
- package/dist/src/Reporters/JUnitReporter.js.map +1 -1
- package/dist/src/Reporters/ResultReporter.d.ts +2 -2
- package/dist/src/Reporters/ResultReporter.d.ts.map +1 -1
- package/dist/src/Reporters/ResultReporter.js +1 -0
- package/dist/src/Reporters/ResultReporter.js.map +1 -1
- package/dist/src/Reporters/SonarReporter.d.ts.map +1 -1
- package/dist/src/Reporters/SonarReporter.js +2 -2
- package/dist/src/Reporters/SonarReporter.js.map +1 -1
- package/dist/src/Reporters/XMLReporter.d.ts +1 -1
- package/dist/src/Reporters/XMLReporter.d.ts.map +1 -1
- package/dist/src/Reporters/XMLReporter.js.map +1 -1
- package/dist/src/Runners/Runner.d.ts +3 -3
- package/dist/src/Runners/Runner.d.ts.map +1 -1
- package/dist/src/Runners/Runner.js +1 -1
- package/dist/src/Runners/Runner.js.map +1 -1
- package/dist/src/Runners/TestRunner.d.ts +4 -2
- package/dist/src/Runners/TestRunner.d.ts.map +1 -1
- package/dist/src/Runners/TestRunner.js +13 -8
- package/dist/src/Runners/TestRunner.js.map +1 -1
- package/dist/src/Runners/TestSuiteLoader.d.ts.map +1 -1
- package/dist/src/Runners/TestSuiteLoader.js +15 -11
- package/dist/src/Runners/TestSuiteLoader.js.map +1 -1
- package/dist/src/Runners/TestSuiteRunner.d.ts +4 -4
- package/dist/src/Runners/TestSuiteRunner.d.ts.map +1 -1
- package/dist/src/Runners/TestSuiteRunner.js +3 -3
- package/dist/src/Runners/TestSuiteRunner.js.map +1 -1
- package/dist/xunit.d.ts +2 -2
- package/dist/xunit.d.ts.map +1 -1
- package/dist/xunit.js +3 -3
- package/dist/xunit.js.map +1 -1
- package/eslint.config.ts +44 -0
- package/package.json +13 -9
- package/src/Assertions/Contains.ts +2 -2
- package/src/Assertions/Count.ts +2 -2
- package/src/Assertions/Defined.ts +2 -2
- package/src/Assertions/DoesNotContain.ts +2 -2
- package/src/Assertions/DoesNotThrow.ts +2 -2
- package/src/Assertions/Empty.ts +2 -2
- package/src/Assertions/Equal.ts +3 -2
- package/src/Assertions/False.ts +2 -2
- package/src/Assertions/InstanceOf.ts +2 -2
- package/src/Assertions/NotEmpty.ts +2 -2
- package/src/Assertions/NotEqual.ts +3 -2
- package/src/Assertions/NotNull.ts +2 -2
- package/src/Assertions/Null.ts +2 -2
- package/src/Assertions/StringContains.ts +2 -2
- package/src/Assertions/StringDoesNotContain.ts +2 -2
- package/src/Assertions/StringDoesNotEndWith.ts +2 -4
- package/src/Assertions/StringDoesNotMatch.ts +2 -2
- package/src/Assertions/StringDoesNotStartWith.ts +1 -1
- package/src/Assertions/StringEndsWith.ts +2 -4
- package/src/Assertions/StringMatches.ts +2 -2
- package/src/Assertions/StringStartsWith.ts +1 -1
- package/src/Assertions/Throws.ts +3 -3
- package/src/Assertions/True.ts +2 -2
- package/src/Assertions/Undefined.ts +2 -2
- package/src/Assertions/index.ts +15 -27
- package/src/CLI.ts +9 -6
- package/src/Factory.ts +11 -9
- package/src/Framework/Test.ts +1 -1
- package/src/Framework/TestInfo.ts +7 -1
- package/src/Framework/TestName.ts +2 -2
- package/src/Framework/TestSuite.ts +10 -8
- package/src/IO/FileSystem.ts +4 -4
- package/src/IO/Output.ts +1 -1
- package/src/Reporters/ConsoleReporter.ts +13 -11
- package/src/Reporters/FileReporter.ts +7 -5
- package/src/Reporters/JUnitReporter.ts +3 -2
- package/src/Reporters/ResultReporter.ts +4 -3
- package/src/Reporters/SonarReporter.ts +4 -2
- package/src/Reporters/XMLReporter.ts +2 -2
- package/src/Runners/Runner.ts +5 -5
- package/src/Runners/TestRunner.ts +19 -11
- package/src/Runners/TestSuiteLoader.ts +14 -7
- package/src/Runners/TestSuiteRunner.ts +7 -7
- package/tsconfig.json +3 -0
- package/xunit.ts +3 -4
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
1
3
|
import TestSuite from "../Framework/TestSuite";
|
|
2
4
|
import FileSystem from "../IO/FileSystem";
|
|
3
|
-
import path from "path";
|
|
4
5
|
|
|
5
6
|
export default class TestSuiteLoader {
|
|
6
7
|
constructor(private readonly file_system: FileSystem) {
|
|
@@ -8,17 +9,23 @@ export default class TestSuiteLoader {
|
|
|
8
9
|
|
|
9
10
|
static async loadTestSuite(file: string, filters: RegExp[]) {
|
|
10
11
|
const module_path = TestSuiteLoader.getModulePath(__dirname, file);
|
|
11
|
-
const test_class = await import(module_path);
|
|
12
|
-
|
|
12
|
+
const test_class = await import(module_path) as { default?: new () => TestSuite };
|
|
13
|
+
const constructor = test_class.default;
|
|
14
|
+
if (!constructor) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const prototype = constructor.prototype as TestSuite;
|
|
19
|
+
if (!(prototype instanceof TestSuite)) {
|
|
13
20
|
return null;
|
|
14
21
|
}
|
|
15
22
|
|
|
16
|
-
const tests =
|
|
23
|
+
const tests = prototype.getTests(filters);
|
|
17
24
|
if (tests === undefined || Object.keys(tests).length === 0) {
|
|
18
25
|
return null;
|
|
19
26
|
}
|
|
20
27
|
|
|
21
|
-
const suite
|
|
28
|
+
const suite = new constructor();
|
|
22
29
|
suite.setTests(tests);
|
|
23
30
|
return suite;
|
|
24
31
|
}
|
|
@@ -35,7 +42,7 @@ export default class TestSuiteLoader {
|
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
static isFromNodeModules(dir: string) {
|
|
38
|
-
return dir.
|
|
45
|
+
return dir.includes("node_modules");
|
|
39
46
|
}
|
|
40
47
|
|
|
41
48
|
async loadTestSuites(dir: string, filters: RegExp[]): Promise<Record<string, TestSuite>> {
|
|
@@ -46,7 +53,7 @@ export default class TestSuiteLoader {
|
|
|
46
53
|
|
|
47
54
|
for (const file of files) {
|
|
48
55
|
const suite = await TestSuiteLoader.loadTestSuite(file, filters);
|
|
49
|
-
if (suite !==
|
|
56
|
+
if (suite !== null) {
|
|
50
57
|
suites[file] = suite;
|
|
51
58
|
}
|
|
52
59
|
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TestInfo from "../Framework/TestInfo";
|
|
2
2
|
import TestSuite from "../Framework/TestSuite";
|
|
3
3
|
import TestSuiteResults from "../Framework/TestSuiteResults";
|
|
4
|
-
import
|
|
4
|
+
import ResultReporter from "../Reporters/ResultReporter";
|
|
5
5
|
import TestRunner from "./TestRunner";
|
|
6
6
|
|
|
7
7
|
export default class TestSuiteRunner {
|
|
8
8
|
|
|
9
|
-
constructor(private readonly runner: TestRunner, private readonly reporters:
|
|
9
|
+
constructor(private readonly runner: TestRunner, private readonly reporters: readonly ResultReporter[]) {
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
async runSuite(suite: TestSuite, filters: RegExp[]) {
|
|
13
|
-
|
|
13
|
+
this.reporters.map(r => r.suiteStarted(suite));
|
|
14
14
|
const tests = suite.getTests(filters);
|
|
15
15
|
const results = await this.runTests(suite, tests);
|
|
16
|
-
|
|
16
|
+
this.reporters.map(r => r.suiteCompleted(suite, results));
|
|
17
17
|
return results;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
async runTests(suite: TestSuite, tests
|
|
20
|
+
async runTests(suite: TestSuite, tests?: Record<string, TestInfo> | null) {
|
|
21
21
|
const results = new TestSuiteResults(suite);
|
|
22
22
|
if (tests === undefined || tests === null || Object.keys(tests).length === 0) {
|
|
23
|
-
|
|
23
|
+
this.reporters.map(r => r.testIncomplete(suite, "(no tests found)"));
|
|
24
24
|
return results;
|
|
25
25
|
}
|
|
26
26
|
|
package/tsconfig.json
CHANGED
package/xunit.ts
CHANGED