Skip to content

Bring toJSON from native-testing-library #536

@acatalina

Description

@acatalina

Describe the Feature

toJSON helper would be handy when taking snapshots of components through queries.

We are trying to migrate to v7 from native-testing-library. We don't like relying on snapshots but we do sometimes get aimed snapshots on specific components. At the moment, it causes a circular problem if trying to assert a snapshot on a component, eg:

expect(getByTestId('testID')).toMatchSnapshot();

We use to be able to do this but I guess with NTL we weren't consuming the ReactTestInstance directly so probably the problem was mitigated.

Possible Implementations

https://github.com/testing-library/native-testing-library/blob/a8ba4166942072ee420e2c77b7e377a605481e6b/src/lib/to-json.js

Is it possible to recycle the code from native-testing-library? I don't mind creating a PR but I do not know if we can recycle the code and if the helper is appropriate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions