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

Coverage seems to run twice each test #6265

Open
youf-olivier opened this issue Jan 24, 2019 · 7 comments
Open

Coverage seems to run twice each test #6265

youf-olivier opened this issue Jan 24, 2019 · 7 comments

Comments

@youf-olivier
Copy link

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes

Which terms did you search for in User Guide?

test jest coverage

Environment

Environment Info:

System:
OS: Windows 7
CPU: x64 Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz
Binaries:
Yarn: 1.7.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
Browsers:
Internet Explorer: 11.0.9600.19236
npmPackages:
react: 16.7.0 => 16.7.0
react-dom: 16.7.0 => 16.7.0
react-scripts: 2.1.3 => 2.1.3
npmGlobalPackages:
create-react-app: Not Found

Steps to Reproduce

npx create-react-app my-app-test
cd my-app-test\
npm run test -- --coverage

Expected Behavior

image

Actual Behavior

image

Actually, I had this problem last year, I could resolve it because I had Jest in Dev Dependencies, and it seems to be problematic.
But, now I have the same problem, but whatever the configuration. For example, with just a fresh install, I got this problem, locally on my machine, but also in VSTS during the build step... And I'm not the only one in my company.

@trendfollowerpl
Copy link

trendfollowerpl commented Feb 4, 2019

Actually we have exactly the same issue with ts and tsx files.
config: we use:
"scripts": { "pretest:CI": "react-scripts test --clearCache", "test:CI": "SET CI=true && react-scripts test --env=jsdom --coverage --coverageDirectory=./reports/coverage" }

"jest-junit": { "suiteName": " unit tests", "outputDirectory": "./reports", "outputName": "./junit.xml", "classNameTemplate": "{classname}-{title}", "titleTemplate": "{classname}-{title}", "ancestorSeparator": " › ", "usePathForSuiteName": "true" }

"jest": { "collectCoverageFrom": [ "src/**/*.{ts,tsx}" ]},

`"coverageReporters": [
  "text",
  "cobertura",
  "html"
]`

Env versions:
"react-scripts": "2.1.3",
nodejs : 10.15.0

@jorgegonzalez
Copy link

Same issue here. And the coverage directory has the files that are in my src twice, one nested in a sort of “temp” folder.

@trendfollowerpl
Copy link

trendfollowerpl commented Feb 6, 2019

We have a workaround for this issue.
Our dev environment is Windows-based an we’ve noticed that duplicated files are taken from for example : D:\src\file.spec.ts AND d:\src\file.spec.ts (notice how drive letter is written).

When we tried to execute tests directly via jest we got error message that pointed this drive letter issue. This is message somehow swallowed by react-scripts test script.

To the point: temporary solution is to use: driveup npm package
Currently our test script starts with :

driveup && react-scripts test

@jorgegonzalez
Copy link

I am also on Windows, btw.

@trendfollowerpl
Copy link

Can we expect any update on this one?

@ianschmitz
Copy link
Contributor

It may be worth trying the 3.0 alpha which includes Jest 24. There's a chance it may fix this issue.

@jorgegonzalez
Copy link

Upgrading to the alpha did not work in my case @ianschmitz

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

5 participants
@ianschmitz @jorgegonzalez @trendfollowerpl @youf-olivier and others