国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

從0到1學(xué)習(xí)前端單元測(cè)試jest框架(一)

2022-11-25 14:08 作者:歲月靜好sandra  | 我要投稿

此步驟建立在你搭建好node環(huán)境基礎(chǔ)之下

第一步 安裝 jest?

使用npm install jest --save-dev 或者 yarn add jest --save-dev??

第二步 初始化 jest.config.js? 使用??npx jest --init? 這個(gè)命令可以在當(dāng)前路徑下初始化jest.config.js


第三步在node環(huán)境或者jsDOM(瀏覽器環(huán)境)下增加對(duì)ES6代碼的支持

yarn add jest-babel @babel/core @babel/preset-env

下載安裝完上面的依賴以后創(chuàng)建一個(gè).babelrc 的文件 里面寫上


第四步,因?yàn)槲覀円?TypeScript 寫代碼文件和測(cè)試文件,而 Jest 是不能直接執(zhí)行 Typescript 的,所以需要通過 babel 來處理。所以需要再使用yarn進(jìn)行安裝下面的這些依賴


另外一定要安裝 jest-environment-jsdom

不安裝這個(gè)一定會(huì)報(bào)錯(cuò)

會(huì)報(bào)下面的這個(gè)錯(cuò)

Test environment jest-environment-jsdom cannot be found. Make sure the testEnvironment configuration?

? Test environment jest-environment-jsdom cannot be found. Make sure the testEnvironment configuration option points to an existing node module.

? Configuration Documentation:

? https://jestjs.io/docs/configuration

As of Jest 28 "jest-environment-jsdom" is no longer shipped by default, make sure to install it separately.




第五步:配置babel.config.js ,內(nèi)容如下

第六步在package.json的scripts下添加?"test":?"jest"

"scripts": { ??"test": "jest"},

添加完這句就可以進(jìn)行單元測(cè)試了





從0到1學(xué)習(xí)前端單元測(cè)試jest框架(一)的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
安宁市| 原平市| 定结县| 宜兰县| 莱州市| 抚远县| 泰顺县| 木兰县| 潮安县| 禹州市| 松江区| 宁阳县| 仁布县| 元谋县| 如东县| 建阳市| 河间市| 宜都市| 淮南市| 兴城市| 罗江县| 扎囊县| 佳木斯市| 安徽省| 青海省| 洪湖市| 阜平县| 平潭县| 常宁市| 兴海县| 洞头县| 宜兴市| 全南县| 高密市| 开封市| 东兴市| 翁牛特旗| 察隅县| 张家港市| 瓦房店市| 潍坊市|