国产chinesehdxxxx野外,国产av无码专区亚洲av琪琪,播放男人添女人下边视频,成人国产精品一区二区免费看,chinese丰满人妻videos

Jest 平臺(tái)

2021-09-18 11:56 更新

你可以挑選 Jest 的特定功能并將它們用作獨(dú)立包。以下是可用軟件包的列表:

已更改文件

用于識(shí)別 git/hg 存儲(chǔ)庫中已修改文件的工具。導(dǎo)出兩個(gè)函數(shù):

  • ?getChangedFilesForRoots ?返回一個(gè)承諾,該承諾解析為具有更改文件和存儲(chǔ)庫的對(duì)象。
  • ?findRepos ?返回解析為指定路徑中包含的一組存儲(chǔ)庫的承諾。

例子

  1. const {getChangedFilesForRoots} = require('jest-changed-files');
  2. // 打印出當(dāng)前目錄最后修改過的一組文件
  3. getChangedFilesForRoots(['./'], {
  4. lastCommit: true,
  5. }).then(result => console.log(result.changedFiles));

可以?在自述文件中閱讀更多相關(guān)jest-changed-files?信息。

差異

可視化數(shù)據(jù)變化的工具。導(dǎo)出一個(gè)函數(shù),該函數(shù)比較任何類型的兩個(gè)值,并返回一個(gè)“pretty printed”的字符串,說明兩個(gè)參數(shù)之間的差異。

例子

  1. const diff = require('jest-diff').default;
  2. const a = {a: {b: {c: 5}}};
  3. const b = {a: {b: {c: 6}}};
  4. const result = diff(a, b);
  5. // print diff
  6. console.log(result);

Docblock

用于提取和解析 JavaScript 文件頂部注釋的工具。導(dǎo)出各種函數(shù)來操作注釋塊內(nèi)的數(shù)據(jù)。

例子

  1. const {parseWithComments} = require('jest-docblock');
  2. const code = `
  3. /**
  4. * This is a sample
  5. *
  6. * @flow
  7. */
  8. console.log('Hello World!');
  9. `;
  10. const parsed = parseWithComments(code);
  11. // prints an object with two attributes: comments and pragmas.
  12. console.log(parsed);

可以?在自述文件中閱讀更多相關(guān)jest-docblock?信息。

獲取類型

標(biāo)識(shí)任何 JavaScript 值的原始類型的模塊。導(dǎo)出一個(gè)函數(shù),該函數(shù)返回一個(gè)字符串,該字符串具有作為參數(shù)傳遞的值的類型。

例子

  1. const getType = require('jest-get-type');
  2. const array = [1, 2, 3];
  3. const nullValue = null;
  4. const undefinedValue = undefined;
  5. // prints 'array'
  6. console.log(getType(array));
  7. // prints 'null'
  8. console.log(getType(nullValue));
  9. // prints 'undefined'
  10. console.log(getType(undefinedValue));

驗(yàn)證

用于驗(yàn)證用戶提交的配置的工具。 導(dǎo)出具有兩個(gè)參數(shù)的函數(shù):用戶配置和包含示例配置和其他選項(xiàng)的對(duì)象。返回值是具有兩個(gè)屬性的對(duì)象:

  • ?hasDeprecationWarnings?,一個(gè)布爾值,指示提交的配置是否有棄用警告,
  • ?isValid?, 一個(gè)布爾值, 指示配置是否正確。

例子

  1. const {validate} = require('jest-validate');
  2. const configByUser = {
  3. transform: '<rootDir>/node_modules/my-custom-transform',
  4. };
  5. const result = validate(configByUser, {
  6. comment: ' Documentation: http://custom-docs.com',
  7. exampleConfig: {transform: '<rootDir>/node_modules/babel-jest'},
  8. });
  9. console.log(result);

可以?在自述文件中閱讀更多相關(guān)jest-validate?信息。

worker

用于任務(wù)并行化的模塊。出口類?JestWorker?是需要的Node.js模塊的路徑,并允許你調(diào)用模塊的導(dǎo)出的方法,好像他們是類方法,返回一個(gè) Promise,消除了在所指定的方法完成它的執(zhí)行在分叉過程。

例子

  1. // heavy-task.js
  2. module.exports = {
  3. myHeavyTask: args => {
  4. // long running CPU intensive task.
  5. },
  6. };
  1. // main.js
  2. async function main() {
  3. const worker = new Worker(require.resolve('./heavy-task.js'));
  4. // run 2 tasks in parallel with different arguments
  5. const results = await Promise.all([
  6. worker.myHeavyTask({foo: 'bar'}),
  7. worker.myHeavyTask({bar: 'foo'}),
  8. ]);
  9. console.log(results);
  10. }
  11. main();

可以在自述文件中閱讀更多相關(guān)?jest-worker?信息。

格式

導(dǎo)出并將任何 JavaScript 值轉(zhuǎn)換為人類可讀字符串的函數(shù)。開箱即用地支持所有內(nèi)置 JavaScript 類型,并允許通過用戶定義的插件擴(kuò)展特定于應(yīng)用程序的類型。

例子

  1. const prettyFormat = require('pretty-format');
  2. const val = {object: {}};
  3. val.circularReference = val;
  4. val[Symbol('foo')] = 'foo';
  5. val.map = new Map([['prop', 'value']]);
  6. val.array = [-0, Infinity, NaN];
  7. console.log(prettyFormat(val));

可以?在自述文件中閱讀更多pretty-format?相關(guān)信息。


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)