Skip to content

Commit

Permalink
Polyfill process.exitCode for Node.js < v20
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSurgisonGDS committed Nov 1, 2023
1 parent 6f80560 commit 4626a91
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/plugins/plugin-validator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ describe('plugin-validator', () => {
const validSuccessMessages = phaseOneSuccessMessages.concat([ansiColors.green('The plugin config is valid.')])

beforeEach(() => {
// Polyfill process.exitCode property for Node.js < v20
if (!process.exitCode) {
Object.defineProperty(process, 'exitCode', {
get: jest.fn(),
set: jest.fn()
})
}
const mockFileSystemRoot = path.join(process.cwd(), 'example-plugin')
const exitCodeSetterSpy = jest.spyOn(process, 'exitCode', 'set').mockImplementation(() => {})
testScope = {
Expand Down Expand Up @@ -42,6 +49,8 @@ describe('plugin-validator', () => {

afterEach(() => {
jest.clearAllMocks()
// Clear Polyfill process.exitCode property for Node.js < v20
process.exitCode = undefined
})

describe('unexpected keys', () => {
Expand Down

0 comments on commit 4626a91

Please sign in to comment.