Skip to content

Commit faae274

Browse files
committed
fix(tests): more sanitizing for windows compat
1 parent 683a1e5 commit faae274

3 files changed

Lines changed: 18 additions & 11 deletions

File tree

e2e/__helpers__/test-case.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ export default function configureTestCase(
129129
return new TestCaseRunDescriptor(name, options);
130130
}
131131

132+
const PASS_MARKS = ['✓', '√'];
133+
const FAIL_MARKS = ['✕', '×'];
134+
const normalizeTestMark = (mark: string): string => {
135+
if (PASS_MARKS.includes(mark)) return 'P'; // tslint:disable-line
136+
if (FAIL_MARKS.includes(mark)) return 'F'; // tslint:disable-line
137+
return '?';
138+
};
132139
export function sanitizeOutput(output: string): string {
133140
let out: string = output
134141
.trim()
@@ -141,8 +148,8 @@ export function sanitizeOutput(output: string): string {
141148
)
142149
// removes each test time values
143150
.replace(
144-
/^(\s*(?:|×||)\s+.+\s+\()[\d.]+m?s(\)\s*)$/gm,
145-
(_, start, end) => `${start}XXms${end}`,
151+
/^(\s*)(|×||)(\s+[^\(]+)(\s+\([\d.]+m?s\))?$/gm,
152+
(_, start, mark, mid, time) => `${start}${normalizeTestMark(mark)}${mid}`,
146153
);
147154
// TODO: improves this...
148155
if (process.platform === 'win32') {

e2e/__tests__/__snapshots__/simple.spec.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Object {
88
===[ STDERR ]===================================================================
99
PASS __tests__/Hello.test.ts
1010
Hello Class
11-
should create a new Hello (XXms)
11+
P should create a new Hello
1212
1313
Test Suites: 1 passed, 1 total
1414
Tests: 1 passed, 1 total
@@ -22,7 +22,7 @@ Object {
2222
===[ STDERR ]===================================================================
2323
PASS __tests__/Hello.test.ts
2424
Hello Class
25-
should create a new Hello (XXms)
25+
P should create a new Hello
2626
2727
Test Suites: 1 passed, 1 total
2828
Tests: 1 passed, 1 total
@@ -36,7 +36,7 @@ Object {
3636
===[ STDERR ]===================================================================
3737
PASS __tests__/Hello.test.ts
3838
Hello Class
39-
should create a new Hello (XXms)
39+
P should create a new Hello
4040
4141
Test Suites: 1 passed, 1 total
4242
Tests: 1 passed, 1 total

e2e/__tests__/__snapshots__/source-map.spec.ts.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Object {
1212
===[ STDERR ]===================================================================
1313
FAIL test/echo.spec.ts
1414
echo
15-
echoes (XXms)
15+
F echoes
1616
1717
echoechoes
1818
@@ -45,7 +45,7 @@ Object {
4545
===[ STDERR ]===================================================================
4646
FAIL test/echo.spec.ts
4747
echo
48-
echoes (XXms)
48+
F echoes
4949
5050
● echo › echoes
5151
@@ -78,7 +78,7 @@ Object {
7878
===[ STDERR ]===================================================================
7979
FAIL test/echo.spec.ts
8080
echo
81-
echoes (XXms)
81+
F echoes
8282
8383
● echo › echoes
8484
@@ -115,7 +115,7 @@ Object {
115115
===[ STDERR ]===================================================================
116116
PASS test/echo.spec.ts
117117
echo
118-
echoes (XXms)
118+
P echoes
119119
120120
Test Suites: 1 passed, 1 total
121121
Tests: 1 passed, 1 total
@@ -133,7 +133,7 @@ Object {
133133
===[ STDERR ]===================================================================
134134
PASS test/echo.spec.ts
135135
echo
136-
echoes (XXms)
136+
P echoes
137137
138138
Test Suites: 1 passed, 1 total
139139
Tests: 1 passed, 1 total
@@ -151,7 +151,7 @@ Object {
151151
===[ STDERR ]===================================================================
152152
PASS test/echo.spec.ts
153153
echo
154-
echoes (XXms)
154+
P echoes
155155
156156
Test Suites: 1 passed, 1 total
157157
Tests: 1 passed, 1 total

0 commit comments

Comments
 (0)