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)
  • expect(value)
  • 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

amasad avatar arcin avatar blainekasten avatar clentfort avatar cpojer avatar dalongi avatar daniel15 avatar dmitrysoshnikov avatar emmenko avatar fabiomcosta avatar hankhsiao avatar harshadsabne avatar ide avatar jakeboone02 avatar jbonta avatar jeffmo avatar jsdf avatar kl3ryk avatar leebyron avatar mcnouvion avatar philvargas avatar ruanwz avatar segfaultx64 avatar sophiebits avatar stephnr avatar tomocchino avatar vjeux avatar wincent avatar yungsters avatar zpao avatar

Watchers

 avatar  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.