Socket
Socket
Sign inDemoInstall

enzyme-theme-utils

Package Overview
Dependencies
126
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    enzyme-theme-utils

Enzyme Theme Utilities


Version published
Weekly downloads
229
decreased by-14.23%
Maintainers
1
Install size
13.7 kB
Created
Weekly downloads
 

Readme

Source

Enzyme Theme Utils

npm install enzyme-theme-utils

Motivation

Testing React components that need to be wrapped in a ThemeProvider is a pain in the butt. So after lots of trial-and-error programming I created this module to rectify this. Essentially what it does is renders the ThemeProvider and it's children inside a wrapper. Then it adds context to the wrapped ThemeProvider. Then it extracts the children and adds the context from the ThemeProvider to the child and mounts it.

Usage

shallowWithTheme

import React from 'react'
import PropTypes from 'prop-types'
import { shallowWithTheme } from 'enzyme-theme-utils'

const someTheme = {
  colors: {
    red: 'red',
    yellow: 'yellow'
  }
}

describe('some themed component', () => {

  it('can be shallow rendered', () => {
    const test = shallowWithTheme(
      <SomeComponent/>,
      someTheme
    )

    // Assertions

  })
})

mountWithTheme

import React from 'react'
import PropTypes from 'prop-types'
import { mountWithTheme } from 'enzyme-theme-utils'

const someTheme = {
  colors: {
    red: 'red',
    yellow: 'yellow'
  }
}

describe('some themed component', () => {

  it('can be mounted', () => {
    const test = mountWithTheme(
      <SomeComponent/>,
      someTheme
    )

    // Assertions

  })
})

MIT License

FAQs

Last updated on 16 Aug 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc