Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mount with react native doesn't work #2094

Closed
2 of 13 tasks
yaizudamashii opened this issue Apr 11, 2019 · 1 comment
Closed
2 of 13 tasks

mount with react native doesn't work #2094

yaizudamashii opened this issue Apr 11, 2019 · 1 comment

Comments

@yaizudamashii
Copy link

yaizudamashii commented Apr 11, 2019

Using jest with enzyme and react native

I've followed the instructions in (did not add jsdom stuff in setup-tests.js as I'm using jest)
https://github.com/airbnb/enzyme/blob/master/docs/guides/react-native.md
And mount should work, according to the documentation. Please advise.

The stripped down test file as below.

/**
 * @jest-environment jsdom
 */
import React from 'react';
import { ScrollView } from 'react-native';
import { mount } from 'enzyme';

describe('Card', () => {
    let wrapper;
    describe('copy', () => {
        it('should render text', () => {
            const tree = mount(
                <ScrollView>
                </ScrollView>
            );
            expect(tree).toMatchSnapshot();
        });
    )};
)};

Current behavior

 Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: symbol.

    > 52 |             const tree = mount(
         |                                    ^
      53 |                 <ScrollView>
      54 |                 </ScrollView>
      55 |             );

Expected behavior

Should be able to mount react native component

Your environment

API

  • shallow
  • mount
  • render

Version

library version
enzyme 3.9.0
react 16.4.1
react-dom 16.0.0
react-test-renderer 16.0.0
adapter (below) 1.10.0

react-native: 0.56.0
jest: 23.2.0

Adapter

  • enzyme-adapter-react-16
  • enzyme-adapter-react-16.3
  • enzyme-adapter-react-16.2
  • enzyme-adapter-react-16.1
  • enzyme-adapter-react-15
  • enzyme-adapter-react-15.4
  • enzyme-adapter-react-14
  • enzyme-adapter-react-13
  • enzyme-adapter-react-helper
  • others ( )
@ljharb
Copy link
Member

ljharb commented Apr 12, 2019

Without an actual react-native adapter, it's not going to be reliable to use RN with enzyme. Follow #1436 for that.

@ljharb ljharb closed this as completed Apr 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants