Skip to content

Commit

Permalink
try stubbing EOL in test
Browse files Browse the repository at this point in the history
  • Loading branch information
bmish committed Apr 28, 2024
1 parent f2d1fcd commit 37561e4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const jestConfig = {
preset: 'ts-jest/presets/default-esm',
testEnvironment: 'node',
testMatch: ['<rootDir>/test/**/*-test.ts'],
globalSetup: '<rootDir>/test/jest.setup.cjs',
globalTeardown: '<rootDir>/test/jest.teardown.cjs',
transform: {
'^.+\\.tsx?$': ['ts-jest', { useESM: true }],
},
Expand Down
6 changes: 6 additions & 0 deletions test/jest.setup.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const os = require('node:os');
const sinon = require('sinon');

module.exports = function () {
globalThis.eolStub = sinon.stub(os, 'EOL').value('\n'); // Stub os.EOL to always be '\n' for testing/snapshot purposes.
};
3 changes: 3 additions & 0 deletions test/jest.teardown.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function () {
globalThis.eolStub.restore();
};

0 comments on commit 37561e4

Please sign in to comment.