国产成人精品999视频&日本一区二区亚洲人妻精品&久久久精品国产99久久精&99热这里只有成人精品国产&精品国产剧情av一区二区&成人亚洲精品久久久久app&国产精品美女高潮抽搐A片

Jest 備忘清單

NPM version Downloads Repo Dependents Github repo

Jest 是一款優(yōu)雅、簡潔的 JavaScript 測試框架,這里介紹了它的入門和 一些 API 的索引

入門

介紹

Jest v29 是一款優(yōu)雅、簡潔的 JavaScript 測試框架。

  • 無需配置 大多數(shù) JS 項目中即裝即用,無需配置
  • 優(yōu)秀接口itexpect - Jest 將工具包整合在一處。文檔齊全、不斷維護,非常不錯。
  • 隔離的 并行進行測試,發(fā)揮每一絲算力。
  • 快照 輕松編寫持續(xù)追蹤大型對象的測試,并在測試旁或代碼內(nèi)顯示實時快照。
  • 代碼覆蓋 無需其他操作,您僅需添加 --coverage 參數(shù)來生成代碼覆蓋率報告。

快速開始

npm install --save-dev jest

Add to package.json

"scripts": {
  "test": "jest"
}

運行你的測試

npm test -- --watch

查看: Getting started

常用命令

# 指定測試文件的名稱
$ jest my-test
# 指定測試文件的路徑
$ jest path/to/my-test.js
# 僅運行在 hg/git 上有改動但尚未提交的文件
$ jest -o
# 僅運行與 fileA.js 和 fileB.js相關(guān)的測試
$ jest --findRelatedTests fileA.js fileB.js
# 僅運行匹配特定名稱的測試用例
$ jest -t name-of-spec
# 運行監(jiān)視模式默認執(zhí)行 jest -o 監(jiān)視有改動的測試
$ jest --watch 
$ jest --watchAll # 監(jiān)視所有測試

支持駝峰和串式命名的參數(shù)

# 下面給出的命令執(zhí)行的結(jié)果是一樣的:
$ jest --collect-coverage
$ jest --collectCoverage
# 不同命名形式的參數(shù)還可以混用,如:
$ jest --update-snapshot \
       --detectOpenHandles

編寫測試

describe('My work', () => {
  test('works', () => {
    expect(2).toEqual(2)
  })
})

BDD 語法

describe('My work', () => {
  it('works', () => { // `it`是`test`的別名
    ···
  })
})

測試結(jié)構(gòu)

describe('makePoniesPink', () => {
  beforeAll(() => {
    /* 在所有測試之前運行 */
  })
  afterAll(() => {
    /* 在所有測試后運行 */
  })
  beforeEach(() => {
    /* 在每次測試之前運行 */
  })
  afterEach(() => {
    /* 每次測試后運行 */
  })
  test('make each pony pink', () => {
    const actual = fn(['Alice', 'Bob', 'Eve'])
    expect(actual).toEqual(['Pink Alice', 'Pink Bob', 'Pink Eve'])
  })
})

聚焦測試

describe.only(···)

it.only(···)
// 別名: fit()

查看: test.only

可選參數(shù)

FlagDescription
--coverage查看測試覆蓋率摘要
--detectOpenHandles查看未關(guān)閉端口的摘要
--runInBand一個接一個地運行所有測試
--bail,-b失敗跳出測試

更多參數(shù)查看 Jest CLI Options

跳過測試

describe.skip(···)

it.skip(···)
// 別名: xit()

查看: test.skip

基本測試用例

expect(value).not.toBe(value)
  .toEqual(value)
  .toBeTruthy()
// Errors 測試
expect(value).toThrow(error)
  .toThrowErrorMatchingSnapshot()

快照

expect(value)
  .toMatchSnapshot()
  .toMatchInlineSnapshot()

Errors

expect(value)
  .toThrow(error)
  .toThrowErrorMatchingSnapshot()

Objects

expect(value)
  .toBeInstanceOf(Class)
  .toMatchObject(object)
  .toHaveProperty(keyPath, value)

Objects

expect(value)
  .toContain(item)
  .toContainEqual(item)
  .toHaveLength(number)

Numbers

expect(value)
  .toBeCloseTo(number, numDigits)
  .toBeGreaterThan(number)
  .toBeGreaterThanOrEqual(number)
  .toBeLessThan(number)
  .toBeLessThanOrEqual(number)

Booleans

expect(value)
  .toBeFalsy()
  .toBeNull()
  .toBeTruthy()
  .toBeUndefined()
  .toBeDefined()

Strings

expect(value)
  .toMatch(regexpOrString)

NaN

test('當(dāng)值為 NaN 時通過', () => {
  expect(NaN).toBeNaN();
  expect(1).not.toBeNaN();
});

Others

expect.extend(matchers)
expect.any(constructor)
expect.addSnapshotSerializer(serializer)

expect.assertions(1)

匹配器

基本匹配器

expect(42).toBe(42)    // 嚴格相等 (===)
expect(42).not.toBe(3) // 嚴格相等 (!==)
expect([1, 2]).toEqual([1, 2]) // 深度相等

// 深度相等
expect({ a: undefined, b: 2 })
  .toEqual({ b: 2 })

// 嚴格相等 (Jest 23+)
expect({ a: undefined, b: 2 })
  .not.toStrictEqual({ b: 2 })

Using matchers, matchers docs

真實性

// 匹配 if 語句視為 true 的任何內(nèi)容
// (not false、0、''、null、undefined、NaN)
expect('foo').toBeTruthy()
// 匹配 if 語句視為 false 的任何內(nèi)容
// (false、0、''、null、undefined、NaN)
expect('').toBeFalsy()
// 僅匹配 null
expect(null).toBeNull()
// 僅匹配未定義
expect(undefined).toBeUndefined()
// toBeUndefined 的反義詞
expect(7).toBeDefined()
// 匹配真假
expect(true).toEqual(expect.any(Boolean))

數(shù)字

// 大于
expect(2).toBeGreaterThan(1)
// 大于或等于
expect(1).toBeGreaterThanOrEqual(1)
// 小于
expect(1).toBeLessThan(2)
// 小于或等于
expect(1).toBeLessThanOrEqual(1)
// 接近于
expect(0.2 + 0.1).toBeCloseTo(0.3, 5)
// 原始值的傳遞類型
expect(NaN).toEqual(expect.any(Number))

字符串

// 檢查字符串是否與正則表達式匹配。
expect('long string').toMatch('str')
expect('string').toEqual(expect.any(String))
expect('coffee').toMatch(/ff/)
expect('pizza').not.toMatch('coffee')
expect(['pizza', 'coffee']).toEqual(
  [
    expect.stringContaining('zz'), 
    expect.stringMatching(/ff/)
  ]
)

數(shù)組

expect([]).toEqual(expect.any(Array))
const exampleArray = [
  'Alice', 'Bob', 'Eve'
]
expect(exampleArray).toHaveLength(3)
expect(exampleArray).toContain('Alice')
expect(exampleArray).toEqual(
  expect.arrayContaining(['Alice', 'Bob'])
)
expect([{ a: 1 }, { a: 2 }])
    .toContainEqual({ a: 1 }) // 包含相等

對象

expect({ a:1 }).toHaveProperty('a')
expect({ a:1 }).toHaveProperty('a', 1)
expect({ a: {b:1} }).toHaveProperty('a.b')
expect({ a:1, b:2 }).toMatchObject({a:1})
expect({ a:1, b:2 }).toMatchObject({
  a: expect.any(Number),
  b: expect.any(Number),
})
expect([{ a: 1 }, { b: 2 }]).toEqual([
  expect.objectContaining(
    { a: expect.any(Number) }
  ),
  expect.anything(),
])

模擬函數(shù)

// const fn = jest.fn()
// const fn = jest.fn().mockName('Unicorn') -- 命名為 mock, Jest 22+
// 函數(shù)被調(diào)用
expect(fn).toBeCalled()
// 函數(shù)*未*調(diào)用
expect(fn).not.toBeCalled()
// 函數(shù)只被調(diào)用一次
expect(fn).toHaveBeenCalledTimes(1)
// 任何執(zhí)行都帶有這些參數(shù)
expect(fn).toBeCalledWith(arg1, arg2)
// 最后一個執(zhí)行是用這些參數(shù)
expect(fn).toHaveBeenLastCalledWith(arg1, arg2)
// 第 N 個執(zhí)行帶有這些參數(shù)(Jest 23+)
expect(fn).toHaveBeenNthCalledWith(callNumber, args)
// 函數(shù)返回沒有拋出錯誤(Jest 23+)
expect(fn).toHaveReturnedTimes(2)
// 函數(shù)返回一個值(Jest 23+)
expect(fn).toHaveReturnedWith(value)
// 最后一個函數(shù)調(diào)用返回一個值(Jest 23+)
expect(fn).toHaveLastReturnedWith(value)
// 第 N 個函數(shù)調(diào)用返回一個值(Jest 23+)
expect(fn).toHaveNthReturnedWith(value)
expect(fn.mock.calls).toEqual([
  ['first', 'call', 'args'],
  ['second', 'call', 'args'],
]) // 多次調(diào)用
// fn.mock.calls[0][0] — 第一次調(diào)用的第一個參數(shù)
expect(fn.mock.calls[0][0]).toBe(2)

別名

  • toBeCalledtoHaveBeenCalled
  • toBeCalledWithtoHaveBeenCalledWith
  • lastCalledWithtoHaveBeenLastCalledWith
  • nthCalledWithtoHaveBeenNthCalledWith
  • toReturnTimestoHaveReturnedTimes
  • toReturnWithtoHaveReturnedWith
  • lastReturnedWithtoHaveLastReturnedWith
  • nthReturnedWithtoHaveNthReturnedWith

雜項

// 檢查對象是否是類的實例。
expect(new A()).toBeInstanceOf(A)

// 檢查對象是否是函數(shù)的實例。
expect(() => {}).toEqual(
  expect.any(Function)
)

// 匹配除 null 或 undefined 之外的任何內(nèi)容
expect('pizza').toEqual(expect.anything())

快照

// 這可確保某個值與最近的快照匹配。
expect(node).toMatchSnapshot()

// Jest 23+
expect(user).toMatchSnapshot({
  date: expect.any(Date),
})

// 確保值與最近的快照匹配。
expect(user).toMatchInlineSnapshot()

Promise 匹配器(Jest 20+)

test('resolve to lemon', () => {
  // 驗證在測試期間是否調(diào)用了一定數(shù)量的斷言。
  expect.assertions(1)
  // 確保添加return語句
  return expect(Promise.resolve('lemon'))
            .resolves.toBe('lemon')

  return expect(Promise.reject('octopus'))
            .rejects.toBeDefined()

  return expect(Promise.reject(
    Error('pizza')
  )).rejects.toThrow()
})

或者使用 async/await:

test('resolve to lemon', async () => {
  expect.assertions(2)
  await expect(Promise.resolve('lemon'))
          .resolves.toBe('lemon')

  await expect(Promise.resolve('lemon'))
          .resolves.not.toBe('octopus')
})

resolves 文檔

例外

// const fn = () => {
//    throw new Error('Out of cheese!')
// }

expect(fn).toThrow()
expect(fn).toThrow('Out of cheese')

// 測試錯誤消息在某處說“cheese”:這些是等價的
expect(fn).toThrowError(/cheese/);
expect(fn).toThrowError('cheese');

// 測試準確的錯誤信息
expect(fn).toThrowError(
  /^Out of cheese!$/
);
expect(fn).toThrowError(
  new Error('Out of cheese!')
);

// 測試函數(shù)在調(diào)用時是否拋出與最新快照匹配的錯誤。
expect(fn).toThrowErrorMatchingSnapshot()

別名

  • toThrowErrortoThrow

異步測試

實例

在異步測試中指定一些預(yù)期的斷言是一個很好的做法,所以如果你的斷言根本沒有被調(diào)用,測試將會失敗。

test('async test', () => {
  // 在測試期間恰好調(diào)用了三個斷言
  expect.assertions(3) 
  // 或者 - 在測試期間至少調(diào)用一個斷言
  expect.hasAssertions()
  // 你的異步測試
})

請注意,您也可以在任何 describetest 之外對每個文件執(zhí)行此操作:

beforeEach(expect.hasAssertions)

這將驗證每個測試用例至少存在一個斷言。 它還可以與更具體的 expect.assertions(3) 聲明配合使用。 請參閱 Jest 文檔中的 更多示例

async/await

test('async test', async () => {
  expect.assertions(1)

  const result = await runAsyncOperation()
  expect(result).toBe(true)
})

done() 回調(diào)

test('async test', (done) => {
  expect.assertions(1)

  runAsyncOperation()
  
  setTimeout(() => {
    try {
      const res = getAsyncOperatResult()
      expect(res).toBe(true)
      done()
    } catch (err) {
      done.fail(err)
    }
  })
})

將斷言包裝在 try/catch 塊中,否則 Jest 將忽略失敗

Promises

test('async test', () => {
  expect.assertions(1)

  return runAsyncOperation().then((result) => {
    expect(result).toBe(true)
  })
})

從你的測試中 返回 一個 Promise

模擬

模擬函數(shù)

test('call the callback', () => {
  const callback = jest.fn()
  fn(callback)
  expect(callback).toBeCalled()
  expect(callback.mock.calls[0][1].baz)
    .toBe('pizza') // 第一次調(diào)用的第二個參數(shù)
  
  // 匹配第一個和最后一個參數(shù),但忽略第二個參數(shù)
  expect(callback)
    .toHaveBeenLastCalledWith(
      'meal',
      expect.anything(),
      'margarita'
    )
})

您還可以使用快照:

test('call the callback', () => {
  // mockName 在 Jest 22+ 中可用
  const callback = jest.fn()
    .mockName('Unicorn')

  fn(callback)
  expect(callback).toMatchSnapshot()
  // ->
  // [MockFunction Unicorn] {
  //   "calls": Array [
  // ...
})

并將實現(xiàn)傳遞給 jest.fn 函數(shù):

const callback = jest.fn(() => true)

模擬函數(shù)文檔

返回、解析和拒絕值

您的模擬可以返回值:

const callback
    = jest.fn().mockReturnValue(true)

const callbackOnce
    = jest.fn().mockReturnValueOnce(true)

或解析值:

const promise
    = jest.fn().mockResolvedValue(true)

const promiseOnce
    = jest.fn().mockResolvedValueOnce(true)

他們甚至可以拒絕值:

const failedPromise =
  jest.fn().mockRejectedValue('Error')

const failedPromiseOnce =
  jest.fn().mockRejectedValueOnce('Error')

你甚至可以結(jié)合這些:

const callback = jest.fn()
        .mockReturnValueOnce(false)
        .mockReturnValue(true)
// ->
//  call 1: false
//  call 2+: true

使用 jest.mock 方法模擬模塊

// 原來的 lodash/memoize 應(yīng)該存在
jest.mock(
  'lodash/memoize',
  () => (a) => a
)
// 不需要原始的 lodash/memoize
jest.mock(
  'lodash/memoize',
  () => (a) => a,
  { virtual: true }
)

注意:當(dāng)使用 babel-jest 時,對 jest.mock 的調(diào)用將自動提升到代碼塊的頂部。 如果您想明確避免這種行為,請使用 jest.doMock。

使用模擬文件模擬模塊

創(chuàng)建一個類似 __mocks__/lodash/memoize.js 的文件:

module.exports = (a) => a

添加到您的測試中:

jest.mock('lodash/memoize')

注意:當(dāng)使用 babel-jest 時,對 jest.mock 的調(diào)用將自動提升到代碼塊的頂部。 如果您想明確避免這種行為,請使用 jest.doMock。手動模擬文檔

模擬 getters 和 setters

const getTitle = jest.fn(() => 'pizza')
const setTitle = jest.fn()
const location = {}
Object.defineProperty(location, 'title', {
  get: getTitle,
  set: setTitle,
})

模擬 getter 和 setter (Jest 22.1.0+)

const location = {}
const getTitle = jest
    .spyOn(location, 'title', 'get')
    .mockImplementation(() => 'pizza')
const setTitle = jest
    .spyOn(location, 'title', 'set')
    .mockImplementation(() => {})

定時器模擬

為使用本機計時器函數(shù)(setTimeout、setInterval、clearTimeoutclearInterval)的代碼編寫同步測試。

// 啟用假計時器
jest.useFakeTimers()
test('kill the time', () => {
  const callback = jest.fn()
  // 運行使用 setTimeout或setInterval 的代碼
  const actual 
    = someFunctionThatUseTimers(callback)
  // 快進直到所有定時器都執(zhí)行完畢
  jest.runAllTimers()
  // 同步檢查結(jié)果
  expect(callback).toHaveBeenCalledTimes(1)
})

或者使用 advanceTimersByTime() 按時間調(diào)整計時器:

// 啟用假計時器
jest.useFakeTimers()
test('kill the time', () => {
  const callback = jest.fn()
  // 運行使用 setTimeout或setInterval 的代碼
  const actual 
    = someFunctionThatUseTimers(callback)
  // 快進 250 毫秒
  jest.advanceTimersByTime(250)
  // 同步檢查結(jié)果
  expect(callback).toHaveBeenCalledTimes(1)
})

對于特殊情況,請使用 jest.runOnlyPendingTimers()

注意: 您應(yīng)該在測試用例中調(diào)用 jest.useFakeTimers() 以使用其他假計時器方法。

模擬對象方法

const spy = jest.spyOn(console, 'log')
  .mockImplementation(() => {})

expect(console.log.mock.calls)
  .toEqual([['dope'], ['nope']])
spy.mockRestore()
const spy = jest.spyOn(ajax, 'request')
  .mockImplementation(
    () => Promise.resolve({success: true})
  )

expect(spy).toHaveBeenCalled()
spy.mockRestore()

清除和恢復(fù)模擬

對于一個模擬

// 清除模擬使用日期
// (fn.mock.calls、fn.mock.instances)
fn.mockClear()

// 清除并刪除任何模擬的返回值或?qū)崿F(xiàn)
fn.mockReset()

// 重置并恢復(fù)初始實現(xiàn)
fn.mockRestore()

注意:mockRestore 僅適用于由jest.spyOn 創(chuàng)建的模擬。對于所有模擬:

// 清除所有 mock 的 
// mock.calls、mock.instances、
// mock.contexts 和 mock.results 屬性。
jest.clearAllMocks()
// 重置所有模擬的狀態(tài)。
jest.resetAllMocks()
// 將所有模擬恢復(fù)到其原始值。
jest.restoreAllMocks()

使用模擬時訪問原始模塊

jest.mock('fs')
// 模擬模塊
const fs = require('fs')
// 原始模塊
const fs = require.requireActual('fs')

數(shù)據(jù)驅(qū)動測試(Jest 23+)

使用不同的數(shù)據(jù)運行相同的測試

test.each([
  [1, 1, 2],
  [1, 2, 3],
  [2, 1, 3],
])('.add(%s, %s)', (a, b, expected) => {
  expect(a + b).toBe(expected)
})

使用模板文字相同

test.each`
  a    | b    | expected
  ${1} | ${1} | ${2}
  ${1} | ${2} | ${3}
  ${2} | ${1} | ${3}
`('returns $expected when $a is added $b', ({ a, b, expected }) => {
  expect(a + b).toBe(expected)
})

或在“describe”級別

describe.each([
  ['mobile'], ['tablet'], ['desktop']
])('checkout flow on %s', (viewport) => {
  test('displays success page', () => {
    //
  })
})

describe.each() 文檔、test.each() 文檔

跳過測試

不要運行這些測試

describe.skip('makePoniesPink'...
tests.skip('make each pony pink'...

僅運行以下測試

describe.only('makePoniesPink'...
tests.only('make each pony pink'...

測試有副作用的模塊

實例

const modulePath = '../module-to-test'
afterEach(() => {
  jest.resetModules()
})
test('第一次測試', () => {
  // 準備第一次測試的條件
  const result = require(modulePath)
  expect(result).toMatchSnapshot()
})
test('第二個文本', () => {
  // 準備第二次測試的條件
  const fn = () => require(modulePath)
  expect(fn).toThrow()
})

Node.jsJest 會緩存你需要的模塊。 要測試具有副作用的模塊,您需要在測試之間重置模塊注冊表

命令參數(shù)參考

命令參數(shù)

:----
--bail[=<n>], -bn 個測試套件失敗后立即退出測試套件
--cache是否使用緩存
--changedFilesWithAncestor運行與當(dāng)前更改和上次提交中所做更改相關(guān)的測試
--changedSince運行與自提供的分支或提交哈希以來的更改相關(guān)的測試
--ci指定該參數(shù)時,Jest 會認為正在 CI 環(huán)境上運行
--clearCache刪除 Jest 的緩存目錄, 然后不運行測試直接退出
--clearMocks在每次測試前自動清除模擬的上下文
--collectCoverageFrom=<glob>相對于 rootDirglob 模式匹配需要從中收集覆蓋信息的文件
--colors即便 stdout 不是 TTY 模式,也要強制高亮顯示測試結(jié)果
--config=<path>指定配置文件的路徑
--coverage[=<boolean>], --collectCoverage將測試覆蓋率信息輸出為報告
--coverageProvider=<provider>指示應(yīng)該使用哪個提供程序來檢測代碼的覆蓋率
--debug打印關(guān)于 Jest 配置的調(diào)試信息
--detectOpenHandles嘗試收集并打印打開的句柄以防止 Jest 干凈地退出
--env=<environment>所有測試都使用該測試環(huán)境設(shè)定
--errorOnDeprecated使調(diào)用已棄用的 API 拋出有用的錯誤消息
--expand, -e使用該參數(shù)來對比完整的差異和錯誤,而非修復(fù)
--filter=<file>導(dǎo)出過濾功能的模塊的路徑
--findRelatedTests <spaceSeparatedListOfSourceFiles>查找并運行涵蓋作為參數(shù)傳入的以空格分隔的源文件列表的測試
--forceExit強制 Jest 在所有測試運行完后退出
--help顯示幫助信息,類似于本頁文檔
--ignoreProjects <project1> ... <projectN>忽略特定的測試項目
--init生成一個基礎(chǔ)配置文件
--injectGlobals將全局變量(expect,test,describe,beforeEach等)插入到全局環(huán)境中
--jsonJSON 模式顯示測試結(jié)果
--lastCommit運行受上次提交中的文件更改影響的所有測試
--listTestsJSON 數(shù)組的形式列出所有將要運行的測試并退出
--logHeapUsage記錄每個測試后的記錄堆使用情況
--maxConcurrency=<num>防止 Jest 同時執(zhí)行超過指定數(shù)量的測試
--maxWorkers=<num>|<string>設(shè)定運行測試的最大工作池數(shù)目
--noStackTrace禁止棧跟蹤信息在測試結(jié)果輸出中
--notify激活測試結(jié)果通知
--onlyChanged -o嘗試確定根據(jù)當(dāng)前存儲庫中哪些已經(jīng)更改的文件來運行的測試
--outputFile=<filename>通過 ——json 參數(shù)可以將測試結(jié)果寫入到指定文件
--passWithNoTests允許在沒有找到文件的情況下通過測試
--projects <path1> ... <pathN>從指定路徑中找到的一個或多個項目運行測試;也采用路徑 globs
--reporters使用指定的記者進行測試
--resetMocks每次測試前自動重置模擬狀態(tài)
--restoreMocks在每次測試前自動恢復(fù)模擬狀態(tài)和實現(xiàn)
--rootsJest 應(yīng)該用來搜索文件的目錄路徑列表
--runInBand, -i僅在當(dāng)前的進程中連續(xù)運行所有測試,而非通過創(chuàng)建的子進程的工作池來運行測試
--runTestsByPath僅運行使用其確切路徑指定的測試
--selectProjects <project1> ... <projectN>運行指定的測試項目
--setupFilesAfterEnv <path1> ... <pathN>運行某些代碼以在每次測試之前配置或設(shè)置測試框架的模塊的路徑列表
--shard測試套件分片以 (?<shardIndex>\d+)/(?<shardCount>\d+) 的格式執(zhí)行
--showConfig輸出 Jest 配置,然后退出
--silent阻止所有測試通過控制臺輸出信息
--testEnvironmentOptions=<json string>帶有將傳遞給 testEnvironment 的選項的 JSON 字符串
--testLocationInResults向測試結(jié)果添加 location 字段
--testMatch glob1 ... globNJest 用于檢測測試文件的 glob 模式
--testNamePattern=<regex>, -t僅運行名稱與正則表達式匹配的測試
--testPathIgnorePatterns=<regex>|[array]在執(zhí)行測試之前針對所有測試路徑進行測試的單個或一組正則表達式模式字符串
--testPathPattern=<regex>在運行測試前,匹配的 regexp 模式字符串的測試文件路徑
--testRunner=<path>允許你指定自定義測試運行程序
--testSequencer=<path>允許您指定自定義測試定序器
--testTimeout=<number>測試的默認超時時間(以毫秒為單位)。默認值:5000
--updateSnapshot, -u在運行測試中使用這個參數(shù)來重新錄制每個失敗測試的快照
--useStderr轉(zhuǎn)移所有輸出到 stderr (標(biāo)準錯誤輸出)
--verbose層次顯示測試套件中每個測試的結(jié)果
--version, -v打印版本并退出
--watch監(jiān)視文件更改,并重新運行與已更改的文件相關(guān)的測試
--watchAll監(jiān)視文件的更改并在任何更改時重新運行所有測試
--watchman是否使用 watchman 進行文件爬取。 默認為 true

另見