Code Coverage in NX monorepo with Playwright CT React
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- playwright, react, typescript, vite
Research direction
Start with the supplied ctViteConfig and compare how Playwright CT React loads its Vite plugins with the vite-plugin-istanbul configuration shown. Verify whether the custom plugin hooks run for the component-test sources and whether coverage is generated; done means the relevant source is instrumented and a coverage report is produced.
Written by the indexing model from the issue text.
Description
I've been looking for a way to get code coverage report for my component tests that use @playwright/experimental-ct-react , and I've followed the guide mentioned here, but it seems, the vite-instanbul-plugin isn't able to transform the relevant code.
I added a custom plugin to debug if transform would happen, but the callback doesn't trigger.
Here'e my ctViteConfig :
ctViteConfig: {
plugins: [
react(),
// Custom debug plugin to check if plugins are loading
{
name: 'debug-plugin-loader',
configResolved(config: any) {
console.log('🔧 DEBUG: Plugin loaded - configResolved hook called');
console.log(
'🔧 DEBUG: Vite config plugins:',
config.plugins?.map((p: any) => p.name || 'unnamed'),
);
console.log('🔧 DEBUG: Environment:', config.env);
console.log('🔧 DEBUG: Command:', config.command);
console.log('🔧 DEBUG: Mode:', config.mode);
},
buildStart() {
console.log('🚀 DEBUG: Build started - buildStart hook called');
},
transform(code: string, id: string) {
if (id.includes('/src/') && (id.endsWith('.tsx') || id.endsWith('.ts'))) {
console.log('🔄 DEBUG: Transforming file:', id);
console.log('🔍 DEBUG: Code sample (first 100 chars):', code.substring(0, 100));
// Check if Istanbul has already instrumented this code
const isInstrumented = code.includes('__cov_') || code.includes('__coverage__');
console.log('📊 DEBUG: File instrumented by Istanbul:', isInstrumented);
}
return null; // Don't modify the code, just log
},
generateBundle() {
console.log('📦 DEBUG: Bundle generation - generateBundle hook called');
},
},
istanbul({
include: 'src/**/*',
exclude: ['node_modules', 'test', '**/*.spec.*', '**/*.story.*'],
extension: ['.js', '.jsx', '.ts', '.tsx'],
requireEnv: false,
forceBuildInstrument: true,
checkProd: false,
}),
] as any,
build: {
sourcemap: true,
},
},
Relevant package versions :
@playwright/experimental-ct-react: 1.56.1
playwright: 1.56.1
vite-plugin-istanbul: 7.2.0
Any pointers that would help me with this?
- Dominant language
- TypeScript
- Stars
- 143
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mxschmitt/playwright-test-coverage
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
mxschmitt/playwright-test-coverage#22 · 1 comment · 1 reaction ·
-
Example with Remix Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
mxschmitt/playwright-test-coverage#21 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
mxschmitt/playwright-test-coverage#17 · 6 comments ·
All issues in mxschmitt/playwright-test-coverage
Similar issues
-
comp/dashboard P3 type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
NousResearch/hermes-agent#117722 ·
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 76/100
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·