diff options
| author | eric sciple <ericsciple@users.noreply.github.com> | 2020-02-13 13:25:46 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-13 13:25:46 -0500 |
| commit | aa53c9e2635a2ba1a74f58631719ad73c5ded361 (patch) | |
| tree | 7608dddd2273528080f9bcc135d064cc001548de /__test__/retry-helper.test.ts | |
| parent | 68e277f20178a549b370dd1ba2f3d8200cbe252f (diff) | |
switch to spyOn for mocks (#152)
Diffstat (limited to '__test__/retry-helper.test.ts')
| -rw-r--r-- | __test__/retry-helper.test.ts | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/__test__/retry-helper.test.ts b/__test__/retry-helper.test.ts index 8c424cf..6f8e027 100644 --- a/__test__/retry-helper.test.ts +++ b/__test__/retry-helper.test.ts @@ -1,18 +1,17 @@ -const mockCore = jest.genMockFromModule('@actions/core') as any -mockCore.info = (message: string) => { - info.push(message) -} +import * as core from '@actions/core' +import {RetryHelper} from '../lib/retry-helper' + let info: string[] let retryHelper: any describe('retry-helper tests', () => { beforeAll(() => { - // Mocks - jest.setMock('@actions/core', mockCore) + // Mock @actions/core info() + jest.spyOn(core, 'info').mockImplementation((message: string) => { + info.push(message) + }) - // Now import - const retryHelperModule = require('../lib/retry-helper') - retryHelper = new retryHelperModule.RetryHelper(3, 0, 0) + retryHelper = new RetryHelper(3, 0, 0) }) beforeEach(() => { @@ -21,8 +20,8 @@ describe('retry-helper tests', () => { }) afterAll(() => { - // Reset modules - jest.resetModules() + // Restore + jest.restoreAllMocks() }) it('first attempt succeeds', async () => { |
