jest-browser-globals
Lets you run Jest in a browser. Works with Mocha, which is expected to be in the global scope first.
Makes the following available:
- expect
jest.fn
- mock functionstest.each
- one of the few globals that Mocha doesn't define
Installation
Run npm install --save-dev jest-browser-globals
In a test runner like Karma, include the built file in the global scope:
// karma.config.js moduleexports = frameworks: 'mocha' files: './node_modules/jest-browser-globals/build-es5/index.js' // other test files...
To run it in an HTML file, do something like this:
Fork Info
This package has been created from a fork of the Jest Project. It aggregates
the expect
, jest-mock
, and jest-each
packages, attaches them to the
window
, and does various other things to ensure that Jest runs similarly to
how it runs in Node. It also strips out lots of dependencies that only make
sense in a Node environment, resulting in a slimmer build.