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.
Files changed (210) hide show
  1. package/README.md +25 -2
  2. package/cli.ts +9 -4
  3. package/dist/cli.js +4 -4
  4. package/dist/cli.js.map +1 -1
  5. package/dist/eslint.config.d.ts +3 -0
  6. package/dist/eslint.config.d.ts.map +1 -0
  7. package/dist/eslint.config.js +46 -0
  8. package/dist/eslint.config.js.map +1 -0
  9. package/dist/src/Assertions/Contains.d.ts +1 -1
  10. package/dist/src/Assertions/Contains.d.ts.map +1 -1
  11. package/dist/src/Assertions/Contains.js +2 -2
  12. package/dist/src/Assertions/Contains.js.map +1 -1
  13. package/dist/src/Assertions/Count.d.ts +1 -1
  14. package/dist/src/Assertions/Count.d.ts.map +1 -1
  15. package/dist/src/Assertions/Count.js +2 -2
  16. package/dist/src/Assertions/Count.js.map +1 -1
  17. package/dist/src/Assertions/Defined.d.ts +1 -1
  18. package/dist/src/Assertions/Defined.d.ts.map +1 -1
  19. package/dist/src/Assertions/Defined.js +2 -2
  20. package/dist/src/Assertions/Defined.js.map +1 -1
  21. package/dist/src/Assertions/DoesNotContain.d.ts +1 -1
  22. package/dist/src/Assertions/DoesNotContain.d.ts.map +1 -1
  23. package/dist/src/Assertions/DoesNotContain.js +2 -2
  24. package/dist/src/Assertions/DoesNotContain.js.map +1 -1
  25. package/dist/src/Assertions/DoesNotThrow.d.ts +1 -1
  26. package/dist/src/Assertions/DoesNotThrow.d.ts.map +1 -1
  27. package/dist/src/Assertions/DoesNotThrow.js +2 -2
  28. package/dist/src/Assertions/DoesNotThrow.js.map +1 -1
  29. package/dist/src/Assertions/Empty.d.ts +1 -1
  30. package/dist/src/Assertions/Empty.d.ts.map +1 -1
  31. package/dist/src/Assertions/Empty.js +2 -2
  32. package/dist/src/Assertions/Empty.js.map +1 -1
  33. package/dist/src/Assertions/Equal.d.ts +1 -1
  34. package/dist/src/Assertions/Equal.d.ts.map +1 -1
  35. package/dist/src/Assertions/Equal.js +2 -2
  36. package/dist/src/Assertions/Equal.js.map +1 -1
  37. package/dist/src/Assertions/False.d.ts +1 -1
  38. package/dist/src/Assertions/False.d.ts.map +1 -1
  39. package/dist/src/Assertions/False.js +2 -2
  40. package/dist/src/Assertions/False.js.map +1 -1
  41. package/dist/src/Assertions/InstanceOf.d.ts +1 -1
  42. package/dist/src/Assertions/InstanceOf.d.ts.map +1 -1
  43. package/dist/src/Assertions/InstanceOf.js +2 -2
  44. package/dist/src/Assertions/InstanceOf.js.map +1 -1
  45. package/dist/src/Assertions/NotEmpty.d.ts +1 -1
  46. package/dist/src/Assertions/NotEmpty.d.ts.map +1 -1
  47. package/dist/src/Assertions/NotEmpty.js +2 -2
  48. package/dist/src/Assertions/NotEmpty.js.map +1 -1
  49. package/dist/src/Assertions/NotEqual.d.ts +1 -1
  50. package/dist/src/Assertions/NotEqual.d.ts.map +1 -1
  51. package/dist/src/Assertions/NotEqual.js +2 -2
  52. package/dist/src/Assertions/NotEqual.js.map +1 -1
  53. package/dist/src/Assertions/NotNull.d.ts +1 -1
  54. package/dist/src/Assertions/NotNull.d.ts.map +1 -1
  55. package/dist/src/Assertions/NotNull.js +2 -2
  56. package/dist/src/Assertions/NotNull.js.map +1 -1
  57. package/dist/src/Assertions/Null.d.ts +1 -1
  58. package/dist/src/Assertions/Null.d.ts.map +1 -1
  59. package/dist/src/Assertions/Null.js +2 -2
  60. package/dist/src/Assertions/Null.js.map +1 -1
  61. package/dist/src/Assertions/StringContains.js +3 -3
  62. package/dist/src/Assertions/StringContains.js.map +1 -1
  63. package/dist/src/Assertions/StringDoesNotContain.js +3 -3
  64. package/dist/src/Assertions/StringDoesNotContain.js.map +1 -1
  65. package/dist/src/Assertions/StringDoesNotEndWith.d.ts.map +1 -1
  66. package/dist/src/Assertions/StringDoesNotEndWith.js +3 -5
  67. package/dist/src/Assertions/StringDoesNotEndWith.js.map +1 -1
  68. package/dist/src/Assertions/StringDoesNotMatch.d.ts +1 -1
  69. package/dist/src/Assertions/StringDoesNotMatch.d.ts.map +1 -1
  70. package/dist/src/Assertions/StringDoesNotMatch.js +2 -2
  71. package/dist/src/Assertions/StringDoesNotMatch.js.map +1 -1
  72. package/dist/src/Assertions/StringDoesNotStartWith.js +2 -2
  73. package/dist/src/Assertions/StringDoesNotStartWith.js.map +1 -1
  74. package/dist/src/Assertions/StringEndsWith.d.ts.map +1 -1
  75. package/dist/src/Assertions/StringEndsWith.js +3 -5
  76. package/dist/src/Assertions/StringEndsWith.js.map +1 -1
  77. package/dist/src/Assertions/StringMatches.d.ts +1 -1
  78. package/dist/src/Assertions/StringMatches.d.ts.map +1 -1
  79. package/dist/src/Assertions/StringMatches.js +2 -2
  80. package/dist/src/Assertions/StringMatches.js.map +1 -1
  81. package/dist/src/Assertions/StringStartsWith.js +2 -2
  82. package/dist/src/Assertions/StringStartsWith.js.map +1 -1
  83. package/dist/src/Assertions/Throws.d.ts +1 -1
  84. package/dist/src/Assertions/Throws.d.ts.map +1 -1
  85. package/dist/src/Assertions/Throws.js +3 -3
  86. package/dist/src/Assertions/Throws.js.map +1 -1
  87. package/dist/src/Assertions/True.d.ts +1 -1
  88. package/dist/src/Assertions/True.d.ts.map +1 -1
  89. package/dist/src/Assertions/True.js +2 -2
  90. package/dist/src/Assertions/True.js.map +1 -1
  91. package/dist/src/Assertions/Undefined.d.ts +1 -1
  92. package/dist/src/Assertions/Undefined.d.ts.map +1 -1
  93. package/dist/src/Assertions/Undefined.js +2 -2
  94. package/dist/src/Assertions/Undefined.js.map +1 -1
  95. package/dist/src/Assertions/index.d.ts +15 -15
  96. package/dist/src/Assertions/index.d.ts.map +1 -1
  97. package/dist/src/Assertions/index.js +15 -15
  98. package/dist/src/Assertions/index.js.map +1 -1
  99. package/dist/src/CLI.d.ts +1 -1
  100. package/dist/src/CLI.d.ts.map +1 -1
  101. package/dist/src/CLI.js +7 -6
  102. package/dist/src/CLI.js.map +1 -1
  103. package/dist/src/Factory.d.ts +1 -1
  104. package/dist/src/Factory.d.ts.map +1 -1
  105. package/dist/src/Factory.js +7 -7
  106. package/dist/src/Factory.js.map +1 -1
  107. package/dist/src/Framework/Test.d.ts +1 -1
  108. package/dist/src/Framework/Test.d.ts.map +1 -1
  109. package/dist/src/Framework/Test.js.map +1 -1
  110. package/dist/src/Framework/TestInfo.d.ts +5 -1
  111. package/dist/src/Framework/TestInfo.d.ts.map +1 -1
  112. package/dist/src/Framework/TestName.js +2 -2
  113. package/dist/src/Framework/TestName.js.map +1 -1
  114. package/dist/src/Framework/TestSuite.d.ts +2 -2
  115. package/dist/src/Framework/TestSuite.d.ts.map +1 -1
  116. package/dist/src/Framework/TestSuite.js +7 -6
  117. package/dist/src/Framework/TestSuite.js.map +1 -1
  118. package/dist/src/IO/FileSystem.d.ts +1 -1
  119. package/dist/src/IO/FileSystem.d.ts.map +1 -1
  120. package/dist/src/IO/FileSystem.js +4 -4
  121. package/dist/src/IO/FileSystem.js.map +1 -1
  122. package/dist/src/IO/Output.d.ts +1 -1
  123. package/dist/src/IO/Output.d.ts.map +1 -1
  124. package/dist/src/Reporters/ConsoleReporter.d.ts +4 -4
  125. package/dist/src/Reporters/ConsoleReporter.d.ts.map +1 -1
  126. package/dist/src/Reporters/ConsoleReporter.js +39 -28
  127. package/dist/src/Reporters/ConsoleReporter.js.map +1 -1
  128. package/dist/src/Reporters/FileReporter.d.ts +4 -4
  129. package/dist/src/Reporters/FileReporter.d.ts.map +1 -1
  130. package/dist/src/Reporters/FileReporter.js +0 -1
  131. package/dist/src/Reporters/FileReporter.js.map +1 -1
  132. package/dist/src/Reporters/JUnitReporter.d.ts.map +1 -1
  133. package/dist/src/Reporters/JUnitReporter.js +1 -1
  134. package/dist/src/Reporters/JUnitReporter.js.map +1 -1
  135. package/dist/src/Reporters/ResultReporter.d.ts +2 -2
  136. package/dist/src/Reporters/ResultReporter.d.ts.map +1 -1
  137. package/dist/src/Reporters/ResultReporter.js +1 -0
  138. package/dist/src/Reporters/ResultReporter.js.map +1 -1
  139. package/dist/src/Reporters/SonarReporter.d.ts.map +1 -1
  140. package/dist/src/Reporters/SonarReporter.js +2 -2
  141. package/dist/src/Reporters/SonarReporter.js.map +1 -1
  142. package/dist/src/Reporters/XMLReporter.d.ts +1 -1
  143. package/dist/src/Reporters/XMLReporter.d.ts.map +1 -1
  144. package/dist/src/Reporters/XMLReporter.js.map +1 -1
  145. package/dist/src/Runners/Runner.d.ts +3 -3
  146. package/dist/src/Runners/Runner.d.ts.map +1 -1
  147. package/dist/src/Runners/Runner.js +1 -1
  148. package/dist/src/Runners/Runner.js.map +1 -1
  149. package/dist/src/Runners/TestRunner.d.ts +4 -2
  150. package/dist/src/Runners/TestRunner.d.ts.map +1 -1
  151. package/dist/src/Runners/TestRunner.js +13 -8
  152. package/dist/src/Runners/TestRunner.js.map +1 -1
  153. package/dist/src/Runners/TestSuiteLoader.d.ts.map +1 -1
  154. package/dist/src/Runners/TestSuiteLoader.js +15 -11
  155. package/dist/src/Runners/TestSuiteLoader.js.map +1 -1
  156. package/dist/src/Runners/TestSuiteRunner.d.ts +4 -4
  157. package/dist/src/Runners/TestSuiteRunner.d.ts.map +1 -1
  158. package/dist/src/Runners/TestSuiteRunner.js +3 -3
  159. package/dist/src/Runners/TestSuiteRunner.js.map +1 -1
  160. package/dist/xunit.d.ts +2 -2
  161. package/dist/xunit.d.ts.map +1 -1
  162. package/dist/xunit.js +3 -3
  163. package/dist/xunit.js.map +1 -1
  164. package/eslint.config.ts +44 -0
  165. package/package.json +13 -9
  166. package/src/Assertions/Contains.ts +2 -2
  167. package/src/Assertions/Count.ts +2 -2
  168. package/src/Assertions/Defined.ts +2 -2
  169. package/src/Assertions/DoesNotContain.ts +2 -2
  170. package/src/Assertions/DoesNotThrow.ts +2 -2
  171. package/src/Assertions/Empty.ts +2 -2
  172. package/src/Assertions/Equal.ts +3 -2
  173. package/src/Assertions/False.ts +2 -2
  174. package/src/Assertions/InstanceOf.ts +2 -2
  175. package/src/Assertions/NotEmpty.ts +2 -2
  176. package/src/Assertions/NotEqual.ts +3 -2
  177. package/src/Assertions/NotNull.ts +2 -2
  178. package/src/Assertions/Null.ts +2 -2
  179. package/src/Assertions/StringContains.ts +2 -2
  180. package/src/Assertions/StringDoesNotContain.ts +2 -2
  181. package/src/Assertions/StringDoesNotEndWith.ts +2 -4
  182. package/src/Assertions/StringDoesNotMatch.ts +2 -2
  183. package/src/Assertions/StringDoesNotStartWith.ts +1 -1
  184. package/src/Assertions/StringEndsWith.ts +2 -4
  185. package/src/Assertions/StringMatches.ts +2 -2
  186. package/src/Assertions/StringStartsWith.ts +1 -1
  187. package/src/Assertions/Throws.ts +3 -3
  188. package/src/Assertions/True.ts +2 -2
  189. package/src/Assertions/Undefined.ts +2 -2
  190. package/src/Assertions/index.ts +15 -27
  191. package/src/CLI.ts +9 -6
  192. package/src/Factory.ts +11 -9
  193. package/src/Framework/Test.ts +1 -1
  194. package/src/Framework/TestInfo.ts +7 -1
  195. package/src/Framework/TestName.ts +2 -2
  196. package/src/Framework/TestSuite.ts +10 -8
  197. package/src/IO/FileSystem.ts +4 -4
  198. package/src/IO/Output.ts +1 -1
  199. package/src/Reporters/ConsoleReporter.ts +13 -11
  200. package/src/Reporters/FileReporter.ts +7 -5
  201. package/src/Reporters/JUnitReporter.ts +3 -2
  202. package/src/Reporters/ResultReporter.ts +4 -3
  203. package/src/Reporters/SonarReporter.ts +4 -2
  204. package/src/Reporters/XMLReporter.ts +2 -2
  205. package/src/Runners/Runner.ts +5 -5
  206. package/src/Runners/TestRunner.ts +19 -11
  207. package/src/Runners/TestSuiteLoader.ts +14 -7
  208. package/src/Runners/TestSuiteRunner.ts +7 -7
  209. package/tsconfig.json +3 -0
  210. 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
- if (!(test_class.default?.prototype instanceof TestSuite)) {
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 = test_class.default?.prototype.getTests(filters);
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: TestSuite = new test_class.default();
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.indexOf("node_modules") !== -1;
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 !== undefined && suite !== null) {
56
+ if (suite !== null) {
50
57
  suites[file] = suite;
51
58
  }
52
59
  }
@@ -1,26 +1,26 @@
1
- import ResultReporter from "../Reporters/ResultReporter";
1
+ import TestInfo from "../Framework/TestInfo";
2
2
  import TestSuite from "../Framework/TestSuite";
3
3
  import TestSuiteResults from "../Framework/TestSuiteResults";
4
- import TestInfo from "../Framework/TestInfo";
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: ReadonlyArray<ResultReporter>) {
9
+ constructor(private readonly runner: TestRunner, private readonly reporters: readonly ResultReporter[]) {
10
10
  }
11
11
 
12
12
  async runSuite(suite: TestSuite, filters: RegExp[]) {
13
- await Promise.all(this.reporters.map(r => r.suiteStarted(suite)));
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
- await Promise.all(this.reporters.map(r => r.suiteCompleted(suite, results)));
16
+ this.reporters.map(r => r.suiteCompleted(suite, results));
17
17
  return results;
18
18
  }
19
19
 
20
- async runTests(suite: TestSuite, tests: Record<string, TestInfo>) {
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
- await Promise.all(this.reporters.map(r => r.testIncomplete(suite, "(no tests found)")));
23
+ this.reporters.map(r => r.testIncomplete(suite, "(no tests found)"));
24
24
  return results;
25
25
  }
26
26
 
package/tsconfig.json CHANGED
@@ -3,6 +3,9 @@
3
3
  "target": "ES2015",
4
4
  "module": "CommonJS",
5
5
  "outDir": "dist/",
6
+ "lib": [
7
+ "ES2024"
8
+ ],
6
9
  "strict": true,
7
10
  "sourceMap": true,
8
11
  "declaration": true,
package/xunit.ts CHANGED
@@ -1,9 +1,8 @@
1
+ import Assert from "./src/Assertions";
1
2
  import Test from "./src/Framework/Test";
2
3
  import TestSuite from "./src/Framework/TestSuite";
3
- import Assert from "./src/Assertions";
4
4
 
5
5
  export {
6
+ Assert,
6
7
  Test,
7
- TestSuite,
8
- Assert
9
- };
8
+ TestSuite };