我正在使用react-google-mapsnpm 的组件开发一个反应应用程序。我应该如何向这个组件添加测试?
我需要对地图进行一些测试,但是当我尝试使用 渲染它时jest,浅层只返回我给地图组件渲染的容器组件。
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();
});
});
有人遇到过同样的问题??有人对我该如何解决有任何指示吗?
我很感激任何帮助