0

With the latest version (currently 2021.1) of PhpStorm when running tests it adds a coverage folder to my src directory.

It appears to be a code coverage report for all files. Is there a way to stop it doing that? I have never used it and often forget to add it to my .gitignore file and it often gets committed.

For us it is unnecessary.

EDIT 2021-06-03

As per LazyOne's comment below, it does seem to be jest.

I was unaware that it was a jest only issue as I don't use PHP at the moment (though still have the editor).

It only started happening on recent updates hence my confusion.

Setting the coverageDirectory to something different indeed moves the coverage folder.

Removing all coverage settings, and running a test with coverage still does create the folder.

Here is a screenshot of the folder that is being created looks like. enter image description here

Jest config is currently

{
  "globalSetup": "../jest.setup.ts",
  "setupFilesAfterEnv": ["../jest.setupFiles.ts"],
  "rootDir": "src",
  "moduleFileExtensions": ["js", "json", "ts"],
  "collectCoverage": true,
  "collectCoverageFrom": [
    "./**/*.{ts,js}",
    "!./**/tests/**/*",
    "!./**/mocks/**/*",
    "!./**/routes.*",
    "!./**/config/**/*",
    "!./**/__tests__/**/*",
    "!./**/__mocks__/**/*",
    "!./**/test/**/*",
    "!./**/exports.*",
    "!./src/coverage"
  ],
  "coverageReporters": ["text", "text-summary"],
  "coverageDirectory": "../coverage",
  "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(js|ts)x?$",
  "testPathIgnorePatterns": [],
  "transform": {
    "^.+\\.(ts)?$": "ts-jest"
  }
}

LazyOne
  • 158,824
  • 45
  • 388
  • 391
nzmattman
  • 465
  • 3
  • 15
  • 1
    Please clearly state what tests you are running (engine) / what coverage is created. As I understand it's about **Jest**? For example: for PHP / PHPUnit tests the IDE does not create such file (only created when "Run with Coverage" button is used and it's done in a temp folder). Other runners/engines may behave differently (but still, normally such stuff would not be created by the IDE in your sources folder -- most likely be your actual tests engine config, e.g. `jest.config.js` file -- `coverageDirectory: 'the-coverage'` (from https://youtrack.jetbrains.com/issue/WEB-48673)). – LazyOne Jun 02 '21 at 09:44
  • @LazyOne I have updated my question – nzmattman Jun 02 '21 at 19:49
  • Try with `"collectCoverage": false,` if you do not need it (and use just Run / *without* coverage). – LazyOne Jun 02 '21 at 20:04
  • i did try that, but running with coverage and that set as false still gives me the folder. I do want to check that I have full coverage of a file, I just don't want the folder created – nzmattman Jun 02 '21 at 20:30
  • Point to your project `temp` / `var` folder and keep it there (and clean it up on project build etc)? Or perhaps even outside of the project (system temp)? Sorry, no better ideas from me (not using Jest myself). – LazyOne Jun 02 '21 at 20:45
  • If you will get no better answers here: use `Help | Contact Support` in your IDE to contact JetBrains -- they should provide a better explanation on why and how to. – LazyOne Jun 03 '21 at 11:51
  • Is the question here, that you don't want to use .gitignore or git/info/exclude ? – Owen McAlack Jun 17 '21 at 16:07
  • Also, you've checked out Settings > Build, Execution, & Deployment > Cover ? These can be set for new projects as well from the File menu – Owen McAlack Jun 17 '21 at 16:10
  • @OwenMcAlack the question isn't git related, it is more that I just don't want the coverage report folder created when running a jest test with coverage, I just want the file highlighting. The `Build, Execution, & Deployment > Cover` area doesn't have any settings for this folder – nzmattman Jun 17 '21 at 20:10

0 Answers0