How to use the jest-mock.fn function in jest-mock

To help you get started, we’ve selected a few jest-mock examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github conveyal / analysis-ui / lib / components / __tests__ / edit-region.js View on Github external
it('renders correctly', () => {
    const props = {
      region: mockRegion,
      save: mock.fn(),
      load: mock.fn(),
      create: mock.fn(),
      deleteRegion: mock.fn(),
      setLocally: mock.fn(),
      setCenter: mock.fn()
    }

    // mount component
    const {snapshot} = mockWithProvider()
    expect(snapshot()).toMatchSnapshot()
    const noCalls = [
      'save',
      'load',
      'setLocally',
      'setCenter'
    ]
    noCalls.forEach(fn => {
      expect(props[fn]).not.toBeCalled()
github kinvolk / nebraska / frontend / src / js / __tests__ / Applications / ApplicationItemGroupItem.spec.js View on Github external
import { MuiThemeProvider } from '@material-ui/core/styles';
import { getByText, render, waitForDomChange } from '@testing-library/react';
import jest from 'jest-mock';
import React from 'react';
import { BrowserRouter } from 'react-router-dom';
import API from '../../api/API';
import ApplicationItemGroupItem from '../../components/Applications/ApplicationItemGroupItem';
import { theme } from '../../TestHelpers/theme';

function mockResolver() {
  return Promise.resolve(1);
}
const mockAjax = jest.fn(() => mockResolver);
describe('Application Item Group Item', () => {
  const minProps = {
    group: {
      name: 'ABC',
      application_id: '123',
      id: '1',
      channel: {
        name: 'main',
      },
    },
    appName: 'FlatCar',
  };
  beforeEach(() => {
    API.getInstancesCount = mockAjax();
  });
  it('should render correct link and correct total instances', async () => {
github conveyal / analysis-ui / lib / components / map / __tests__ / edit-bounds.js View on Github external
it('renders correctly', () => {
    const tree = renderer.create(
      <map>
        
      </map>
    ).toJSON()
    expect(tree).toMatchSnapshot()
  })
})
github lucasconstantino / now-we-test / tests / fixtures / now-node-project / lambdas / throwing.js View on Github external
const jestMock = require('jest-mock')

module.exports = jestMock.fn(() => {
  throw new Error('Ooops!')
})
github ReactTraining / history / modules / __tests__ / TestSequences / Listen.js View on Github external
export default function(history, done) {
  const spy = mock.fn();
  const unlisten = history.listen(spy);

  expect(spy).not.toHaveBeenCalled();

  unlisten();
  done();
}
github streamlit / streamlit / frontend / src / lib / MetricsManagerTestUtils.ts View on Github external
export function getMetricsManagerForTest(): MetricsManager {
  const mm = new MetricsManager()
  mm["track"] = jest.fn()
  mm["identify"] = jest.fn()
  return mm
}
github wp-headless / fetch / packages / client / __mocks__ / MockTransport.js View on Github external
resetMock() {
    this.request = mock.fn((input, options) => this._request());
  }

jest-mock

**Note:** More details on user side API can be found in [Jest documentation](https://jestjs.io/docs/mock-function-api).

MIT
Latest version published 8 months ago

Package Health Score

93 / 100
Full package analysis