如何模拟传单进行笑话测试?

时间:2020-04-11 22:06:20

标签: react-leaflet

我在CRA项目的L.Icon中使用自定义图标。一直在说笑话测试时L是不确定的。我将如何模拟传单以避免此错误?

1 个答案:

答案 0 :(得分:1)

我在leaflet本身的类似问题上找到了这个答案

What I can recommend for testing is the following,
 just mock leaflet using this in your test file,
 that is rendering the map component:
jest.mock('leaflet')

And then you place this leaflet mock you can
find in react-leaflet into the jest mocks folder
 (__mocks__/leaflet.js, download the current file from: 
https://github.com/PaulLeCam/react-leaflet/blob/master/__mocks__/leaflet.js)

That should be enough in most cases.

ref:https://github.com/Leaflet/Leaflet/issues/6297#issuecomment-499809735