diff --git a/jest.config.cjs b/jest.config.cjs index f0111b9..b321edd 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -6,6 +6,8 @@ const jestConfig = { preset: 'ts-jest/presets/default-esm', testEnvironment: 'node', testMatch: ['/test/**/*-test.ts'], + globalSetup: '/test/jest.setup.cjs', + globalTeardown: '/test/jest.teardown.cjs', transform: { '^.+\\.tsx?$': ['ts-jest', { useESM: true }], }, diff --git a/test/jest.setup.cjs b/test/jest.setup.cjs new file mode 100644 index 0000000..76e999e --- /dev/null +++ b/test/jest.setup.cjs @@ -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. +}; diff --git a/test/jest.teardown.cjs b/test/jest.teardown.cjs new file mode 100644 index 0000000..69d0f9b --- /dev/null +++ b/test/jest.teardown.cjs @@ -0,0 +1,3 @@ +module.exports = function () { + globalThis.eolStub.restore(); +};