我如何模拟传单以进行开玩笑的测试?

问题描述 投票:1回答:1

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

react-leaflet
1个回答
0
投票

我在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

© www.soinside.com 2019 - 2024. All rights reserved.