Skip to content

Commit

Permalink
fix: Fix jest-mock fn and spyOn. (#11480)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpojer authored May 29, 2021
1 parent e9802d3 commit 50d590a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

### Performance

## 27.0.3

### Fixes

- `[jest-mock]` Fixed `fn` and `spyOn` exports ([#11480](https://github.com/facebook/jest/pull/11480))

## 27.0.2

### Features
Expand Down
9 changes: 8 additions & 1 deletion packages/jest-mock/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/* eslint-disable local/ban-types-eventually, local/prefer-rest-params-eventually */

import vm, {Context} from 'vm';
import {ModuleMocker} from '../';
import {ModuleMocker, fn, spyOn} from '../';

describe('moduleMocker', () => {
let moduleMocker: ModuleMocker;
Expand Down Expand Up @@ -1439,3 +1439,10 @@ describe('moduleMocker', () => {
});
});
});

test('`fn` and `spyOn` do not throw', () => {
expect(() => {
fn();
spyOn({apple: () => {}}, 'apple');
}).not.toThrow();
});
4 changes: 2 additions & 2 deletions packages/jest-mock/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1112,5 +1112,5 @@ export class ModuleMocker {

const JestMock = new ModuleMocker(global);

export const fn = JestMock.fn;
export const spyOn = JestMock.spyOn;
export const fn = JestMock.fn.bind(JestMock);
export const spyOn = JestMock.spyOn.bind(JestMock);

0 comments on commit 50d590a

Please sign in to comment.