Skip to content

Commit dce5bfa

Browse files
committed
test(cli): handle CRLF in test fixture files
On Windows, files are normally checked-out with `git config core.autocrlf true`, which will replace `'\n'`/LF chars with `'\r\n'`/CRLF chars. We should handle this in our unit tests, otherwise tests will fail on Windows CI.
1 parent 79451c1 commit dce5bfa

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/cli/src/commander.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,10 @@ describe('link', () => {
390390
expect(file).toMatch(idLineRegex);
391391
// other than the added `id: xxxx` field, everything else should be identical,
392392
// although in practice, we'd expect some formatting changes
393-
expect(file.replace(idLineRegex, '')).toStrictEqual(
394-
await readFile(UNUSUAL_MARKDOWN_FILE, { encoding: 'utf8' }),
393+
//
394+
// We also normalize line endings to LF to avoid issues with CRLF on Windows
395+
expect(file.replace(idLineRegex, '').replaceAll('\r\n', '\n')).toStrictEqual(
396+
(await readFile(UNUSUAL_MARKDOWN_FILE, { encoding: 'utf8' })).replaceAll('\r\n', '\n'),
395397
);
396398
});
397399
});

0 commit comments

Comments
 (0)