How to use the jest-emotion.createSerializer 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 anarock / pebble / tests / __setup__ / setupFramework.ts View on Github external
import * as emotion from "emotion";
import { createSerializer } from "jest-emotion";
import Enzyme from "enzyme";
import Adapter from "enzyme-adapter-react-16";
import { createSerializer as enzymeSerializer } from "enzyme-to-json";

// @ts-ignore
expect.addSnapshotSerializer(enzymeSerializer({ mode: "deep" }));

Enzyme.configure({ adapter: new Adapter() });

expect.addSnapshotSerializer(createSerializer(emotion));
github sumup-oss / circuit-ui / jest.setup.js View on Github external
};

// This is defined by webpack in storybook builds using the DefinePlugin plugin.
global.STORYBOOK = false;

global.__DEV__ = false;
global.__PRODUCTION__ = false;
global.__TEST__ = true;

// Add custom matchers
expect.extend(toHaveNoViolations);

// Add a snapshot serializer that removes random hashes
// from emotion class names.
expect.addSnapshotSerializer(
  createSerializer({
    classNameReplacer(className, index) {
      return `circuit-${index}`;
    }
  })
);
github bcgov / devhub-app-web / app-web / config / setupTests.js View on Github external
You may obtain a copy of the License at 

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Created by Patrick Simonian
*/
import * as emotion from 'emotion';
import { createSerializer } from 'jest-emotion';

expect.addSnapshotSerializer(createSerializer(emotion));
// mock out graph ql
global.graphql = jest.fn();
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 netlify / netlify-cms / setupTestFramework.js View on Github external
/* eslint-disable emotion/no-vanilla */
import '@testing-library/jest-dom/extend-expect';
import fetch from 'node-fetch';
import * as emotion from 'emotion';
import { createSerializer } from 'jest-emotion';

window.fetch = fetch;
expect.addSnapshotSerializer(createSerializer(emotion));
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)}`
    }
github mineral-ui / mineral-ui / utils / setupTestFrameworkScript.ts View on Github external
import Enzyme from 'enzyme';
import * as emotion from 'emotion';
import { matchers, createSerializer } from 'jest-emotion';
import Adapter from 'enzyme-adapter-react-16';
import { canUseDOM } from 'exenv';

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

Enzyme.configure({ adapter: new Adapter() });

if (canUseDOM) {
  window.scroll = jest.fn();
}
github Autodesk / hig / packages / jest-preset / setupTests.js View on Github external
require("jest-enzyme");
require("jest-extended");
const createSerializer = require("jest-emotion").createSerializer;
const emotion = require("emotion");

require("./matchers");
require("./utils");

expect.addSnapshotSerializer(createSerializer(emotion));
github twilio-labs / paste / .jest / setupFilesAfterEnv.js View on Github external
const emotion = require('emotion');
const {createSerializer} = require('jest-emotion');
const Enzyme = require('enzyme');
const Adapter = require('enzyme-adapter-react-16');
const {toHaveNoViolations} = require('jest-axe');
expect.extend(toHaveNoViolations);

expect.addSnapshotSerializer(createSerializer(emotion));
Enzyme.configure({adapter: new Adapter()});

jest-emotion

Jest utilities for emotion

MIT
Latest version published 4 years ago

Package Health Score

78 / 100
Full package analysis