Open any86 opened 5 years ago
// 是否支持touch事件 export const SUPPORT_TOUCH = ('ontouchstart' in window);
// jest.config.js module.exports = { ... globals: { ontouchstart: null } };
如果你的代码里有一段是这样的:
因为默认jest集成的jsdom的window上是没有ontouchstart属性的, 所以我们需要自己加一个:
现在在每个测试文件中, 都可以直接识别到ontouchstart了, 是不是很简单 🐳