close
logo
Rstest
指南
配置
API
English
简体中文
指南
配置
API
English
简体中文
logo
Rstest
Overview

Test API

Test
Describe
Hooks

Rstest Utility

Mock functions
MockInstance
Fake timers
Utilities

API Overview

当前页面列出了 Rstest 所有的测试 API。

Test API

Test

  • test
  • test.only
  • test.skip
  • test.todo
  • test.each
  • test.for
  • test.fails
  • test.concurrent
  • test.sequential
  • test.runIf
  • test.skipIf
  • test.extend

Describe

  • describe
  • describe.only
  • describe.skip
  • describe.todo
  • describe.each
  • describe.for
  • describe.runIf
  • describe.skipIf
  • describe.concurrent
  • describe.sequential

Hooks

  • beforeAll
  • afterAll
  • beforeEach
  • afterEach

Rstest Utility

Mock functions

  • rstest.fn
  • rstest.spyOn
  • rstest.isMockFunction
  • rstest.clearAllMocks
  • rstest.resetAllMocks
  • rstest.restoreAllMocks

MockInstance

  • getMockName
  • mockName
  • mockClear
  • mockReset
  • mockRestore
  • getMockImplementation
  • mockImplementation
  • mockImplementationOnce
  • withImplementation
  • mockReturnThis
  • mockReturnValue
  • mockReturnValueOnce
  • mockResolvedValue
  • mockResolvedValueOnce
  • mockRejectedValue
  • mockRejectedValueOnce
  • mock
  • mock.calls
  • mock.instances
  • mock.contexts
  • mock.invocationCallOrder
  • mock.lastCall
  • mock.results
  • mock.settledResults

Fake timers

  • rstest.useFakeTimers
  • rstest.useRealTimers
  • rstest.isFakeTimers
  • rstest.setSystemTime
  • rstest.getRealSystemTime
  • rstest.runAllTicks
  • rstest.runAllTimers
  • rstest.runAllTimersAsync
  • rstest.runOnlyPendingTimers
  • rstest.runOnlyPendingTimersAsync
  • rstest.advanceTimersByTime
  • rstest.advanceTimersByTimeAsync
  • rstest.advanceTimersToNextTimer
  • rstest.advanceTimersToNextTimerAsync
  • rstest.advanceTimersToNextFrame
  • rstest.getTimerCount
  • rstest.clearAllTimers

Utilities

  • rstest.stubEnv
  • rstest.unstubAllEnvs
  • rstest.stubGlobal
  • rstest.unstubAllGlobals