istanbuljs / nyc

the Istanbul command line interface
https://istanbul.js.org/
ISC License
5.59k stars 359 forks source link

Code coverage is not instrumenting React components (React Native) #1542

Open z7edge opened 9 months ago

z7edge commented 9 months ago

I am using Detox with Cucumber for BDD test report. All test feature is working fine. Then I installed nyc plugin for generating detailed test coverage report but that is not instrumenting React components (such as App.js). While using with jest it is working as expected but for some technical reasons we have to use it with Cucumber test.

Link to bug demonstration repository

Screenshot 2023-12-21 at 10 44 48 AM

Expected Behavior

Instrumentation of all the React components should happen.

Observed Behavior

All the React functional component code is going in Uncovered Line column of the coverage report.

Troubleshooting steps

Environment Information


# paste the output here

System:
    OS: macOS 14.1.1
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 27.83 MB / 16.00 GB
  Binaries:
    Node: 16.15.0 - /usr/local/bin/node
    Yarn: 1.22.18 - /usr/local/bin/yarn
    npm: 8.5.5 - /usr/local/bin/npm
  npmPackages:
    @babel/core: ^7.20.0 => 7.23.2 
    @babel/preset-env: ^7.20.0 => 7.23.2 
    @babel/register: ^7.22.15 => 7.22.15 
    @babel/runtime: ^7.20.0 => 7.23.2 
    @istanbuljs/nyc-config-babel: ^3.0.0 => 3.0.0 
    babel-jest: ^29.2.1 => 29.7.0 
    babel-plugin-istanbul: ^6.1.1 => 6.1.1 
    metro-react-native-babel-preset: 0.76.8 => 0.76.8 
    nyc: ^15.1.0 => 15.1.0 
    typescript: 4.8.4 => 4.8.4