Reactjs Can';无法获取Jest以运行命名导入
这是一个带有Typescript create react应用程序项目的Typescript Jest测试 我有以下几点Reactjs Can';无法获取Jest以运行命名导入,reactjs,jestjs,create-react-app,Reactjs,Jestjs,Create React App,这是一个带有Typescript create react应用程序项目的Typescript Jest测试 我有以下几点 /* global test, expect */ import React from 'react'; import { getCurrentUser } from '../../utils/authUtils'; test('Bidding component runs without errors', () => { jest.mock('../../ut
/* global test, expect */
import React from 'react';
import { getCurrentUser } from '../../utils/authUtils';
test('Bidding component runs without errors', () => {
jest.mock('../../utils/authUtils', () => {
return {
__esModule: true,
getCurrentUser: jest.fn(() => ({ uid: 'user124' })),
};
});
console.log(getCurrentUser());
});
在测试中调用getCurrentUser()
时,它调用的是原始导入的函数,而不是声明的mock。我做错了什么
这个函数实际上在我的组件中使用,一旦我有了它,它将被测试,但我假设如果它在这里不工作,在那里也不会工作?请参阅createMockFromModule方法-请参阅createMockFromModule方法-