approvals / approvals/ApprovalTests.cpp

`APPROVAL_TESTS_USE_REPORTER` should override the default reporter

Open
#242 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
339
Forks
55
PR merge metrics
No merged PRs in 30d

Description

My entire team prefers to use just the TextDiffReporter for day-to-day development, so we would like to do this in the code:

auto defaultReporter = ApprovalTests::Approvals::useAsFrontLoadedReporter(
                          std::make_shared<ApprovalTests::TextDiffReporter>());

However we would also like to use the APPROVAL_TESTS_USE_REPORTER environment variable to run with the AutoApproveIfMissingReporter when adding new tests, or AutoApproveReporter if we are making some bulk changes to our output. Or maybe in certain use cases or for certain developers they want to use a regular diff tool again. We would prefer not to have to do this via code because it ends up creating local changes that can be accidentally committed etc. And an #ifdef seems not so great if the environment variable is already provided.

But APPROVAL_TESTS_USE_REPORTER does not seem to override this default. It seems like it should to me.

Contributor guide

No contributing guide indexed for this repository

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 tracing ApprovalTests::Approvals::useAsFrontLoadedReporter and the handling of APPROVAL_TESTS_USE_REPORTER. Confirm how the default reporter and environment-selected reporter are resolved; done means the environment variable takes precedence without requiring local code changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.