Skip to content

Commit

Permalink
fix(tests): more sanitizing for windows compat
Browse files Browse the repository at this point in the history
  • Loading branch information
huafu committed Aug 8, 2018
1 parent 683a1e5 commit faae274
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
11 changes: 9 additions & 2 deletions e2e/__helpers__/test-case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ export default function configureTestCase(
return new TestCaseRunDescriptor(name, options);
}

const PASS_MARKS = ['✓', '√'];
const FAIL_MARKS = ['✕', '×'];
const normalizeTestMark = (mark: string): string => {
if (PASS_MARKS.includes(mark)) return 'P'; // tslint:disable-line
if (FAIL_MARKS.includes(mark)) return 'F'; // tslint:disable-line
return '?';
};
export function sanitizeOutput(output: string): string {
let out: string = output
.trim()
Expand All @@ -141,8 +148,8 @@ export function sanitizeOutput(output: string): string {
)
// removes each test time values
.replace(
/^(\s*(?:✕|×|✓|√)\s+.+\s+\()[\d.]+m?s(\)\s*)$/gm,
(_, start, end) => `${start}XXms${end}`,
/^(\s*)(✕|×|✓|√)(\s+[^\(]+)(\s+\([\d.]+m?s\))?$/gm,
(_, start, mark, mid, time) => `${start}${normalizeTestMark(mark)}${mid}`,
);
// TODO: improves this...
if (process.platform === 'win32') {
Expand Down
6 changes: 3 additions & 3 deletions e2e/__tests__/__snapshots__/simple.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Object {
===[ STDERR ]===================================================================
PASS __tests__/Hello.test.ts
Hello Class
should create a new Hello (XXms)
P should create a new Hello
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Expand All @@ -22,7 +22,7 @@ Object {
===[ STDERR ]===================================================================
PASS __tests__/Hello.test.ts
Hello Class
should create a new Hello (XXms)
P should create a new Hello
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Expand All @@ -36,7 +36,7 @@ Object {
===[ STDERR ]===================================================================
PASS __tests__/Hello.test.ts
Hello Class
should create a new Hello (XXms)
P should create a new Hello
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Expand Down
12 changes: 6 additions & 6 deletions e2e/__tests__/__snapshots__/source-map.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Object {
===[ STDERR ]===================================================================
FAIL test/echo.spec.ts
echo
echoes (XXms)
F echoes
echoechoes
Expand Down Expand Up @@ -45,7 +45,7 @@ Object {
===[ STDERR ]===================================================================
FAIL test/echo.spec.ts
echo
echoes (XXms)
F echoes
● echo › echoes
Expand Down Expand Up @@ -78,7 +78,7 @@ Object {
===[ STDERR ]===================================================================
FAIL test/echo.spec.ts
echo
echoes (XXms)
F echoes
● echo › echoes
Expand Down Expand Up @@ -115,7 +115,7 @@ Object {
===[ STDERR ]===================================================================
PASS test/echo.spec.ts
echo
echoes (XXms)
P echoes
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Expand All @@ -133,7 +133,7 @@ Object {
===[ STDERR ]===================================================================
PASS test/echo.spec.ts
echo
echoes (XXms)
P echoes
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Expand All @@ -151,7 +151,7 @@ Object {
===[ STDERR ]===================================================================
PASS test/echo.spec.ts
echo
echoes (XXms)
P echoes
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Expand Down

0 comments on commit faae274

Please sign in to comment.