Giter Club home page Giter Club logo

jest's Introduction

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 />

jest's People

Contributors

jeffmo avatar sophiebits avatar vjeux avatar harshadsabne avatar kl3ryk avatar wincent avatar ruanwz avatar daniel15 avatar tomocchino avatar wyze avatar jsdf avatar dakuan avatar chenglou avatar dobrite avatar ide avatar jasonlaster avatar bestander avatar leebyron avatar pimterry avatar davidxi avatar xeodou avatar yungsters avatar

Watchers

Jason Hutchens avatar Jack Casey avatar Matt Powell avatar Guillaume avatar Brad Crawford avatar  avatar James Cloos avatar  avatar Agworld Developers avatar  avatar Robert Barnett avatar Josh Kinabrew avatar  avatar Edixon Yu Jr. avatar Judah Cofer avatar Damon J. Murray avatar  avatar  avatar gellmr avatar  avatar Lyndsay Roger avatar  avatar Agworld Deploy avatar Raphael Ramos avatar david-jeffries avatar tawanda avatar Candhie Khairul Ikhwan avatar  avatar  avatar putripw avatar  avatar  avatar Stephen Greer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.