Skip to content

Conversation

@mfazekas
Copy link
Contributor

@mfazekas mfazekas commented Jan 20, 2026

Summary

Adds coverage.root config option to fix 0% coverage in create-react-native-library and other monorepo setups.

Usage

// example/rn-harness.config.mjs
export default {
  coverage: {
    root: '..', // Point to parent where library src/ lives
  },
  // ...
};

Fixes #58

In create-react-native-library projects, tests run from example/ but
source files are in ../src/. babel-plugin-istanbul uses cwd as its root
and skips files outside it, causing 0% coverage.

Added coverageRoot config option to specify the root directory for
coverage instrumentation. This is passed to babel-plugin-istanbul's
cwd option.

Fixes callstackincubator#58
@vercel
Copy link

vercel bot commented Jan 20, 2026

@mfazekas is attempting to deploy a commit to the Callstack Team on Vercel.

A member of the Team first needs to authorize it.

@mfazekas
Copy link
Contributor Author

Perhaps this is a documentation-only issue? Instead of adding a new config option, we could just document that users can set NYC_CWD to change the root directory for coverage:

NYC_CWD=.. yarn test:harness:ios --coverage

This is a standard babel-plugin-istanbul/nyc environment variable and doesn't require any code changes.

Thoughts?

@V3RON
Copy link
Contributor

V3RON commented Jan 20, 2026

I believe this should go into the config file. Users shouldn't need to know exactly how coverage is implemented under the hood. I also wonder whether we have any other configuration properties related to coverage. If so, we might consider nesting root under coverage instead of using a flat coverageRoot 🤔

@mfazekas mfazekas marked this pull request as ready for review January 20, 2026 13:22
@V3RON V3RON merged commit 0f0ca1b into callstackincubator:main Jan 21, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--coverage reports 0% in create-react-native-library setups

2 participants