sayayin
sayayin

Reputation: 1041

How to Debug Tests in React Native When Using Jest and Expo

I'm trying to setup some debugging for the tests in my app I'm building with React native on expo. I followed some instructions from online resources. Below are the settings from my package.json. When I run a test with this script node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand I see the break point hit in the chrome dev tools and on continuing I see some warnings on the console but not much else.

I'm not even sure what am I supposed to see. Would there be some output even when there is no error? Just in case I deliberately made an error in the test and still nothing on the console. May be it is because of those warnings?

Package.json

 "jest": {
    "preset": "jest-expo",
    "transformIgnorePatterns": [
      "node_modules/(?!(jest-)?react-native|react-clone-referenced-element|@react-native-community|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|@sentry/.*)"
    ]

enter image description here

Upvotes: 1

Views: 1388

Answers (1)

JenB
JenB

Reputation: 11

You need to open chrome://inspect in Chrome, you should be on the Devices tab, then click Open dedicated DevTools for Node

It also helps to put debugger; in your source where you want it to break.

Chrome Screen Shot

Upvotes: 1

Related Questions