Add more strongly typed wrapper around test.macro#3883
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a makeMacro helper in src/testing-utils.ts to wrap AVA test.macro in a way that preserves stronger argument typing at call sites, and then migrates several existing test macros to use the new wrapper-style invocation.
Changes:
- Add
makeMacrohelper that creates a typed wrapper around an AVA macro and exposes convenience helpers like.serial()/.test(). - Refactor multiple test suites to declare macros via
makeMacroand invoke them via the wrapper APIs (instead of passing macros intotest()/test.serial()). - Update the workspace VS Code snippet to generate
makeMacro-based macros.
Show a summary per file
| File | Description |
|---|---|
| src/testing-utils.ts | Adds makeMacro helper and adjusts setupTests parameter naming. |
| src/upload-sarif.test.ts | Migrates a macro + serial tests to makeMacro wrapper usage. |
| src/status-report.test.ts | Migrates a macro + serial tests to makeMacro wrapper usage. |
| src/start-proxy.test.ts | Migrates several macros/tests to wrapper-style invocation (.serial() / direct call). |
| src/setup-codeql.test.ts | Migrates a macro + serial tests to makeMacro wrapper usage. |
| src/overlay/caching.test.ts | Migrates a macro + serial tests to makeMacro wrapper usage. |
| src/init.test.ts | Migrates a macro + tests to wrapper-style invocation (direct call). |
| src/init-action-post-helper.test.ts | Migrates a macro + serial tests to makeMacro wrapper usage. |
| src/diff-informed-analysis-utils.test.ts | Migrates a macro + serial tests to makeMacro wrapper usage. |
| src/config/db-config.test.ts | Migrates multiple macros/tests and updates internal macro composition to use .fn. |
| src/config-utils.test.ts | Migrates a macro + many serial tests to makeMacro wrapper usage. |
| src/codeql.test.ts | Migrates a macro + many serial tests to makeMacro wrapper usage. |
| .vscode/tests.code-snippets | Updates the “Test Macro” snippet to use makeMacro. |
Copilot's findings
- Files reviewed: 13/13 changed files
- Comments generated: 1
This was referenced May 7, 2026
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.
When defining a test macro using
test.macro, the argument types are not strongly enforced when the macro is used withtest,test.serial, etc.This PR adds a
makeMacrohelper which returns a wrapper around a macro that enforces the argument types.Replaces #3873.
Risk assessment
For internal use only. Please select the risk level of this change:
Which use cases does this change impact?
Environments:
How did/will you validate this change?
.test.tsfiles).If something goes wrong after this change is released, what are the mitigation and rollback strategies?
How will you know if something goes wrong after this change is released?
Are there any special considerations for merging or releasing this change?
Merge / deployment checklist