我在 React 中使用rewire创建了一个简单的测试(在babel-plugin-rewire中为 React 实现),但无法让导入工作:
代码:
import ClientSelectionMenu, {
__RewireAPI__ as ClientSelectionMenuRewireAPI
} from './ClientSelectionMenu';
测试:
describe('selectionList', () => {
it.only('returns Logout option from empty input', () => {
const rewiredSelectionList = ClientSelectionMenuRewireAPI.__Rewire__('selectionList');
当我运行测试时,ClientSelectionMenuRewireAPI
是未定义的。我到底做错了什么?