Jest preset for testing React components


2.0.02 years ago4 years agoMinified + gzip package size for @ta-interaktiv/jest-preset in KB


Jest Preset

Jest Preset for testing React components, using React 16, Enzyme and Jest-Enzyme.


yarn add jest @ta-interaktiv/jest-preset --dev


Add to package.json:

  "jest": {
    "preset": "@ta-interaktiv/jest-preset"

and, if necessary, under scripts:

"test": "jest"

Manipulating the virtual browser environment

Jest uses JSDOM to simulate a browser environment to test React components in.

In cases where the window.location is relevant for testing, it is set up to use https://interaktiv.tagesanzeiger.ch/2018/test-project/index .html#anchor – which, hopefully, should cover most bases.

You can change this property as follows:

jsdom.reconfigure({url: 'https://new.url.com/to-use.html#with-hash-if-needed'})

See in the enclosed __tests__/index.js how this works.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.