Skip to content

Commit

Permalink
fix cli tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-nUUb committed May 22, 2023
1 parent 0d6fe49 commit 92ca6ae
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/oloco/src/cli.test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
const argvBackup = process.argv
const consoleSpy = jest.spyOn(console, 'log').mockImplementation()
const exitSpy = jest.spyOn(process, 'exit').mockImplementation()
let argvBackup: string[]
let consoleSpy: jest.SpyInstance
let exitSpy: jest.SpyInstance

async function runCmd(...args: string[]) {
process.argv = ['ts-node', 'cli.ts', ...args]
return require('./cli')
}

describe('cli', () => {
beforeAll(() => {
argvBackup = process.argv
consoleSpy = jest.spyOn(console, 'log').mockImplementation()
exitSpy = jest.spyOn(process, 'exit').mockImplementation()
})

beforeEach(() => {
jest.resetAllMocks()
jest.clearAllMocks()
jest.resetModules()
})

afterEach(() => {
afterAll(() => {
jest.resetAllMocks()
jest.restoreAllMocks()
process.argv = argvBackup
})

Expand Down

0 comments on commit 92ca6ae

Please # to comment.