Giter Site home page Giter Site logo

Comments (8)

manakuro avatar manakuro commented on August 18, 2024 1

Hi sorry for the late reply. I'm going to work on it this week.

from native-testing-library.

lewie9021 avatar lewie9021 commented on August 18, 2024

Hi @manakuro,

I've not personally used baseElement before, but judging by your intentions in the tests, you're probably after using the named export toJSON from the library like so:

import 'react-native'
import React from 'react'
import App from 'app/src/App'
import { render, toJSON } from '@testing-library/react-native'

it('renders correctly', () => {
  const { baseElement } = render(<App />)
  expect(toJSON(baseElement)).toMatchSnapshot()
})

If that doesn't work, try using container instead of baseElement - it's probably a better option for your use case:

import 'react-native'
import React from 'react'
import App from 'app/src/App'
import { render, toJSON } from '@testing-library/react-native'

it('renders correctly', () => {
  const { container } = render(<App />)
  expect(toJSON(container)).toMatchSnapshot()
})

Hope that helps!

from native-testing-library.

bcarroll22 avatar bcarroll22 commented on August 18, 2024

Thanks for jumping in Lewis πŸ‘

@manakuro sorry for the delay. So, this one just looks like an issue with the typings actually. I’m not a typescript user myself, so would you mind helping out by creating a PR to fix the type issues you’re running into? I can support that effort however necessary to allow these to be correct πŸ’―

After the typings are fixed, what you did should work. Until the typings are fixed, even what Lewis suggested won’t work without compile errors.

from native-testing-library.

manakuro avatar manakuro commented on August 18, 2024

Hi @lewie9021
Thank you for your suggestions. I tried to use container and toJSON as you said but there still are a typing error.

@bcarroll22 Hi, thank you for the reply. Okay I'll create a PR to fix it. πŸ‘

Thank you for your guys help !

from native-testing-library.

bcarroll22 avatar bcarroll22 commented on August 18, 2024

Awesome! Thanks for your help. I should be able to get it reviewed and merged today.

from native-testing-library.

aleph-naught2tog avatar aleph-naught2tog commented on August 18, 2024

Hi, any update on this?

from native-testing-library.

aleph-naught2tog avatar aleph-naught2tog commented on August 18, 2024

@manakuro No worries at all, I just didn't see an update and was worried I'd missed something :)

from native-testing-library.

bcarroll22 avatar bcarroll22 commented on August 18, 2024

πŸŽ‰ This issue has been resolved in version 4.0.3 πŸŽ‰

The release is available on:

Your semantic-release bot πŸ“¦πŸš€

from native-testing-library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.