Skip to content

Commit

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

### Performance

## 27.0.3

### Fixes

- `[jest-mock]` Fixed `fn` and `spyOn` exports ([]())

## 27.0.2

### Features
Expand Down
9 changes: 8 additions & 1 deletion packages/jest-mock/src/__tests__/index.test.ts
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
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 de88dd8

Please sign in to comment.