Giter VIP home page Giter VIP logo

Comments (11)

mdjastrzebski avatar mdjastrzebski commented on June 14, 2024 1

@pedrohamarques This looks like a potential setup issue, has RNTL generally supports the latest RN versions. In order to help you diagnose the issue, I would need to be able to reproduce it locally. Could you prepare a minimal reproduction repo?

from react-native-testing-library.

pedrohamarques avatar pedrohamarques commented on June 14, 2024 1

Yeah, it was a wrong setup by my part. Following some tutorial I added the second and third preset in babel.config. I removed them and it worked properly.

This was my file:

module.exports = function (api) {
	api.cache(true);
	return {
		presets: [
			'babel-preset-expo',
			['@babel/preset-env', { targets: { node: 'current' } }],
			'@babel/preset-typescript',
		],
		plugins: ['nativewind/babel'],
	};
};

from react-native-testing-library.

valn1 avatar valn1 commented on June 14, 2024

it looks like this change in my babel.config file caused the errors
image
i have no idea why tho, i imagine it should work fine

from react-native-testing-library.

valn1 avatar valn1 commented on June 14, 2024

rolling that line back seems to have fixed the issue for me, but still, this should not happen.
i made that change because the react-native upgrade helper told me to do so. here is the commit in react-native that made that change from react-native 0.72.10 to 0.73.0
facebook/react-native@d380bb8

from react-native-testing-library.

mdjastrzebski avatar mdjastrzebski commented on June 14, 2024

@valn1, would you be able to produce a minimal reproduction repository based either on the latest RN CLI? It's hard to give any recommendation without being able to reproduce the issue you are having. That might also help you with diagnosing the issue.

from react-native-testing-library.

pedrohamarques avatar pedrohamarques commented on June 14, 2024

I'm facing the same problem. But I started a project one week ago and it was already on RN 0.73.4. All the other packages are at the same version of the issue's author.

I don't know if it will help, but here is a example:

export function Loading() {
	return (
		<View className="flex-1 items-center justify-center bg-slate-900">
			<ActivityIndicator color={colors.white} testID='components.loading.activity-indicator'/>
		</View>
	);
}

And here is the test:

describe('components/loading/<Loading />', () => {
  it('renders the loading properly', () => {
    render(<Loading />)

    expect(screen.getByTestId('components.loading.activity-indicator')).toBeTruthy();
  })
})

And here's the error:

src/components/__tests__/loading.test.tsx
  components/loading/<Loading />
    × renders the product properly (300 ms)

  ● components/loading/<Loading /> › renders the product properly

    Trying to detect host component names triggered the following error:

    Unexpected token 'export'

    There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.
    Please check if you are using compatible versions of React Native and React Native Testing Library.

       9 |
      10 |   it('renders the product properly', () => {
    > 11 |     render(<Loading />)
         |           ^
      12 |
      13 |     expect(screen.getByTestId('components.loading.activity-indicator')).toBeTruthy();
      14 |   })

      at detectHostComponentNames (node_modules/@testing-library/react-native/src/helpers/host-component-names.tsx:56:11)
      at detectHostComponentNames (node_modules/@testing-library/react-native/src/helpers/host-component-names.tsx:27:30)
      at renderInternal (node_modules/@testing-library/react-native/src/render.tsx:49:40)
      at renderInternal (node_modules/@testing-library/react-native/src/render.tsx:32:10)
      at Object.<anonymous> (src/components/__tests__/loading.test.tsx:11:11)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        3.192 s

from react-native-testing-library.

abhishekgoel101 avatar abhishekgoel101 commented on June 14, 2024

Facing same issue

from react-native-testing-library.

pedrohamarques avatar pedrohamarques commented on June 14, 2024

Facing same issue

@abhishekgoel101 , do your babel.config looks like mine in the previous comment?

from react-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.