Skip to content
/ jest Public
forked from jestjs/jest

Painless JavaScript Unit Testing built on top of the Jasmine test framework.

License

Notifications You must be signed in to change notification settings

hankhsiao/jest

This branch is 2 commits ahead of, 7037 commits behind jestjs/jest:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

f822981 · Apr 1, 2015
Feb 25, 2015
Mar 20, 2015
Mar 12, 2015
Apr 1, 2015
May 15, 2014
Nov 4, 2014
Mar 3, 2015
May 14, 2014
May 16, 2014
May 14, 2014
May 14, 2014
Mar 17, 2015
May 14, 2014
May 14, 2014
May 14, 2014
Sep 3, 2014
Mar 20, 2015

Repository files navigation

Painless JavaScript Unit Testing

  • Familiar Approach: Built on top of the Jasmine test framework, using familiar expect(value).toBe(other) assertions

  • Mock by Default: Automatically mocks CommonJS modules returned by require(), making most existing code testable

  • Short Feedback Loop: DOM APIs are mocked and tests run in parallel via a small node.js command line utility

Getting Started

Check out the Getting Started tutorial. It's pretty simple!

API

<generated_api_start />

The jest object

Mock functions

Config options

Globally injected variables

  • afterEach(fn)
  • beforeEach(fn)
  • describe(name, fn)
  • it(name, fn)
  • it.only(name, fn) executes only this test. Useful when investigating a failure
  • jest
  • pit(name, fn) helper for promises
  • require(module)
  • require.requireActual(module)
  • xdescribe(name, fn)
  • xit(name, fn)

expect(value)

  • .not inverse the next comparison
  • .toThrow(?message)
  • .toBe(value) comparison using ===
  • .toEqual(value) deep comparison. Use jasmine.any(type) to be softer
  • .toBeFalsy()
  • .toBeTruthy()
  • .toBeNull()
  • .toBeUndefined()
  • .toBeDefined()
  • .toMatch(regexp)
  • .toContain(string)
  • .toBeCloseTo(number, delta)
  • .toBeGreaterThan(number)
  • .toBeLessThan(number)
  • .toBeCalled()
  • .toBeCalledWith(arg, um, ents)
  • .lastCalledWith(arg, um, ents)

<generated_api_end />

About

Painless JavaScript Unit Testing built on top of the Jasmine test framework.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 95.3%
  • CSS 4.4%
  • Other 0.3%