JSPM

jest-cli

0.0.6-pre
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 37675859
  • Score
    100M100P100Q210745F

Package Exports

  • jest-cli/bin/jest
  • jest-cli/bin/jest.js
  • jest-cli/package.json
  • jest-cli/src/lib/moduleMocker
  • jest-cli/src/lib/utils

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jest-cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Jest

Painless JavaScript Unit Testing

  • Familiar Approach: Built on top of Jasmine test framework, a familiar BDD testing environment

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

  • Short Feedback Loop: Tests run in parallel and DOM apis are mocked so you can run tests on the command line

Take a look at the website for more information

Getting Started

Getting started with Jest is pretty simple. All you need to do is:

  1. Write some (jasmine) tests in a __tests__/ directory
  2. Run npm install jest-cli --save-dev
  3. Add "scripts": {"test": "jest"} to your package.json
  4. Run npm test

This will run your automatically mocked tests for you and you'll be on your way!

Check out the Getting Started tutorial for more in-depth details.

API

#### The `jest` object

Mock functions

Config options

Globally injected variables

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

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)