亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在玩笑中跳過文件執行?

如何在玩笑中跳過文件執行?

蝴蝶刀刀 2023-09-14 22:06:34
我正在使用 jest 進行集成測試,其中一個文件夾下有 20 個測試文件。我需要確保在運行測試時不需要執行該文件夾中的三個文件。我嘗試使用testPathIgnorePatterns但它僅適用于文件夾而不適用于文件。怎么做?笑話配置.js/** * @file Jest Integration Test Configuration File */module.exports = {  roots: ['../../tests'],  testRegex: '_*_integration.test.(js|ts|tsx)?$',  globals: {    'ts-jest': {      tsconfig: 'tsconfig.json',    },  },  moduleFileExtensions: ['ts', 'js'],  transform: {    '^.+\\.(ts|tsx)$': 'ts-jest',  },  testPathIgnorePatterns: ['tests/api/modules/m3/sample.test.ts'],  testEnvironment: 'node',  reporters: [    'default',    [      '../../node_modules/jest-html-reporter',      {        pageTitle: 'Integration Test Report',        outputPath: 'tests/reports/integration-test-report.html',        includeFailureMsg: true,      },    ],  ],};
查看完整描述

3 回答

?
皈依舞

TA貢獻1851條經驗 獲得超3個贊

--testPathIgnorePatterns使用cli 選項怎么樣?

yarn test --testPathIgnorePatterns=user.test.ts

如果對于多個文件,可以使用下面的。

yarn test --testPathIgnorePatterns=filename1 filename2


查看完整回答
反對 回復 2023-09-14
?
繁花不似錦

TA貢獻1851條經驗 獲得超4個贊

對于 Jest 覆蓋范圍中要忽略的單個文件,請放置以下行


/* istanbul ignore next */

忽略個別功能,請忽略上面的功能


/* istanbul ignore next */

const ignoreFunc =()=>{

 console.log('This function will be ignored from coverage')

}


查看完整回答
反對 回復 2023-09-14
?
米琪卡哇伊

TA貢獻1998條經驗 獲得超6個贊

collectCoverageFrom您可以像這樣使用Zest json 的參數,

collectCoverageFrom:?['path-to-file1','path-to-file2'],

注意:此選項需要將collectCoverage設置為true或調用Jest--coverage.

在文檔中,他們指定了一種模式,但它也適用于文件靜態文件路徑。


查看完整回答
反對 回復 2023-09-14
  • 3 回答
  • 0 關注
  • 160 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號