Javascript 如何使用jest测试GoogleMap
我正在使用Javascript 如何使用jest测试GoogleMap,javascript,reactjs,jestjs,react-google-maps,Javascript,Reactjs,Jestjs,React Google Maps,我正在使用react谷歌地图npm的组件开发一个react应用程序。 我应该如何将测试添加到此组件 我需要对贴图进行一些测试,但是当我尝试使用jest渲染它时,shallow只返回我给贴图组件渲染的容器组件 const props = { googleMapURL: `https://maps.googleapis.com/maps/api/js?key=${API_KEY}&v=3.exp&libraries=geometry,drawing,places`, cont
react谷歌地图npm的组件开发一个react应用程序。
我应该如何将测试添加到此组件
我需要对贴图进行一些测试,但是当我尝试使用jest
渲染它时,shallow只返回我给贴图组件渲染的容器组件
const props = {
googleMapURL: `https://maps.googleapis.com/maps/api/js?key=${API_KEY}&v=3.exp&libraries=geometry,drawing,places`,
containerElement: <div style={{ height: '100%' }} />,
loadingElement: <div style={{ height: '100%' }} />,
mapElement: <div style={{ height: '100%' }} />,
defaultZoom: 5,
defaultCenter: { location: { lat: 0, lng: 0 } },
iconPrefix: '/',
points: points.map(p => createMarker(p)), // this is just for styling the markers.
};
describe('Map component', () => {
const component = shallow(<Map {...props} />);
it('It should match snapshot', () => {
console.log('....: ', component.html()); // -> returns <div style="height:100%"></div>
expect(component.html()).toMatchSnapshot();
});
});
const props={
谷歌地图网址:`https://maps.googleapis.com/maps/api/js?key=${API_KEY}&v=3.exp&libraries=几何图形、图形、位置`,
集装箱运输:,
加载元素:,
mapElement:,
默认缩放:5,
defaultCenter:{位置:{lat:0,lng:0},
iconPrefix:“/”,
points:points.map(p=>createMarker(p)),//这只是用于设置标记的样式。
};
描述('映射组件',()=>{
常量分量=浅();
它('它应该匹配快照',()=>{
console.log('..:',component.html());/>返回
expect(component.html()).toMatchSnapshot();
});
});
有人经历过同样的问题??有人对我如何解决这个问题有什么指导吗
谢谢你的帮助