Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Component tests not collecting coverage from components situated in folders above or at the same level of the playwright project #34474

Open
GeneratorX16 opened this issue Jan 25, 2025 · 0 comments
Assignees

Comments

@GeneratorX16
Copy link
Contributor

GeneratorX16 commented Jan 25, 2025

Version

1.50.0

Steps to reproduce

  1. Clone my repo at https://github.com/GeneratorX16/playwright-component-test-issue/tree/main
  2. cd into component-tests and run npm install
  3. cd into my-react-app and run npm install
  4. cd into component-tests
  5. Run npm run test-ct (may give wrong results the first time, then run again)
  6. To generate nyc output for code coverage report, run npx nyc report --reporter=text

Expected behavior

I expect it to collect coverage from the components in my-react-app too.

Actual behavior

It is collecting coverage only from the components inside the playwright project. I want it to collect coverage from other directories too.

Additional context

I have been tasked to run component tests on a component library which is internal to us. I want to have minimum interference with their projects and directory, so I cannot place tests inside the place where their components exist. I can do this at runtime for just tests, but that is a lot of grunt work and not an efficient workflow. The component tests work correctly, but I am not at all able to collect overage of the components that they have developed.

I have followed the steps from the recommended repo https://github.com/mxschmitt/playwright-test-coverage/tree/ct-react-vite?tab=readme-ov-file#use-istanbul-coverage-collection-with-playwright-component-testing-react

The project uses react17 and @playwright/experimental-ct-react17.

This is what my project structure looks like:

Root
|_______Main-Components
               |__componentA
               |__componentB...
|_______playwright Component Testing Project
               |_wrapper-component-folder
               |_tests

This wa, it only collects coverage from the wrapper-components-folder, instead of the Main-Components.
Changing the nyc config in the vite-pugin-istabul also has no effect.
I cannot upgrade node or npm to a version above the 16.20.2
Can you recommend me any way to do this ?

Environment

System: 
 OS: Linux 5.15 Amazon Linux 2
 CPU: (4) x64 Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz
 Container: Yes
Binaries:
 Node: 16.20.2
 Yarn: 1.22.22
 npm: 8.19.4
npmPackages:
 @playwright/experimental-ct-react17: ^1.49.0 => 1.50.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants