Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stevenfitzpatrick/enzyme-context-helpers
Helper functions for enzyme to mock Styled Components Themes and React Router
https://github.com/stevenfitzpatrick/enzyme-context-helpers
3rd-party-libs context enzyme helpers react-router styled-components
Last synced: 29 days ago
JSON representation
Helper functions for enzyme to mock Styled Components Themes and React Router
- Host: GitHub
- URL: https://github.com/stevenfitzpatrick/enzyme-context-helpers
- Owner: stevenfitzpatrick
- License: mit
- Created: 2018-03-22T20:37:05.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-06-02T23:52:36.000Z (over 4 years ago)
- Last Synced: 2024-11-15T02:54:12.024Z (about 2 months ago)
- Topics: 3rd-party-libs, context, enzyme, helpers, react-router, styled-components
- Language: JavaScript
- Homepage:
- Size: 1.36 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# enzyme-context-helpers
[![Greenkeeper badge](https://badges.greenkeeper.io/stevenfitzpatrick/enzyme-context-helpers.svg)](https://greenkeeper.io/)
## 💻 Installation
First include the dependency in your project as dev-dependency.
npm
```bash
$ npm i @sfitzpatrick/enzyme-context-helpers -D
```Yarn
```bash
$ yarn add @sfitzpatrick/enzyme-context-helpers -D
```## 📦 Usage
### Styled Components
First you need to `init` once to pass your Styled Components theme.
```js
import { init } from '@sfitzpatrick/enzyme-context-helpers';
// Change path to where your Theme is saved
import theme from '../src/theme/theme';init({ theme });
```Then when you want test your styled components, which are dependent on theme context, you can use the following helpers to test with `shallow` and `mount`. These functions will automatically inject the Theme into your components.
```js
import {
mountWithTheme,
shallowWithTheme,
renderWithTheme
} from '@sfitzpatrick/enzyme-context-helpers';const mountedWrapper = mountWithTheme(component);
const shallowWrapper = shallowWithTheme(component);
const snapshotWrapper = renderWithTheme(component).toJSON();
```## 👊 Author
* Steven Fitzpatrick [@Fitzy_longhorn](https://twitter.com/Fitzy_longhorn)
## 📃 License
This project is licensed under the MIT License - see the [Licence.md](Licence.md) file for details.
## 📜 Change log
The change log can found on the [CHANGELOG](https://github.com/stevenfitzpatrick/enzyme-context-helpers/blob/master/CHANGELOG.md) page.
## ✍️ Contributions
Feel free to contribute and submit pull requests.test