jjzjj

MemoryRouter

全部标签

测试与开玩笑和酶的反应式v4

我有一个简单的应用程序,他们使用React-RouterV4constApp=()=>(Home}/>Profile}/>Help}/>);和测试jest.dontMock('../App');importReactfrom'react';import{MemoryRouter}from'react-router-dom';import{shallow}from'enzyme';importAppfrom'../App';describe('',()=>{constwrapper=shallow();console.log(wrapper.html());it('rendersastatict

javascript - 使用 Jest 和 Enzyme 测试 react-router v4

我有一个简单的应用程序,他们使用react-routerv4constApp=()=>(Home}/>Profile}/>Help}/>);和测试jest.dontMock('../App');importReactfrom'react';import{MemoryRouter}from'react-router-dom';import{shallow}from'enzyme';importAppfrom'../App';describe('',()=>{constwrapper=shallow();console.log(wrapper.html());it('rendersasta

javascript - 如何设置与 MemoryRouter 和 Jest 的匹配路径? (不是位置或历史)

如有重复请见谅我知道MemoryRouter有initialEntries和initialIndex,所以你可以为“location”和“history”设置路径等。但是“匹配”没有得到更新...我需要为我的React应用程序和Jest测试设置“匹配”。当我尝试时,我得到了match:{path:'/',url:'/',params:{}...},location:{path:'/hello',pathname:'/',...},history:{...,location:{path:'/hello',pathname:'/',...}}不知道有没有办法设置匹配。提前致谢。