How to use enzyme-adapter-react-15 - 10 common examples

To help you get started, we’ve selected a few enzyme-adapter-react-15 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 poanetwork / token-wizard / test / components / Crowdsales / index.spec.js View on Github external
import React from 'react'
import Adapter from 'enzyme-adapter-react-15'
import { configure, shallow, mount } from 'enzyme'
import { Crowdsales } from '../../../src/components/Crowdsales'
import { CrowdsalesList } from '../../../src/components/Crowdsales/CrowdsalesList'
import { crowdsaleStore, contractStore, web3Store, generalStore } from '../../../src/stores'
import { Provider } from 'mobx-react'
import renderer from 'react-test-renderer'

configure({ adapter: new Adapter() })

describe('Crowdsales', () => {
  const stores = { crowdsaleStore, web3Store, generalStore, contractStore }

  it('should render screen ', () => {
    // Given
    const tree = renderer.create(
      
        
      
    )

    // When
    const treeJson = tree.toJSON()

    // Then
github coralproject / talk / test / client / setupJest.js View on Github external
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-15';

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

// Storage Mock

// TODO: Some places in our code (e.g. translations) has a hardcoded dependency
// to the local storage. Fixing it and we can remove this global mock.

function storageMock() {
  let storage = {};

  return {
    setItem: function(key, value) {
      storage[key] = value || '';
    },
    getItem: function(key) {
      return key in storage ? storage[key] : null;
    },
github sprjr / react-access / test / setup / setup.js View on Github external
import { configure } from 'enzyme';
import { JSDOM } from 'jsdom';

// enzyme requires special adapters now that are in different modules
// as opposed to different imports, so we need to configure it based on
// which React version we're testing
if (process.env.REACT_VERSION === '^15.4.0') {
  const Adapter = require('enzyme-adapter-react-15.4');
  configure({ adapter: new Adapter() });
} else if (process.env.REACT_VERSION === '<15.4.0 >15.0.0') {
  const Adapter = require('enzyme-adapter-react-15');
  configure({ adapter: new Adapter() });
} else {
  const Adapter = require('enzyme-adapter-react-16');
  configure({ adapter: new Adapter() });
}

module.exports = function(root) {
  root = root ? root : global;
  root.expect = root.chai.expect;

  const dom = new JSDOM('');
  root.window = dom.window;
  root.document = dom.window.document;


  beforeEach(() => {
    // Using these globally-available Sinon features is preferrable, as they're
github OpusCapita / fsm-workflow / packages / editor / src / components / TopForm.spec.js View on Github external
import React from 'react';
import { expect } from 'chai';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-15';
import { mount } from 'enzyme';
import sinon from 'sinon';
import FormControl from 'react-bootstrap/lib/FormControl';
import TopForm from './TopForm.react';
import { I18nManager } from '@opuscapita/i18n';

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

describe('', () => {
  it('renders top form', () => {
    const props = {
      name: 'Invoice workflow',
      onNameChange: sinon.spy()
    };

    const wrapper = mount(, { context: { i18n: new I18nManager() } });
    expect(wrapper).to.exist; // eslint-disable-line no-unused-expressions
    expect(wrapper.contains(FormControl)).to.be.true; // eslint-disable-line no-unused-expressions
    expect(wrapper.find(FormControl).prop('value')).to.equal(props.name);
    expect(wrapper.find(FormControl).prop('onChange')).to.equal(props.onNameChange);
  });
});
github pivotal-cf / pivotal-ui / styleguide / spec / support / matchers / jest_react.js View on Github external
import React from 'react';
import {configure as configureEnzyme, mount} from 'enzyme';
import Adapter from 'enzyme-adapter-react-15';
configureEnzyme({adapter: new Adapter()});
import {matcherResult} from './common';
import jestDiff from 'jest-diff';

const root = document.createElement('div');
document.body.appendChild(root);

let lastRendered;
const testRender = element => {
  lastRendered = mount(element, {attachTo: root});
  // eslint-disable-next-line no-console
  lastRendered.print = () => console.log(lastRendered.debug());
  return lastRendered;
};

const testReset = () => {
  lastRendered && lastRendered.unmount();
github studentinsights / studentinsights / ui / config / setupTests.js View on Github external
// This is a configuration file for Jest
import './sprockets-shims.js';
import '../legacy.js';

// Enzyme support
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-15.4';
Enzyme.configure({ adapter: new Adapter() });

// These are for MountTimer and measurePageLoad.
// See https://gist.github.com/ShirtlessKirk/eb41720a797411defae6
import './performance-timing-api.js';
import {performance} from 'perf_hooks';
global.performance = performance;

// https://github.com/jefflau/jest-fetch-mock
global.fetch = require('jest-fetch-mock'); // eslint-disable-line no-undef

// Make console.warn and error fail tests
console.error = jest.fn(error => { throw new Error(error); }); //eslint-disable-line no-console
console.warn = jest.fn(warn => { throw new Error(warn); }); //eslint-disable-line no-console

// Make test fail if code is reporting errors to Rollbar
window.Rollbar = {
github rnosov / react-reveal / __tests__ / in-and-out / Bounce.js View on Github external
/*
 * Bounce Component Test Suite
 *
 * Copyright © Roman Nosov 2016
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.txt file in the root directory of this source tree.
 */
import Bounce from '../../Bounce';

import React from 'react';
import { shallow } from 'enzyme';
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-15';

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

describe('Bounce', () => {
  it('renders a initial view', () => {
    const content = shallow(
      
        <div>Test test</div>
      
    );
    expect(content.html()).toMatchSnapshot();
  });
});
github poanetwork / token-wizard / test / components / Manage / index.spec.js View on Github external
import { MemoryRouter } from 'react-router'
import { Manage } from '../../../src/components/Manage/index'
import {
  crowdsaleStore,
  web3Store,
  tierStore,
  contractStore,
  reservedTokenStore,
  stepTwoValidationStore,
  generalStore,
  tokenStore,
  gasPriceStore,
  deploymentStore
} from '../../../src/stores'

configure({ adapter: new Adapter() })

describe('Manage index', () => {
  const stores = {
    crowdsaleStore,
    web3Store,
    tierStore,
    contractStore,
    reservedTokenStore,
    stepTwoValidationStore,
    generalStore,
    tokenStore,
    gasPriceStore,
    deploymentStore
  }

  it(`should render Manage`, () => {
github poanetwork / token-wizard / test / components / Common / Error.spec.js View on Github external
import React from 'react'
import { Error } from '../../../src/components/Common/Errors'
import { Form } from 'react-final-form'
import Adapter from 'enzyme-adapter-react-15'
import { configure, mount, shallow } from 'enzyme'
import renderer from 'react-test-renderer'
import { FORM_ERROR } from 'final-form'
import {validateTierMinCap} from "../../../src/utils/validations";

configure({ adapter: new Adapter() })

describe('Error ', () => {

  const errorStyle = {
    color: 'blue',
    fontWeight: 'bold',
    fontSize: '24px',
    width: '50%',
    height: '10px'
  }


  it(`should render Error component`, () => {
    const getErrors = () =>{
      return FORM_ERROR
    }

enzyme-adapter-react-15

JavaScript Testing utilities for React

MIT
Latest version published 2 years ago

Package Health Score

62 / 100
Full package analysis

Popular enzyme-adapter-react-15 functions