当前位置:网站首页>jest单测样式问题【identity-obj-proxy】npm包
jest单测样式问题【identity-obj-proxy】npm包
2022-07-27 05:32:00 【祥哥的说】
背景:
在使用jest做单测时,由于文件中存在less文件,导致单测失败


处理方式:
1、identity-obj-proxy
使用此npm结合jest配置,可以进行样式的代理处理。
jest配置的两种形式:
(1)单独的jest配置文件

配置内容:
module.exports = {
'moduleNameMapper': {
'\\.(css|less)$': 'identity-obj-proxy',
},
};
(2)直接在package.json中进行配置
"jest": {
"moduleNameMapper": {
"\\.(css|less)$": "identity-obj-proxy"
}
}2、创建mock文件
rootDir: 相对于package.json文件的路径
module.exports = {
'moduleNameMapper': {
'\\.(css|less)$': '<rootDir>/__mocks__/styleMock.js',
},
};
边栏推荐
- FTX 基金会资助1500万帮助新冠疫苗临床实验,将影响全球公共卫生
- Redis fast learning
- Problems related to compilation and training of Darknet yolov3 and Yolo fast using CUDA environment of rtx30 Series graphics card on win10 platform
- 齐岳:巯基修饰寡聚DNA|DNA修饰CdTe/CdS核壳量子点|DNA偶联砷化铟InAs量子点InAs-DNA QDs
- Inventory of the world's six most technologically competent smart contract audit companies in 2022
- Ancient art - make good use of long tail keywords
- Sok: the faults in our asrs: an overview of attacks against automatic speech recognition
- 如何让最小 API 绑定查询字符串中的数组
- For redis under windows, it can only read but not write
- regular expression
猜你喜欢

Sunflower teaches you how to prevent denial of service attacks?

EasyCVR平台播放设备录像时,拖动时间轴播放无效是什么原因?

如何避免漏洞?向日葵远程为你讲解不同场景下的安全使用方法

According to SQL, you must know and learn SQL (MySQL)
![[unity URP] the code obtains the universalrendererdata of the current URP configuration and dynamically adds the rendererfeature](/img/be/812ccb05d7763effcece51945f0460.png)
[unity URP] the code obtains the universalrendererdata of the current URP configuration and dynamically adds the rendererfeature

Multimodal database | star ring technology multimode database argodb "one database for multiple purposes", building a high-performance Lake warehouse integrated platform

FTX Foundation funded 15million to help covid-19 clinical trials, which will affect global public health

PNA肽核酸修饰多肽Suc-Tyr-Leu-Val-pNA|Suc-Ala-Pro-Phe-pNA 11

Detection and identification data set and yolov5 model of helmet reflective clothing

Soul continues to make efforts to list its social channels in Hong Kong. Why is "soul style social" popular?
随机推荐
Auto encoder (AE), denoising auto encoder (DAE), variable auto encoder (VAE) differences
gin-vue-admin 使用docker容器中的数据库
Fix the problem that the paging data is not displayed when searching the easycvr device management list page
Socket programming II: using Select
The problem of torch loading custom models
Speech and language processing (3rd ed. draft) Chapter 2 - regular expression, text normalization, editing distance reading notes
Express framework
硫化镉CdS量子点修饰脱氧核糖核酸DNA|CdS-DNA QDs|近红外CdS量子点偶联DNA规格信息
自己动手实现容器
FTX 基金会资助1500万帮助新冠疫苗临床实验,将影响全球公共卫生
About the new features of ES6
Many of the world's top 500 enterprises gathered at the second digital Expo, and the digital industry curtain is about to open!
2022上半年英特尔有哪些“硬核创新”?看这张图就知道了!
Alibaba cloud SMS authentication third-party interface (fast use)
How to delete or replace the loading style of easyplayer streaming media player?
CentOS上使用Docker安装和部署Redis
Brief introduction of chip, memory and its key indicators I
【11】 Binary code: "holding two roller handcuffs, crying out for hot hot hot"?
Ftx.us launched stock and ETF trading services to make trading more transparent
deepsort源码解读(二)