nodejs / nodejs/node

Test runner: --test-reporter-destination should create the folder if not found

Open
#64,994 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request test_runner
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

What is the problem this feature will solve?

Hi 👋

Fairly easy one:
I have node --test --experimental-code-coverage --test-reporter-destination="coverage/lcov.info" outputting the coverage file to the coverage folder.

However, if the coverage folder does not exist beforehand, an ENOENT is thrown.

Since storing the behavior of storing coverage in coverage/lcov.info, and having that folder in .gitignore is rather standard, it'd be nice to have Node creating the folder in which it will place the coverage report in case it doesn't exist.

Thanks :)

What is the feature you are proposing to solve the problem?

When writing coverage report, check if the destination folder exists, and if not, create it beforehand

What alternatives have you considered?
  • version controlling the coverage folder with a .gitkeep file, but it's cumbersome
  • Having the CLI test script in my package json create the folder itself, but that's quite inelegant to maintain for both Windows and Unix users
  • Switching to another test runner and losing all the charisma points that come with using the native one

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the provided node --test --experimental-code-coverage --test-reporter-destination="coverage/lcov.info" command when coverage does not exist. Trace the test runner's reporter-destination handling and verify that the destination folder is created before the coverage report is written, including when nested folders are needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, testing-qa
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.