How to use the jest-emotion.createMatchers function in jest-emotion

To help you get started, we’ve selected a few jest-emotion examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mineral-ui / mineral-ui / utils / setupTestFrameworkScript.js View on Github external
import React from 'react';
import Enzyme from 'enzyme';
import * as emotion from 'emotion';
import { createMatchers, createSerializer } from 'jest-emotion';
import semver from 'semver';

expect.addSnapshotSerializer(createSerializer(emotion));
expect.extend(createMatchers(emotion));

// Configure Enzyme for appropriate React version
let Adapter;
if (semver.satisfies(React.version, '15.0.0 - 15.4.x')) {
  Adapter = require('enzyme-adapter-react-15.4');
} else if (semver.satisfies(React.version, '^15.5.0')) {
  Adapter = require('enzyme-adapter-react-15');
} else if (semver.satisfies(React.version, '^16.0.0')) {
  Adapter = require('enzyme-react-adapter-future');
}
Enzyme.configure({ adapter: new Adapter() });

window.scroll = jest.fn();
github jxnblk / superbox / test / emotion.js View on Github external
import React from 'react'
import { create as render } from 'react-test-renderer'
import { renderIntoDocument } from 'react-dom/test-utils'
import { createSerializer, createMatchers } from 'jest-emotion'
import * as emotion from 'emotion'
import Box from '../dist/emotion'

expect.addSnapshotSerializer(createSerializer(emotion))
expect.extend(createMatchers(emotion))

const renderJSON = el => render(el).toJSON()

describe('superbox/emotion', () => {
  test('renders', () => {
    const box = renderJSON()
    expect(box).toMatchInlineSnapshot(`
<div>
`)
  })

  test('renders with styles', () =&gt; {
    const box = renderJSON(
      </div>
github primer / components / src / utils / test-matchers.js View on Github external
import {createMatchers, createSerializer} from 'jest-emotion'
import * as emotion from 'emotion'
import {styles as systemProps} from 'styled-system'
import {getClasses, getClassName, getComputedStyles, render} from './testing'

expect.extend(createMatchers(emotion))
expect.addSnapshotSerializer(createSerializer(emotion))

const stringify = d => JSON.stringify(d, null, '  ')

/**
 * These are props that styled-system aliases for backwards compatibility.
 * For some reason, they don't show up in our toImplementSystemProps() matcher,
 * so we skip over them.
 */
const ALIAS_PROP_TYPES = ['w', 'align', 'justify', 'wrap']

expect.extend({
  toMatchKeys(obj, values) {
    return {
      pass: Object.keys(values).every(key => this.equals(obj[key], values[key])),
      message: () => `Expected ${stringify(obj)} to have matching keys: ${stringify(values)}`

jest-emotion

Jest utilities for emotion

MIT
Latest version published 3 years ago

Package Health Score

78 / 100
Full package analysis