How to include @testing-library/react-native and @testing-library/react?
GeorgeDavidTito opened this issue · 3 comments
Hi,
I'm trying to install @testing-library/react-native and @testing-library/react.
The native test works fine, but the web test fails, maybe I need to add a special configuration for the web, it would be nice to have this information available.
The scripts from the package.json file :
scripts": {
"web": "node scripts/start.js",
"test:web": "node scripts/test.js",
"build": "node scripts/build.js",
"start": "react-native start",
"start-clean": "rm -rf $TMPDIR/react-* && watchman watch-del-all && npm start -- --reset-cache",
"test": "npm run test:web && npm run test:native",
"android": "react-native run-android",
"ios": "react-native run-ios",
"test:native": "node_modules/.bin/jest -c ./config/jest/jest.config.native.js"
}
I set @testing-library/react-native for the test:native
script as suggested by site, this script passes test well, but when it runs the test:web
script breaks. How can I include @testing-library/react for the web test? I'm assuming the project should have a jest.config.web.js file to tailor the test as expo using jest-expo/web.
Error:
Hi @davidtito1992,
Could you explain in more details,
What did you mean by "The native test works fine, but the web test fails,"?
What did you do, what did you expect that would happen and what actually happened?
Did you get any error messages you can share?
Thanks
Ok, thanks. I already edited the description.
Hi @davidtito1992 ,
The issue you're having is that babel/webpack is not parsing/compiling the files.. usually jest uses babel directly and does not use webpack.
I haven't used testing library my self but with jest you usually need to add or have 2 different config files (that's what expo does inside) for native and web