xunit.ts 1.4.0 → 2.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 (123) hide show
  1. package/README.md +21 -19
  2. package/dist/src/Assertions/Contains.js +2 -2
  3. package/dist/src/Assertions/Contains.js.map +1 -1
  4. package/dist/src/Assertions/Count.js +2 -2
  5. package/dist/src/Assertions/Count.js.map +1 -1
  6. package/dist/src/Assertions/Defined.js +2 -2
  7. package/dist/src/Assertions/Defined.js.map +1 -1
  8. package/dist/src/Assertions/DoesNotContain.js +2 -2
  9. package/dist/src/Assertions/DoesNotContain.js.map +1 -1
  10. package/dist/src/Assertions/DoesNotThrow.js +2 -2
  11. package/dist/src/Assertions/DoesNotThrow.js.map +1 -1
  12. package/dist/src/Assertions/Empty.js +2 -2
  13. package/dist/src/Assertions/Empty.js.map +1 -1
  14. package/dist/src/Assertions/Equal.js +2 -2
  15. package/dist/src/Assertions/Equal.js.map +1 -1
  16. package/dist/src/Assertions/False.js +2 -2
  17. package/dist/src/Assertions/False.js.map +1 -1
  18. package/dist/src/Assertions/InstanceOf.js +2 -2
  19. package/dist/src/Assertions/InstanceOf.js.map +1 -1
  20. package/dist/src/Assertions/NotEmpty.js +2 -2
  21. package/dist/src/Assertions/NotEmpty.js.map +1 -1
  22. package/dist/src/Assertions/NotEqual.js +2 -2
  23. package/dist/src/Assertions/NotEqual.js.map +1 -1
  24. package/dist/src/Assertions/NotNull.js +2 -2
  25. package/dist/src/Assertions/NotNull.js.map +1 -1
  26. package/dist/src/Assertions/Null.js +2 -2
  27. package/dist/src/Assertions/Null.js.map +1 -1
  28. package/dist/src/Assertions/StringContains.js +2 -2
  29. package/dist/src/Assertions/StringContains.js.map +1 -1
  30. package/dist/src/Assertions/StringDoesNotContain.js +2 -2
  31. package/dist/src/Assertions/StringDoesNotContain.js.map +1 -1
  32. package/dist/src/Assertions/StringDoesNotEndWith.js +2 -2
  33. package/dist/src/Assertions/StringDoesNotEndWith.js.map +1 -1
  34. package/dist/src/Assertions/StringDoesNotMatch.d.ts +17 -0
  35. package/dist/src/Assertions/StringDoesNotMatch.d.ts.map +1 -0
  36. package/dist/src/Assertions/StringDoesNotMatch.js +30 -0
  37. package/dist/src/Assertions/StringDoesNotMatch.js.map +1 -0
  38. package/dist/src/Assertions/StringDoesNotStartWith.js +3 -3
  39. package/dist/src/Assertions/StringDoesNotStartWith.js.map +1 -1
  40. package/dist/src/Assertions/StringEndsWith.js +2 -2
  41. package/dist/src/Assertions/StringEndsWith.js.map +1 -1
  42. package/dist/src/Assertions/StringMatches.d.ts +17 -0
  43. package/dist/src/Assertions/StringMatches.d.ts.map +1 -0
  44. package/dist/src/Assertions/StringMatches.js +30 -0
  45. package/dist/src/Assertions/StringMatches.js.map +1 -0
  46. package/dist/src/Assertions/StringStartsWith.js +3 -3
  47. package/dist/src/Assertions/StringStartsWith.js.map +1 -1
  48. package/dist/src/Assertions/Throws.js +2 -2
  49. package/dist/src/Assertions/Throws.js.map +1 -1
  50. package/dist/src/Assertions/True.js +2 -2
  51. package/dist/src/Assertions/True.js.map +1 -1
  52. package/dist/src/Assertions/Undefined.js +2 -2
  53. package/dist/src/Assertions/Undefined.js.map +1 -1
  54. package/dist/src/Assertions/index.d.ts +4 -0
  55. package/dist/src/Assertions/index.d.ts.map +1 -1
  56. package/dist/src/Assertions/index.js +4 -0
  57. package/dist/src/Assertions/index.js.map +1 -1
  58. package/dist/src/CLI.d.ts +0 -2
  59. package/dist/src/CLI.d.ts.map +1 -1
  60. package/dist/src/CLI.js +4 -3
  61. package/dist/src/CLI.js.map +1 -1
  62. package/dist/src/Framework/ResultType.js +1 -1
  63. package/dist/src/Framework/ResultType.js.map +1 -1
  64. package/dist/src/Framework/Test.d.ts.map +1 -1
  65. package/dist/src/Framework/Test.js +2 -2
  66. package/dist/src/Framework/Test.js.map +1 -1
  67. package/dist/src/Framework/TestSuite.d.ts +2 -0
  68. package/dist/src/Framework/TestSuite.d.ts.map +1 -1
  69. package/dist/src/Framework/TestSuite.js +2 -0
  70. package/dist/src/Framework/TestSuite.js.map +1 -1
  71. package/dist/src/IO/FileSystem.d.ts +1 -1
  72. package/dist/src/IO/FileSystem.d.ts.map +1 -1
  73. package/dist/src/IO/FileSystem.js +2 -1
  74. package/dist/src/IO/FileSystem.js.map +1 -1
  75. package/dist/src/IO/Output.d.ts +0 -1
  76. package/dist/src/IO/Output.d.ts.map +1 -1
  77. package/dist/src/IO/Output.js.map +1 -1
  78. package/dist/src/Reporters/ConsoleReporter.d.ts +0 -1
  79. package/dist/src/Reporters/ConsoleReporter.d.ts.map +1 -1
  80. package/dist/src/Reporters/ConsoleReporter.js +1 -1
  81. package/dist/src/Reporters/ConsoleReporter.js.map +1 -1
  82. package/dist/src/Reporters/FileReporter.d.ts +0 -1
  83. package/dist/src/Reporters/FileReporter.d.ts.map +1 -1
  84. package/dist/src/Reporters/JUnitReporter.js.map +1 -1
  85. package/dist/src/Reporters/ResultReporter.d.ts +0 -1
  86. package/dist/src/Reporters/ResultReporter.d.ts.map +1 -1
  87. package/dist/src/Reporters/SonarReporter.js.map +1 -1
  88. package/dist/src/Runners/Runner.js.map +1 -1
  89. package/dist/src/Runners/TestRunner.js.map +1 -1
  90. package/dist/src/Runners/TestSuiteLoader.js +18 -8
  91. package/dist/src/Runners/TestSuiteLoader.js.map +1 -1
  92. package/dist/src/Runners/TestSuiteRunner.js.map +1 -1
  93. package/package.json +14 -14
  94. package/src/Assertions/Contains.ts +1 -1
  95. package/src/Assertions/Count.ts +1 -1
  96. package/src/Assertions/Defined.ts +1 -1
  97. package/src/Assertions/DoesNotContain.ts +1 -1
  98. package/src/Assertions/DoesNotThrow.ts +1 -1
  99. package/src/Assertions/Empty.ts +1 -1
  100. package/src/Assertions/Equal.ts +1 -1
  101. package/src/Assertions/False.ts +1 -1
  102. package/src/Assertions/InstanceOf.ts +1 -1
  103. package/src/Assertions/NotEmpty.ts +1 -1
  104. package/src/Assertions/NotEqual.ts +1 -1
  105. package/src/Assertions/NotNull.ts +1 -1
  106. package/src/Assertions/Null.ts +1 -1
  107. package/src/Assertions/StringContains.ts +1 -1
  108. package/src/Assertions/StringDoesNotContain.ts +1 -1
  109. package/src/Assertions/StringDoesNotEndWith.ts +1 -1
  110. package/src/Assertions/StringDoesNotMatch.ts +28 -0
  111. package/src/Assertions/StringDoesNotStartWith.ts +2 -2
  112. package/src/Assertions/StringEndsWith.ts +1 -1
  113. package/src/Assertions/StringMatches.ts +28 -0
  114. package/src/Assertions/StringStartsWith.ts +2 -2
  115. package/src/Assertions/Throws.ts +1 -1
  116. package/src/Assertions/True.ts +1 -1
  117. package/src/Assertions/Undefined.ts +1 -1
  118. package/src/Assertions/index.ts +6 -0
  119. package/src/CLI.ts +4 -3
  120. package/src/Framework/Test.ts +1 -1
  121. package/src/Framework/TestSuite.ts +3 -0
  122. package/src/IO/FileSystem.ts +3 -1
  123. package/src/Reporters/ConsoleReporter.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xunit.ts",
3
- "version": "1.4.0",
3
+ "version": "2.0.0",
4
4
  "description": "A unit testing framework for TypeScript, following standard xUnit patterns",
5
5
  "main": "dist/xunit.js",
6
6
  "author": "ecoAPM LLC",
@@ -8,28 +8,28 @@
8
8
  "bugs": "https://github.com/ecoAPM/xunit.ts/issues",
9
9
  "license": "MIT",
10
10
  "engines": {
11
- "node": ">= 14"
11
+ "node": ">= 18"
12
12
  },
13
13
  "dependencies": {
14
14
  "colors": "1.4.0",
15
- "command-line-args": "5.2.1",
16
- "command-line-usage": "7.0.1",
15
+ "command-line-args": "6.0.1",
16
+ "command-line-usage": "7.0.3",
17
17
  "lodash.escaperegexp": "4.1.2",
18
18
  "lodash.isequal": "4.5.0",
19
19
  "xml": "1.0.1"
20
20
  },
21
21
  "devDependencies": {
22
- "@types/command-line-args": "5.2.0",
23
- "@types/command-line-usage": "5.0.2",
24
- "@types/lodash.escaperegexp": "4.1.7",
25
- "@types/lodash.isequal": "4.5.6",
26
- "@types/node": "18.15.7",
27
- "@types/xml": "1.0.8",
28
- "@typescript-eslint/eslint-plugin": "5.56.0",
29
- "@typescript-eslint/parser": "5.56.0",
30
- "eslint": "8.36.0",
22
+ "@types/command-line-args": "5.2.3",
23
+ "@types/command-line-usage": "5.0.4",
24
+ "@types/lodash.escaperegexp": "4.1.9",
25
+ "@types/lodash.isequal": "4.5.8",
26
+ "@types/node": "22.10.6",
27
+ "@types/xml": "1.0.11",
28
+ "@typescript-eslint/eslint-plugin": "8.20.0",
29
+ "@typescript-eslint/parser": "8.20.0",
30
+ "eslint": "9.18.0",
31
31
  "ts-mockito": "2.6.1",
32
- "typescript": "5.0.2"
32
+ "typescript": "5.7.3"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "typescript": ">= 4"
@@ -21,7 +21,7 @@ export default function Contains<T>(needle: T, haystack: ReadonlyArray<T>, messa
21
21
  }
22
22
 
23
23
  throw new AssertionError({
24
- message: message || "Expected array containing expression, but array did not contain expression",
24
+ message: message ?? "Expected array containing expression, but array did not contain expression",
25
25
  expected: needle,
26
26
  actual: haystack
27
27
  });
@@ -21,7 +21,7 @@ export default function Count(expected: number, array: ReadonlyArray<any>, messa
21
21
  }
22
22
 
23
23
  throw new AssertionError({
24
- message: message || `Expected array with ${expected} elements, but array had ${array.length} elements`,
24
+ message: message ?? `Expected array with ${expected} elements, but array had ${array.length} elements`,
25
25
  expected: expected,
26
26
  actual: array.length
27
27
  });
@@ -20,7 +20,7 @@ export default function Defined(expression: any, message?: string) {
20
20
  }
21
21
 
22
22
  throw new AssertionError({
23
- message: message || "Expected expression to be defined, but expression is undefined",
23
+ message: message ?? "Expected expression to be defined, but expression is undefined",
24
24
  expected: "(not undefined expression)",
25
25
  actual: expression
26
26
  });
@@ -21,7 +21,7 @@ export default function DoesNotContain<T>(needle: T, haystack: ReadonlyArray<T>,
21
21
  }
22
22
 
23
23
  throw new AssertionError({
24
- message: message || "Expected array not containing expression, but array contained expression",
24
+ message: message ?? "Expected array not containing expression, but array contained expression",
25
25
  expected: needle,
26
26
  actual: haystack
27
27
  });
@@ -20,7 +20,7 @@ export default function DoesNotThrow(expression: () => any, message?: string) {
20
20
  return;
21
21
  } catch (exception) {
22
22
  throw new AssertionError({
23
- message: message || "Expected expression to not throw exception, but expression did throw exception",
23
+ message: message ?? "Expected expression to not throw exception, but expression did throw exception",
24
24
  expected: "(no exception)",
25
25
  actual: exception
26
26
  });
@@ -20,7 +20,7 @@ export default function Empty(array: ReadonlyArray<any>, message?: string) {
20
20
  }
21
21
 
22
22
  throw new AssertionError({
23
- message: message || "Expected expression to be empty, but expression was not empty",
23
+ message: message ?? "Expected expression to be empty, but expression was not empty",
24
24
  expected: [],
25
25
  actual: array
26
26
  });
@@ -22,7 +22,7 @@ export default function Equal(expected: any, actual: any, message?: string) {
22
22
  }
23
23
 
24
24
  throw new AssertionError({
25
- message: message || "Expected expressions to be equal, but expressions are not equal",
25
+ message: message ?? "Expected expressions to be equal, but expressions are not equal",
26
26
  expected: expected,
27
27
  actual: actual,
28
28
  });
@@ -20,7 +20,7 @@ export default function False(expression: any, message?: string) {
20
20
  }
21
21
 
22
22
  throw new AssertionError({
23
- message: message || "Expected expression to be false, but expression is not false",
23
+ message: message ?? "Expected expression to be false, but expression is not false",
24
24
  expected: false,
25
25
  actual: expression
26
26
  });
@@ -21,7 +21,7 @@ export default function InstanceOf(type: any, expression: any, message?: string)
21
21
  }
22
22
 
23
23
  throw new AssertionError({
24
- message: message || `Expected expression of type, but was ${typeof expression}`,
24
+ message: message ?? `Expected expression of type, but was ${typeof expression}`,
25
25
  expected: type.name,
26
26
  actual: typeof expression
27
27
  });
@@ -20,7 +20,7 @@ export default function NotEmpty(array: ReadonlyArray<any>, message?: string) {
20
20
  }
21
21
 
22
22
  throw new AssertionError({
23
- message: message || "Expected expression to be not empty, but expression was empty",
23
+ message: message ?? "Expected expression to be not empty, but expression was empty",
24
24
  expected: "(non-empty expression)",
25
25
  actual: array
26
26
  });
@@ -22,7 +22,7 @@ export default function NotEqual(expected: any, actual: any, message?: string) {
22
22
  }
23
23
 
24
24
  throw new AssertionError({
25
- message: message || "Expected expressions to be not equal, but expressions are equal",
25
+ message: message ?? "Expected expressions to be not equal, but expressions are equal",
26
26
  expected: expected,
27
27
  actual: actual,
28
28
  });
@@ -20,7 +20,7 @@ export default function NotNull(expression: any, message?: string) {
20
20
  }
21
21
 
22
22
  throw new AssertionError({
23
- message: message || "Expected expression to be not null, but expression is null",
23
+ message: message ?? "Expected expression to be not null, but expression is null",
24
24
  expected: "(non-null expression)",
25
25
  actual: expression
26
26
  });
@@ -20,7 +20,7 @@ export default function Null(expression: any, message?: string) {
20
20
  }
21
21
 
22
22
  throw new AssertionError({
23
- message: message || "Expected expression to be null, but expression is not null",
23
+ message: message ?? "Expected expression to be null, but expression is not null",
24
24
  expected: null,
25
25
  actual: expression
26
26
  });
@@ -21,7 +21,7 @@ export default function StringContains(needle: string, haystack: string | null,
21
21
  }
22
22
 
23
23
  throw new AssertionError({
24
- message: message || "Expected string containing expression, but string did not contain expression",
24
+ message: message ?? "Expected string containing expression, but string did not contain expression",
25
25
  expected: needle,
26
26
  actual: haystack
27
27
  });
@@ -21,7 +21,7 @@ export default function StringDoesNotContain(needle: string, haystack: string |
21
21
  }
22
22
 
23
23
  throw new AssertionError({
24
- message: message || "Expected string not containing expression, but string did contain expression",
24
+ message: message ?? "Expected string not containing expression, but string did contain expression",
25
25
  expected: needle,
26
26
  actual: haystack
27
27
  });
@@ -23,7 +23,7 @@ export default function StringDoesNotEndWith(needle: string, haystack: string |
23
23
  }
24
24
 
25
25
  throw new AssertionError({
26
- message: message || "Expected string containing expression, but string did not contain expression",
26
+ message: message ?? "Expected string containing expression, but string did not contain expression",
27
27
  expected: needle,
28
28
  actual: haystack
29
29
  });
@@ -0,0 +1,28 @@
1
+ import { AssertionError } from "assert";
2
+
3
+ /**
4
+ * Asserts that a string does not match a given regular expression
5
+ *
6
+ * @remarks
7
+ * Passes if `haystack` does not pass a `regex` test
8
+ *
9
+ * Fails if `haystack` passes a `regex` test
10
+ *
11
+ * @param regex the regular expression to test
12
+ * @param haystack the string to search
13
+ * @param message (optional) message to display on failure
14
+ *
15
+ * @example
16
+ * this.assert.stringDoesNotMatch(regex, haystack);
17
+ */
18
+ export default function StringDoesNotMatch(regex: RegExp, haystack: string | null, message?: string) {
19
+ if (haystack === undefined || haystack === null || !regex.test(haystack)) {
20
+ return;
21
+ }
22
+
23
+ throw new AssertionError({
24
+ message: message ?? "Expected string not pass regular expression test, but string did pass",
25
+ expected: regex.test(haystack),
26
+ actual: haystack
27
+ });
28
+ }
@@ -16,12 +16,12 @@ import { AssertionError } from "assert";
16
16
  * this.assert.stringDoesNotStartWith(needle, haystack);
17
17
  */
18
18
  export default function StringDoesNotStartWith(needle: string, haystack: string | null, message?: string) {
19
- if (haystack === undefined || haystack === null || haystack.indexOf(needle) !== 0) {
19
+ if (!haystack?.startsWith(needle)) {
20
20
  return;
21
21
  }
22
22
 
23
23
  throw new AssertionError({
24
- message: message || "Expected string containing expression, but string did not contain expression",
24
+ message: message ?? "Expected string containing expression, but string did not contain expression",
25
25
  expected: needle,
26
26
  actual: haystack
27
27
  });
@@ -23,7 +23,7 @@ export default function StringEndsWith(needle: string, haystack: string | null,
23
23
  }
24
24
 
25
25
  throw new AssertionError({
26
- message: message || "Expected string containing expression, but string did not contain expression",
26
+ message: message ?? "Expected string containing expression, but string did not contain expression",
27
27
  expected: needle,
28
28
  actual: haystack
29
29
  });
@@ -0,0 +1,28 @@
1
+ import { AssertionError } from "assert";
2
+
3
+ /**
4
+ * Asserts that a string matches a given regular expression
5
+ *
6
+ * @remarks
7
+ * Passes if `haystack` matches a `regex` test
8
+ *
9
+ * Fails if `haystack` does not match a `regex` test
10
+ *
11
+ * @param regex the regular expression to match
12
+ * @param haystack the string to search
13
+ * @param message (optional) message to display on failure
14
+ *
15
+ * @example
16
+ * this.assert.stringMatches(regex, haystack);
17
+ */
18
+ export default function StringMatches(regex: RegExp, haystack: string | null, message?: string) {
19
+ if (haystack !== undefined && haystack !== null && regex.test(haystack)) {
20
+ return;
21
+ }
22
+
23
+ throw new AssertionError({
24
+ message: message ?? "Expected string to match regular expression, but string did not match",
25
+ expected: regex,
26
+ actual: haystack
27
+ });
28
+ }
@@ -16,12 +16,12 @@ import { AssertionError } from "assert";
16
16
  * this.assert.stringStartsWith(needle, haystack);
17
17
  */
18
18
  export default function StringStartsWith(needle: string, haystack: string | null, message?: string) {
19
- if (haystack !== undefined && haystack !== null && haystack.indexOf(needle) === 0) {
19
+ if (haystack?.startsWith(needle)) {
20
20
  return;
21
21
  }
22
22
 
23
23
  throw new AssertionError({
24
- message: message || "Expected string containing expression, but string did not contain expression",
24
+ message: message ?? "Expected string containing expression, but string did not contain expression",
25
25
  expected: needle,
26
26
  actual: haystack
27
27
  });
@@ -22,6 +22,6 @@ export default function Throws(expression: () => any, message?: string) {
22
22
  }
23
23
 
24
24
  throw new AssertionError({
25
- message: message || "Expected expression to throw exception, but expression did not throw exception"
25
+ message: message ?? "Expected expression to throw exception, but expression did not throw exception"
26
26
  });
27
27
  }
@@ -20,7 +20,7 @@ export default function True(expression: any, message?: string) {
20
20
  }
21
21
 
22
22
  throw new AssertionError({
23
- message: message || "Expected expression to be true, but expression is not true",
23
+ message: message ?? "Expected expression to be true, but expression is not true",
24
24
  expected: true,
25
25
  actual: expression
26
26
  });
@@ -20,7 +20,7 @@ export default function Undefined(expression: any, message?: string) {
20
20
  }
21
21
 
22
22
  throw new AssertionError({
23
- message: message || "Expected expression to be undefined, but expression is not undefined",
23
+ message: message ?? "Expected expression to be undefined, but expression is not undefined",
24
24
  expected: undefined,
25
25
  actual: expression
26
26
  });
@@ -27,6 +27,9 @@ import string_not_starts from "./StringDoesNotStartWith";
27
27
  import string_ends from "./StringEndsWith";
28
28
  import string_not_ends from "./StringDoesNotEndWith";
29
29
 
30
+ import string_matches from "./StringMatches";
31
+ import string_not_matches from "./StringDoesNotMatch";
32
+
30
33
  import instance_of from "./InstanceOf";
31
34
 
32
35
  import throws from "./Throws";
@@ -62,6 +65,9 @@ export default new class AssertionLibrary {
62
65
  stringEndsWith = string_ends;
63
66
  stringDoesNotEndWith = string_not_ends;
64
67
 
68
+ stringMatches = string_matches;
69
+ stringDoesNotMatch = string_not_matches;
70
+
65
71
  instanceOf = instance_of;
66
72
 
67
73
  throws = throws;
package/src/CLI.ts CHANGED
@@ -97,13 +97,14 @@ export default class CLI {
97
97
  const runner = this.runnerFactory(args);
98
98
 
99
99
  try {
100
- const filters = args.filter ?? [];
101
- const results = await runner.runAll(args.dir, filters.map(SafeRegex));
100
+ const filters: string[] = args.filter ?? [];
101
+ const regexFilters = filters.map((f: string) => new RegExp(SafeRegex(f)));
102
+ const results = await runner.runAll(args.dir, regexFilters);
102
103
  return Runner.allTestsPassed(results);
103
104
  } catch (error) {
104
105
  if (error instanceof Error) {
105
106
  this.process.stderr.write(`An unhandled ${error.name} occurred: ${error.message}\n`);
106
- this.process.stderr.write(error.stack?.toString() || "(no call stack)\n");
107
+ this.process.stderr.write(error.stack?.toString() ?? "(no call stack)\n");
107
108
  }
108
109
  return false;
109
110
  }
@@ -18,6 +18,6 @@ import TestName from "./TestName";
18
18
  */
19
19
  export default function Test(test_name?: string) {
20
20
  return function (suite: TestSuite, method_name: string, info: TestInfo) {
21
- suite.addTest(test_name || TestName.toSentenceCase(method_name), info);
21
+ suite.addTest(test_name ?? TestName.toSentenceCase(method_name), info);
22
22
  };
23
23
  }
@@ -33,6 +33,9 @@ export default abstract class TestSuite {
33
33
  }
34
34
 
35
35
  filteredTests(filters: RegExp[]) {
36
+ if (!this.tests)
37
+ return {};
38
+
36
39
  const filtered: Record<string, TestInfo> = {};
37
40
  const keys = Object.keys(this.tests).filter(k => filters.map(f => f.test(`${this.constructor.name}.${this.tests[k].value?.name}`)).filter(m => m).length > 0);
38
41
  keys.forEach(k => {
@@ -6,8 +6,10 @@ export default class FileSystem {
6
6
  constructor(private readonly fs: typeof fs_promises) {
7
7
  }
8
8
 
9
+ private static readonly matchExtension: RegExp = new RegExp(/\.(\w+)$/);
10
+
9
11
  static extension(file: string) {
10
- const match = file.match(/\.(\w+)$/);
12
+ const match = this.matchExtension.exec(file);
11
13
  return match !== undefined && match !== null && match.length > 1
12
14
  ? match[1]
13
15
  : "";
@@ -70,7 +70,7 @@ export default class ConsoleReporter implements ResultReporter {
70
70
 
71
71
  const sum = (result_type?: ResultType) => results
72
72
  .map((suite_result) => result_type !== undefined ? suite_result.count(result_type) : suite_result.total())
73
- .reduce((acc, current) => acc + current);
73
+ .reduce((acc, current) => acc + current, 0);
74
74
 
75
75
  const result = (result_type?: ResultType, color: (string: string) => string = colors.white) => {
76
76
  const count = sum(result_type).toString();