Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

API reference

Jest API reference

Jest unit testing

Identifiers
104
With full guides
0
Types
4

Topics covered

  • Matchers
  • Mocks & spies
  • Module mocks
  • Async tests
  • Setup / teardown
  • Snapshot testing
  • Coverage
  • Fake timers

Function

NameWhat it does
describeFunction
testFunction
expectFunction
beforeEachFunction
afterEachFunction
jest.fnFunction
jest.mockFunction
jest.spyOnFunction
toEqualFunction
toHaveBeenCalledFunction
beforeAllFunction
afterAllFunction
jest.useFakeTimersFunction
jest.clearAllMocksFunction
jest.resetModulesFunction
expect.extendFunction
toMatchSnapshotFunction
toThrowFunction
mockResolvedValueFunction
itFunction
test.eachFunction
describe.eachFunction
it.onlyFunction
it.skipFunction
it.todoFunction
test.concurrentFunction
xdescribeFunction
xitFunction
fitFunction

Type Alias

NameWhat it does
jest.MockType Alias
jest.MockedType Alias
jest.SpyInstanceType Alias
MockedFunctionType Alias

Module

NameWhat it does
toBeModule
toStrictEqualModule
toBeNullModule
toBeUndefinedModule
toBeDefinedModule
toBeTruthyModule
toBeFalsyModule
toBeGreaterThanModule
toBeGreaterThanOrEqualModule
toBeLessThanModule
toBeLessThanOrEqualModule
toBeCloseToModule
toMatchModule
toMatchObjectModule
toContainModule
toContainEqualModule
toHaveLengthModule
toHavePropertyModule
toBeInstanceOfModule
toBeNaNModule
toMatchInlineSnapshotModule
toHaveBeenCalledTimesModule
toHaveBeenCalledWithModule
toHaveBeenLastCalledWithModule
toHaveBeenNthCalledWithModule
toHaveReturnedModule
toHaveReturnedWithModule
resolvesModule
rejectsModule
notModule
anyModule
anythingModule
arrayContainingModule
objectContainingModule
stringContainingModule
stringMatchingModule
assertionsModule
hasAssertionsModule
jest.resetAllMocksModule
jest.restoreAllMocksModule
jest.useRealTimersModule
jest.advanceTimersByTimeModule
jest.runAllTimersModule
jest.runOnlyPendingTimersModule
jest.mockedModule
jest.requireActualModule
jest.requireMockModule
jest.doMockModule
jest.unmockModule
jest.setTimeoutModule
jest.isolateModulesModule
mockReturnValueModule
mockRejectedValueModule
mockImplementationModule
mockImplementationOnceModule
mockReturnValueOnceModule
mockResetModule
mockClearModule
mockRestoreModule
mockNameModule

Pipe

NameWhat it does
testEnvironmentPipe
setupFilesPipe
setupFilesAfterEachPipe
moduleNameMapperPipe
transformPipe
collectCoveragePipe
coverageThresholdPipe
testMatchPipe
presetPipe
projectsPipe
globalSetupPipe

Search across every package and filter by type in your dashboard.

Start learning