JSPM

react-router-test-context

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5002
  • Score
    100M100P100Q117562F
  • License MIT

Create a pseudo context to assist in testing components that render React Router's location-aware components.

Package Exports

  • react-router-test-context

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 (react-router-test-context) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-router-test-context

Create a pseudo context object that duplicates React Router's context.router structure. This is useful for shallow unit testing with Enzyme.

Usage

import createRouterContext from 'react-router-test-context'
import { shallow } from 'enzyme'

describe('my test', () => {
  it('renders', () => {
    const context = createRouterContext()
    const wrapper = shallow(<MyComponent />, { context })
    // ...
  })
})