xunit.ts 0.13.1 → 1.0.3
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/.editorconfig +26 -0
- package/.eslintrc.json +37 -0
- package/README.md +2 -1
- package/SECURITY.md +11 -0
- package/cli.ts +6 -5
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/src/Assertions/Contains.js +1 -1
- package/dist/src/Assertions/Contains.js.map +1 -1
- package/dist/src/Assertions/Count.js.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.js +1 -1
- package/dist/src/Assertions/DoesNotContain.js.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.js +1 -1
- package/dist/src/Assertions/Empty.js.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.js +1 -1
- 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 +1 -1
- package/dist/src/Assertions/InstanceOf.js.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.js +2 -2
- package/dist/src/Assertions/NotEqual.js.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.js +1 -1
- package/dist/src/Assertions/Null.js.map +1 -1
- package/dist/src/Assertions/StringContains.d.ts.map +1 -1
- package/dist/src/Assertions/StringContains.js +2 -2
- package/dist/src/Assertions/StringContains.js.map +1 -1
- package/dist/src/Assertions/StringDoesNotContain.d.ts.map +1 -1
- package/dist/src/Assertions/StringDoesNotContain.js +1 -1
- 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 +4 -2
- package/dist/src/Assertions/StringDoesNotEndWith.js.map +1 -1
- package/dist/src/Assertions/StringDoesNotStartWith.d.ts.map +1 -1
- package/dist/src/Assertions/StringDoesNotStartWith.js +1 -1
- 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 +4 -2
- package/dist/src/Assertions/StringEndsWith.js.map +1 -1
- package/dist/src/Assertions/StringStartsWith.d.ts.map +1 -1
- package/dist/src/Assertions/StringStartsWith.js +1 -1
- package/dist/src/Assertions/StringStartsWith.js.map +1 -1
- package/dist/src/Assertions/Throws.js +1 -1
- package/dist/src/Assertions/Throws.js.map +1 -1
- package/dist/src/Assertions/True.js +1 -1
- package/dist/src/Assertions/True.js.map +1 -1
- package/dist/src/Assertions/Undefined.js +1 -1
- package/dist/src/Assertions/Undefined.js.map +1 -1
- package/dist/src/Assertions/index.d.ts +22 -22
- package/dist/src/Assertions/index.d.ts.map +1 -1
- package/dist/src/Assertions/index.js.map +1 -1
- package/dist/src/CLI.d.ts +4 -1
- package/dist/src/CLI.d.ts.map +1 -1
- package/dist/src/CLI.js +10 -8
- package/dist/src/CLI.js.map +1 -1
- package/dist/src/Factory.d.ts +5 -4
- package/dist/src/Factory.d.ts.map +1 -1
- package/dist/src/Factory.js +4 -4
- package/dist/src/Factory.js.map +1 -1
- package/dist/src/Framework/ResultType.d.ts.map +1 -1
- package/dist/src/Framework/ResultType.js.map +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/TestName.d.ts.map +1 -1
- package/dist/src/Framework/TestName.js.map +1 -1
- package/dist/src/Framework/TestResult.d.ts.map +1 -1
- package/dist/src/Framework/TestResult.js.map +1 -1
- package/dist/src/Framework/TestSuite.d.ts +1 -1
- package/dist/src/Framework/TestSuite.d.ts.map +1 -1
- package/dist/src/Framework/TestSuite.js.map +1 -1
- package/dist/src/Framework/TestSuiteResults.d.ts +1 -1
- package/dist/src/Framework/TestSuiteResults.d.ts.map +1 -1
- package/dist/src/Framework/TestSuiteResults.js.map +1 -1
- package/dist/src/IO/FileSystem.d.ts +2 -2
- package/dist/src/IO/FileSystem.d.ts.map +1 -1
- package/dist/src/IO/FileSystem.js +6 -6
- package/dist/src/IO/FileSystem.js.map +1 -1
- package/dist/src/IO/Output.d.ts.map +1 -1
- package/dist/src/IO/Output.js.map +1 -1
- package/dist/src/Reporters/ConsoleReporter.d.ts.map +1 -1
- package/dist/src/Reporters/ConsoleReporter.js +8 -7
- package/dist/src/Reporters/ConsoleReporter.js.map +1 -1
- package/dist/src/Reporters/FileReporter.d.ts.map +1 -1
- package/dist/src/Reporters/FileReporter.js +1 -0
- package/dist/src/Reporters/FileReporter.js.map +1 -1
- package/dist/src/Reporters/JUnitReporter.d.ts +2 -2
- package/dist/src/Reporters/JUnitReporter.d.ts.map +1 -1
- package/dist/src/Reporters/JUnitReporter.js +7 -7
- package/dist/src/Reporters/JUnitReporter.js.map +1 -1
- package/dist/src/Reporters/ResultReporter.d.ts +3 -3
- package/dist/src/Reporters/ResultReporter.d.ts.map +1 -1
- package/dist/src/Reporters/SonarReporter.d.ts +2 -2
- package/dist/src/Reporters/SonarReporter.d.ts.map +1 -1
- package/dist/src/Reporters/SonarReporter.js +16 -16
- package/dist/src/Reporters/SonarReporter.js.map +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 +5 -5
- package/dist/src/Runners/Runner.js.map +1 -1
- package/dist/src/Runners/TestRunner.d.ts +4 -4
- package/dist/src/Runners/TestRunner.d.ts.map +1 -1
- package/dist/src/Runners/TestRunner.js +10 -9
- package/dist/src/Runners/TestRunner.js.map +1 -1
- package/dist/src/Runners/TestSuiteLoader.d.ts +3 -3
- package/dist/src/Runners/TestSuiteLoader.d.ts.map +1 -1
- package/dist/src/Runners/TestSuiteLoader.js +15 -15
- package/dist/src/Runners/TestSuiteLoader.js.map +1 -1
- package/dist/src/Runners/TestSuiteRunner.d.ts +5 -5
- package/dist/src/Runners/TestSuiteRunner.d.ts.map +1 -1
- package/dist/src/Runners/TestSuiteRunner.js +1 -1
- package/dist/src/Runners/TestSuiteRunner.js.map +1 -1
- package/dist/xunit.d.ts +3 -3
- package/dist/xunit.d.ts.map +1 -1
- package/dist/xunit.js.map +1 -1
- package/icon.svg +82 -0
- package/logo.svg +154 -0
- package/package.json +43 -35
- package/sonar-project.properties +1 -1
- package/src/Assertions/Contains.ts +10 -10
- package/src/Assertions/Count.ts +11 -11
- package/src/Assertions/Defined.ts +11 -11
- package/src/Assertions/DoesNotContain.ts +11 -11
- package/src/Assertions/DoesNotThrow.ts +13 -13
- package/src/Assertions/Empty.ts +11 -11
- package/src/Assertions/Equal.ts +12 -12
- package/src/Assertions/False.ts +11 -11
- package/src/Assertions/InstanceOf.ts +13 -13
- package/src/Assertions/NotEmpty.ts +11 -11
- package/src/Assertions/NotEqual.ts +12 -12
- package/src/Assertions/NotNull.ts +11 -11
- package/src/Assertions/Null.ts +11 -11
- package/src/Assertions/StringContains.ts +12 -12
- package/src/Assertions/StringDoesNotContain.ts +12 -12
- package/src/Assertions/StringDoesNotEndWith.ts +14 -12
- package/src/Assertions/StringDoesNotStartWith.ts +12 -12
- package/src/Assertions/StringEndsWith.ts +14 -12
- package/src/Assertions/StringStartsWith.ts +12 -12
- package/src/Assertions/Throws.ts +11 -11
- package/src/Assertions/True.ts +11 -11
- package/src/Assertions/Undefined.ts +12 -12
- package/src/Assertions/index.ts +45 -45
- package/src/CLI.ts +85 -84
- package/src/Factory.ts +25 -25
- package/src/Framework/ResultType.ts +4 -4
- package/src/Framework/Test.ts +6 -6
- package/src/Framework/TestName.ts +7 -7
- package/src/Framework/TestResult.ts +3 -2
- package/src/Framework/TestSuite.ts +18 -18
- package/src/Framework/TestSuiteResults.ts +17 -16
- package/src/IO/FileSystem.ts +28 -29
- package/src/IO/Output.ts +21 -20
- package/src/Reporters/ConsoleReporter.ts +88 -87
- package/src/Reporters/FileReporter.ts +29 -29
- package/src/Reporters/JUnitReporter.ts +80 -80
- package/src/Reporters/ResultReporter.ts +20 -12
- package/src/Reporters/SonarReporter.ts +86 -86
- package/src/Reporters/XMLReporter.ts +6 -6
- package/src/Runners/Runner.ts +21 -21
- package/src/Runners/TestRunner.ts +34 -32
- package/src/Runners/TestSuiteLoader.ts +41 -40
- package/src/Runners/TestSuiteRunner.ts +27 -26
- package/tsconfig.json +26 -24
- package/xunit.ts +6 -6
|
@@ -2,27 +2,27 @@ import { AssertionError } from "assert";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Asserts that a string does not contain a given substring
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* @remarks
|
|
7
7
|
* Passes if `needle` is not a substring of `haystack`
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* Fails if `needle` is a substring of `haystack`
|
|
10
10
|
*
|
|
11
11
|
* @param needle the substring to find
|
|
12
12
|
* @param haystack the string to search
|
|
13
13
|
* @param message (optional) message to display on failure
|
|
14
|
-
*
|
|
14
|
+
*
|
|
15
15
|
* @example
|
|
16
16
|
* this.assert.stringDoesNotContain(needle, haystack);
|
|
17
17
|
*/
|
|
18
|
-
export default function StringDoesNotContain(needle: string, haystack: string|null, message?: string) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
export default function StringDoesNotContain(needle: string, haystack: string | null, message?: string) {
|
|
19
|
+
if (haystack === undefined || haystack === null || haystack.indexOf(needle) === -1) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
throw new AssertionError({
|
|
24
|
+
message: message || "Expected string not containing expression, but string did contain expression",
|
|
25
|
+
expected: needle,
|
|
26
|
+
actual: haystack
|
|
27
|
+
});
|
|
28
28
|
}
|
|
@@ -2,27 +2,29 @@ import { AssertionError } from "assert";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Asserts that a string does not end with a given substring
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* @remarks
|
|
7
7
|
* Passes if the final characters of `haystack` do not match `needle`
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* Fails if the final characters of `haystack` match `needle`
|
|
10
10
|
*
|
|
11
11
|
* @param needle the substring to find
|
|
12
12
|
* @param haystack the string to search
|
|
13
13
|
* @param message (optional) message to display on failure
|
|
14
|
-
*
|
|
14
|
+
*
|
|
15
15
|
* @example
|
|
16
16
|
* this.assert.stringDoesNotEndWith(needle, haystack);
|
|
17
17
|
*/
|
|
18
|
-
export default function StringDoesNotEndWith(needle: string, haystack: string|null, message?: string) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
export default function StringDoesNotEndWith(needle: string, haystack: string | null, message?: string) {
|
|
19
|
+
if (haystack === undefined || haystack === null
|
|
20
|
+
|| haystack.indexOf(needle) === -1
|
|
21
|
+
|| haystack.indexOf(needle) !== haystack.length - needle.length) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
throw new AssertionError({
|
|
26
|
+
message: message || "Expected string containing expression, but string did not contain expression",
|
|
27
|
+
expected: needle,
|
|
28
|
+
actual: haystack
|
|
29
|
+
});
|
|
28
30
|
}
|
|
@@ -2,27 +2,27 @@ import { AssertionError } from "assert";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Asserts that a string does not begin with a given substring
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* @remarks
|
|
7
7
|
* Passes if the first characters of `haystack` do not match `needle`
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* Fails if the first characters of `haystack` match `needle`
|
|
10
10
|
*
|
|
11
11
|
* @param needle the substring to find
|
|
12
12
|
* @param haystack the string to search
|
|
13
13
|
* @param message (optional) message to display on failure
|
|
14
|
-
*
|
|
14
|
+
*
|
|
15
15
|
* @example
|
|
16
16
|
* this.assert.stringDoesNotStartWith(needle, haystack);
|
|
17
17
|
*/
|
|
18
|
-
export default function StringDoesNotStartWith(needle: string, haystack: string|null, message?: string) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
export default function StringDoesNotStartWith(needle: string, haystack: string | null, message?: string) {
|
|
19
|
+
if (haystack === undefined || haystack === null || haystack.indexOf(needle) !== 0) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
throw new AssertionError({
|
|
24
|
+
message: message || "Expected string containing expression, but string did not contain expression",
|
|
25
|
+
expected: needle,
|
|
26
|
+
actual: haystack
|
|
27
|
+
});
|
|
28
28
|
}
|
|
@@ -2,27 +2,29 @@ import { AssertionError } from "assert";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Asserts that a string ends with a given substring
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* @remarks
|
|
7
7
|
* Passes if the final characters of `haystack` match `needle`
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* Fails if the final characters of `haystack` do not match `needle`
|
|
10
10
|
*
|
|
11
11
|
* @param needle the substring to find
|
|
12
12
|
* @param haystack the string to search
|
|
13
13
|
* @param message (optional) message to display on failure
|
|
14
|
-
*
|
|
14
|
+
*
|
|
15
15
|
* @example
|
|
16
16
|
* this.assert.stringEndsWith(needle, haystack);
|
|
17
17
|
*/
|
|
18
|
-
export default function StringEndsWith(needle: string, haystack: string|null, message?: string) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
export default function StringEndsWith(needle: string, haystack: string | null, message?: string) {
|
|
19
|
+
if (haystack !== undefined && haystack !== null
|
|
20
|
+
&& haystack.indexOf(needle) > -1
|
|
21
|
+
&& haystack.indexOf(needle) === haystack.length - needle.length) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
throw new AssertionError({
|
|
26
|
+
message: message || "Expected string containing expression, but string did not contain expression",
|
|
27
|
+
expected: needle,
|
|
28
|
+
actual: haystack
|
|
29
|
+
});
|
|
28
30
|
}
|
|
@@ -2,27 +2,27 @@ import { AssertionError } from "assert";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Asserts that a string begins with a given substring
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* @remarks
|
|
7
7
|
* Passes if the first characters of `haystack` match `needle`
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* Fails if the first characters of `haystack` do not match `needle`
|
|
10
10
|
*
|
|
11
11
|
* @param needle the substring to find
|
|
12
12
|
* @param haystack the string to search
|
|
13
13
|
* @param message (optional) message to display on failure
|
|
14
|
-
*
|
|
14
|
+
*
|
|
15
15
|
* @example
|
|
16
16
|
* this.assert.stringStartsWith(needle, haystack);
|
|
17
17
|
*/
|
|
18
|
-
export default function StringStartsWith(needle: string, haystack: string|null, message?: string) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
export default function StringStartsWith(needle: string, haystack: string | null, message?: string) {
|
|
19
|
+
if (haystack !== undefined && haystack !== null && haystack.indexOf(needle) === 0) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
throw new AssertionError({
|
|
24
|
+
message: message || "Expected string containing expression, but string did not contain expression",
|
|
25
|
+
expected: needle,
|
|
26
|
+
actual: haystack
|
|
27
|
+
});
|
|
28
28
|
}
|
package/src/Assertions/Throws.ts
CHANGED
|
@@ -2,26 +2,26 @@ import { AssertionError } from "assert";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Asserts that an expression throws an error/exception
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* @remarks
|
|
7
7
|
* Passes if calling `expression` throws an error/exception
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* Fails if calling `expression` does not throw an error/exception
|
|
10
10
|
*
|
|
11
11
|
* @param expression the expression to run
|
|
12
12
|
* @param message (optional) message to display on failure
|
|
13
|
-
*
|
|
13
|
+
*
|
|
14
14
|
* @example
|
|
15
15
|
* this.assert.throws(() => expression);
|
|
16
16
|
*/
|
|
17
17
|
export default function Throws(expression: () => any, message?: string) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
try {
|
|
19
|
+
expression();
|
|
20
|
+
} catch (exception) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
throw new AssertionError({
|
|
25
|
+
message: message || "Expected expression to throw exception, but expression did not throw exception"
|
|
26
|
+
});
|
|
27
27
|
}
|
package/src/Assertions/True.ts
CHANGED
|
@@ -2,12 +2,12 @@ import { AssertionError } from "assert";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Asserts that a given expression evaluates to `true`
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* @remarks
|
|
7
7
|
* Passes if `expression` evaluates to `true`
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* Fails if `expression` does not evaluate to `true`
|
|
10
|
-
*
|
|
10
|
+
*
|
|
11
11
|
* @param expression the value to check
|
|
12
12
|
* @param message (optional) message to display on failure
|
|
13
13
|
*
|
|
@@ -15,13 +15,13 @@ import { AssertionError } from "assert";
|
|
|
15
15
|
* this.assert.true(expression);
|
|
16
16
|
*/
|
|
17
17
|
export default function True(expression: any, message?: string) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
if (expression === true) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
throw new AssertionError({
|
|
23
|
+
message: message || "Expected expression to be true, but expression is not true",
|
|
24
|
+
expected: true,
|
|
25
|
+
actual: expression
|
|
26
|
+
});
|
|
27
27
|
}
|
|
@@ -2,26 +2,26 @@ import { AssertionError } from "assert";
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Asserts that a given value is equal to `undefined`
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* @remarks
|
|
7
7
|
* Passes if `expression` evaluates to `undefined`
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* Fails if `expression` does not evaluate to `undefined`
|
|
10
|
-
*
|
|
10
|
+
*
|
|
11
11
|
* @param expression the value to check
|
|
12
12
|
* @param message (optional) message to display on failure
|
|
13
|
-
*
|
|
13
|
+
*
|
|
14
14
|
* @example
|
|
15
15
|
* this.assert.undefined(expression);
|
|
16
16
|
*/
|
|
17
17
|
export default function Undefined(expression: any, message?: string) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
if (expression === undefined) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
throw new AssertionError({
|
|
23
|
+
message: message || "Expected expression to be undefined, but expression is not undefined",
|
|
24
|
+
expected: undefined,
|
|
25
|
+
actual: expression
|
|
26
|
+
});
|
|
27
27
|
}
|
package/src/Assertions/index.ts
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
import is_true from
|
|
2
|
-
import is_false from
|
|
1
|
+
import is_true from "./True";
|
|
2
|
+
import is_false from "./False";
|
|
3
3
|
|
|
4
|
-
import is_undefined from
|
|
5
|
-
import is_defined from
|
|
4
|
+
import is_undefined from "./Undefined";
|
|
5
|
+
import is_defined from "./Defined";
|
|
6
6
|
|
|
7
|
-
import is_null from
|
|
8
|
-
import not_null from
|
|
7
|
+
import is_null from "./Null";
|
|
8
|
+
import not_null from "./NotNull";
|
|
9
9
|
|
|
10
|
-
import equal from
|
|
11
|
-
import not_equal from
|
|
10
|
+
import equal from "./Equal";
|
|
11
|
+
import not_equal from "./NotEqual";
|
|
12
12
|
|
|
13
|
-
import empty from
|
|
14
|
-
import not_empty from
|
|
13
|
+
import empty from "./Empty";
|
|
14
|
+
import not_empty from "./NotEmpty";
|
|
15
15
|
|
|
16
|
-
import count from
|
|
16
|
+
import count from "./Count";
|
|
17
17
|
|
|
18
|
-
import contains from
|
|
19
|
-
import not_contains from
|
|
18
|
+
import contains from "./Contains";
|
|
19
|
+
import not_contains from "./DoesNotContain";
|
|
20
20
|
|
|
21
|
-
import string_contains from
|
|
22
|
-
import string_not_contains from
|
|
21
|
+
import string_contains from "./StringContains";
|
|
22
|
+
import string_not_contains from "./StringDoesNotContain";
|
|
23
23
|
|
|
24
|
-
import string_starts from
|
|
25
|
-
import string_not_starts from
|
|
24
|
+
import string_starts from "./StringStartsWith";
|
|
25
|
+
import string_not_starts from "./StringDoesNotStartWith";
|
|
26
26
|
|
|
27
|
-
import string_ends from
|
|
28
|
-
import string_not_ends from
|
|
27
|
+
import string_ends from "./StringEndsWith";
|
|
28
|
+
import string_not_ends from "./StringDoesNotEndWith";
|
|
29
29
|
|
|
30
|
-
import instance_of from
|
|
30
|
+
import instance_of from "./InstanceOf";
|
|
31
31
|
|
|
32
|
-
import throws from
|
|
33
|
-
import does_not_throw from
|
|
32
|
+
import throws from "./Throws";
|
|
33
|
+
import does_not_throw from "./DoesNotThrow";
|
|
34
34
|
|
|
35
35
|
export default new class AssertionLibrary {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
true = is_true;
|
|
37
|
+
false = is_false;
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
undefined = is_undefined;
|
|
40
|
+
defined = is_defined;
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
null = is_null;
|
|
43
|
+
notNull = not_null;
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
equal = equal;
|
|
46
|
+
notEqual = not_equal;
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
empty = empty;
|
|
49
|
+
notEmpty = not_empty;
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
count = count;
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
contains = contains;
|
|
54
|
+
doesNotContain = not_contains;
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
stringContains = string_contains;
|
|
57
|
+
stringDoesNotContain = string_not_contains;
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
stringStartsWith = string_starts;
|
|
60
|
+
stringDoesNotStartWIth = string_not_starts;
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
stringEndsWith = string_ends;
|
|
63
|
+
stringDoesNotEndWith = string_not_ends;
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
instanceOf = instance_of;
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
67
|
+
throws = throws;
|
|
68
|
+
doesNotThrow = does_not_throw;
|
|
69
|
+
};
|
package/src/CLI.ts
CHANGED
|
@@ -1,98 +1,99 @@
|
|
|
1
|
-
import Usage from
|
|
2
|
-
import JUnitReporter from
|
|
1
|
+
import Usage from "command-line-usage";
|
|
2
|
+
import JUnitReporter from "./Reporters/JUnitReporter";
|
|
3
3
|
import Process from "process";
|
|
4
4
|
import Args from "command-line-args";
|
|
5
|
-
import Factory from "./Factory";
|
|
6
5
|
import Runner from "./Runners/Runner";
|
|
7
6
|
import SonarReporter from "./Reporters/SonarReporter";
|
|
8
7
|
|
|
9
8
|
export default class CLI {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
9
|
+
private static readonly options: Usage.OptionDefinition[] = [
|
|
10
|
+
{
|
|
11
|
+
name: "dir",
|
|
12
|
+
alias: "d",
|
|
13
|
+
type: String,
|
|
14
|
+
defaultOption: true,
|
|
15
|
+
typeLabel: "<directory>",
|
|
16
|
+
description: "The path where tests to run are located (-d/--dir flag optional)"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "junit",
|
|
20
|
+
alias: "j",
|
|
21
|
+
type: String,
|
|
22
|
+
typeLabel: `[filename] (${JUnitReporter.defaultFileName})`,
|
|
23
|
+
description: "Save results as JUnit-formatted XML"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "sonar",
|
|
27
|
+
alias: "s",
|
|
28
|
+
type: String,
|
|
29
|
+
typeLabel: `[filename] (${SonarReporter.defaultFileName})`,
|
|
30
|
+
description: "Save results as SonarQube/SonarCloud-formatted XML"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "quiet",
|
|
34
|
+
alias: "q",
|
|
35
|
+
type: Boolean,
|
|
36
|
+
description: "Do not print test results to stdout"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "help",
|
|
40
|
+
alias: "h",
|
|
41
|
+
type: Boolean,
|
|
42
|
+
description: "Display this help page (and ignore all other options)"
|
|
43
|
+
}
|
|
44
|
+
];
|
|
46
45
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
46
|
+
private static readonly sections: Usage.Section[] = [
|
|
47
|
+
{
|
|
48
|
+
header: "xunit.ts",
|
|
49
|
+
content: "A TypeScript unit testing framework, following standard xUnit patterns"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
header: "Usage",
|
|
53
|
+
content: [
|
|
54
|
+
"<npm run | yarn> xunit [-j|--junit [filename]] [-s|--sonar [filename]]",
|
|
55
|
+
"[-q|--quiet] [-d|--dir] <directory>"
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
header: "Examples",
|
|
60
|
+
content: [
|
|
61
|
+
"npm run xunit dist/tests",
|
|
62
|
+
"yarn xunit --junit results.xml --dir dist/tests --quiet",
|
|
63
|
+
"yarn xunit -q -s -d dist/tests"
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
header: "Options",
|
|
68
|
+
optionList: CLI.options
|
|
69
|
+
}
|
|
70
|
+
];
|
|
72
71
|
|
|
73
|
-
|
|
72
|
+
private static readonly usage = Usage(CLI.sections);
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
constructor(private readonly runnerFactory: (args: Args.CommandLineOptions) => Runner, private readonly process: typeof Process) {
|
|
75
|
+
}
|
|
77
76
|
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
async run(): Promise<boolean> {
|
|
78
|
+
const args = Args(CLI.options, { argv: this.process.argv });
|
|
80
79
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
if (args.help) {
|
|
81
|
+
this.process.stdout.write(CLI.usage);
|
|
82
|
+
this.process.stdout.write("\n");
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
86
85
|
|
|
87
|
-
|
|
86
|
+
const runner = this.runnerFactory(args);
|
|
88
87
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
88
|
+
try {
|
|
89
|
+
const results = await runner.runAll(args.dir);
|
|
90
|
+
return Runner.allTestsPassed(results);
|
|
91
|
+
} catch (error) {
|
|
92
|
+
if (error instanceof Error) {
|
|
93
|
+
this.process.stderr.write(`An unhandled ${error.name} occurred: ${error.message}\n`);
|
|
94
|
+
this.process.stderr.write(error.stack?.toString() || "(no call stack)\n");
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
98
99
|
}
|