1import React from 'react';
2import { render } from '@testing-library/react';
3import '@testing-library/jest-dom/extend-expect'
4import App from './App';
5
6import { randomNameGenerator } from "./utils";
7
8jest.mock('./utils.js', () => ({
9 randomNameGenerator: jest.fn()
10}));
11
12describe('test', () => {
13 it('allows Jest method mocking 1', () => {
14 randomNameGenerator.mockImplementation(() => "Craig");
15 const { getByText } = render(<App />);
16 expect(getByText("Craig")).toBeInTheDocument()
17 });
18
19 it('allows Jest method mocking 2', () => {
20 randomNameGenerator.mockImplementation(() => "Not Craig");
21 const { getByText } = render(<App />);
22 expect(getByText("Not Craig")).toBeInTheDocument()
23 });
24});
25