diff --git a/src/transformers/hoist-jest.spec.ts b/src/transformers/hoist-jest.spec.ts index 3d2f40dd96..55dab5be34 100644 --- a/src/transformers/hoist-jest.spec.ts +++ b/src/transformers/hoist-jest.spec.ts @@ -6,6 +6,8 @@ import * as hoist from './hoist-jest' const CODE_WITH_HOISTING = ` const foo = 'foo' console.log(foo) +jest.enableAutomock() +jest.disableAutomock() jest.mock('./foo') jest.mock('./foo/bar', () => 'bar') const func = () => { @@ -42,27 +44,29 @@ describe('hoisting', () => { it('should hoist jest mock() and unmock() statements', () => { const out = transpile(CODE_WITH_HOISTING) expect(out.outputText).toMatchInlineSnapshot(` -"jest.mock('./foo'); -jest.mock('./foo/bar', function () { return 'bar'; }); -var foo = 'foo'; -console.log(foo); -var func = function () { - jest.unmock('./foo'); - jest.mock('./bar'); - jest.mock('./bar/foo', function () { return 'foo'; }); - jest.unmock('./foo/bar'); - var bar = 'bar'; - console.log(bar); -}; -var func2 = function () { - jest.mock('./bar'); - jest.unmock('./foo/bar'); - jest.mock('./bar/foo', function () { return 'foo'; }); - jest.unmock('./foo'); - var bar = 'bar'; - console.log(bar); -}; -" -`) + "jest.enableAutomock(); + jest.disableAutomock(); + jest.mock('./foo'); + jest.mock('./foo/bar', function () { return 'bar'; }); + var foo = 'foo'; + console.log(foo); + var func = function () { + jest.unmock('./foo'); + jest.mock('./bar'); + jest.mock('./bar/foo', function () { return 'foo'; }); + jest.unmock('./foo/bar'); + var bar = 'bar'; + console.log(bar); + }; + var func2 = function () { + jest.mock('./bar'); + jest.unmock('./foo/bar'); + jest.mock('./bar/foo', function () { return 'foo'; }); + jest.unmock('./foo'); + var bar = 'bar'; + console.log(bar); + }; + " + `) }) }) diff --git a/src/transformers/hoist-jest.ts b/src/transformers/hoist-jest.ts index f2eba92cc9..034011cd3e 100644 --- a/src/transformers/hoist-jest.ts +++ b/src/transformers/hoist-jest.ts @@ -17,7 +17,7 @@ import { ConfigSet } from '../config/config-set' /** * What methods of `jest` should we hoist */ -const HOIST_METHODS = ['mock', 'unmock'] +const HOIST_METHODS = ['mock', 'unmock', 'enableAutomock', 'disableAutomock'] /** * @internal