refactor: route the remaining user-facing errors through the message bundle - #164
Merged
Merged
Conversation
|
Preview build for this pull request: sf plugins install https://pkg.pr.new/apex-mutation-testing@829e6c9 |
Performance Comparison (same runner)Stable
|
|
Shipped in release $ sf plugins install apex-mutation-testing@latest-rc
# Or
$ sf plugins install apex-mutation-testing@v1.9.0💡 Enjoying apex-mutation-testing? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explain your changes
Completes the work started in dd69ee2 (#162), which moved ten
ConfigReadererrors intomessages/apex.mutation.test.run.mdbut left three behind because they lived in classes withno
Messagesdependency. All three are user-actionable — each is caused by a flag the usertyped and fixed by changing it — so they belong on the bundle side of the line #162 drew:
HTMLReporter.ts—--report-dirresolves outside the cwderror.reportDirOutsideCwdHTMLReporter.ts—--report-dirdereferences outside the cwderror.reportDirSymlinkOutsideCwdmutantGenerator.ts— every mutator excluded by configurationerror.allMutatorsExcludedThe wording is byte-identical to what shipped before; only the source of the string moves. The
point is visibility:
test/unit/messages/apexMutationTestRunBundle.test.tsloads the realbundle unmocked, so from now on a renamed or missing key fails that suite instead of throwing
MissingMessageErrorin front of a user, on a failure path no happy-path run reaches.Design decision — constructor injection, matching
ConfigReader's existing shape.Neither class had a constructor.
ApexMutationHTMLReporterwas cheap (one construction site inrun.ts, one in its test).MutantGeneratorwas the real question: 21 construction sites acrossunit, integration, perf and NUT suites. Passing
Messagesper call was still worse —compute()already takes seven parameters, an eighth positional would touch the same 21 sites anyway, and
making it optional would reintroduce the hardcoded fallback this change exists to remove. The 20
sites that never trip the filter take a shared
keyEchoingMessages()bundle fromtest/utils/testUtil.tsrather than each carrying its own template map.Internal invariant throws are deliberately left hardcoded —
apexClassRepository'scontainer/request ID guards and poll options,
orgMutationTestBed's prepare-before-evaluateprecondition,
mutationLocation,exactColoring, andmutantGenerator's overlapping-token-rangecheck. They are programmer errors, and putting them in a user-facing catalogue would imply the
user can act on them.
Also documents one testing hazard in
DESIGN.mdthat cost real debugging time and is invisible oninspection:
await expect(p).rejects.toThrow('message')passes when the promise rejects withundefined. It is only reachable where the thrown value is computed rather than constructed inline(
throw someFactory(...)), because a mutant can gut the factory into returningundefined. Such asite should also assert
rejects.toBeInstanceOf(Error), sharing one promise variable so the subjectis not executed twice. Exactly one such site exists today (
mutationTestingService.ts, alreadyfixed), so this is a documented convention rather than a test helper.
Does this close any currently open issues?
No open issue — follow-up to #162.
E2E is unaffected: the rendered sentences are unchanged, and neither error is on the path the
E2E snapshot exercises.
Any particular element that can be tested locally
No new flags and no behaviour change. The three messages render exactly as before:
Any other comments
Gates run locally
npx tsc -p . --noEmitnpx @biomejs/biome check --error-on-warnings src testnpx vitest run --coveragenpx vitest run --config vitest.config.nut.tsnpm run lint:dependencies(knip)npx commitlint --from main --to HEADnpm outdatednpm ls zod4.4.3, deduped under@salesforce/coreMutation testing on the diff — run per-hunk against the changed ranges under a temporary
typescript@6.0.3(Stryker 10.0.0 crashes onts.parseConfigFileTextToJsonunder TS 7):Message plumbing is exactly where
StringLiteralmutants survive — four field-name literalssurvived in dd69ee2 until tests pinned the rendered sentences. All three new key literals and both
argument arrays were mutated and killed, because each test asserts the whole rendered sentence with
its interpolated values rather than a fragment. No
// Stryker disablewas added; the singleIgnoredmutant in the range is the pre-existing disable onINPUT_STREAM_NAME.