Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Improve TestEnv for cleaner tests#4005

Open
mbg wants to merge 14 commits into
mainfrom
mbg/test-env/improvements
Open

Improve TestEnv for cleaner tests#4005
mbg wants to merge 14 commits into
mainfrom
mbg/test-env/improvements

Conversation

@mbg

@mbg mbg commented Jul 9, 2026

Copy link
Copy Markdown
Member

Various changes to the test-only TestEnv that was introduced recently as part of #3990 to make tests nicer to write.

Risk assessment

For internal use only. Please select the risk level of this change:

  • Low risk: Changes are fully under feature flags, or have been fully tested and validated in pre-production environments and are highly observable, or are documentation or test only.

Which use cases does this change impact?

Environments:

  • Testing/None - This change does not impact any CodeQL workflows in production.

How did/will you validate this change?

  • Unit tests - I am depending on unit test coverage (i.e. tests in .test.ts files).

If something goes wrong after this change is released, what are the mitigation and rollback strategies?

  • Development/testing only - This change cannot cause any failures in production.

How will you know if something goes wrong after this change is released?

  • Other - N/A.

Are there any special considerations for merging or releasing this change?

  • No special considerations - This change can be merged at any time.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Consider adding a changelog entry for this change.
  • Confirm the readme and docs have been updated if necessary.

@mbg mbg self-assigned this Jul 9, 2026
Copilot AI review requested due to automatic review settings July 9, 2026 18:34
@mbg mbg requested a review from a team as a code owner July 9, 2026 18:34
@github-actions github-actions Bot added the size/L May be hard to review label Jul 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the test-only TestEnv helper in src/testing-utils.ts into a builder-style API that enables cleaner test chaining and adds delayed log assertions, then updates existing config tests to use the new API.

Changes:

  • Replaced TestEnv with EnvBuilder/CallableEnvBuilder and updated callee(...) to return the new builder.
  • Added delayed log assertion helpers (logs, notLogs) and a throws(...) helper for more concise tests.
  • Updated src/config/*.test.ts tests to use .passes(t.is, ...), .throws(t, ...), and the new env/actions mutation helpers.
Show a summary per file
File Description
src/testing-utils.ts Introduces the new builder-based test harness, delayed checks, and new assertion helpers.
src/config/remote-file.test.ts Updates tests to the new callee(...).withEnv(...).withArgs(...).passes/throws chaining style.
src/config/file.test.ts Simplifies config-file input tests using delayed log assertions and the new .passes(...) signature.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 4
  • Review effort level: Low

Comment thread src/testing-utils.ts
Comment thread src/testing-utils.ts
Comment thread src/testing-utils.ts
Comment thread src/testing-utils.ts Outdated
@mbg mbg force-pushed the mbg/test-env/improvements branch from 6109575 to d2e6ffe Compare July 9, 2026 19:02
@mbg mbg force-pushed the mbg/test-env/improvements branch from d2e6ffe to d0a69d7 Compare July 9, 2026 19:03
@mbg mbg requested a review from Copilot July 9, 2026 19:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 4/4 changed files
  • Comments generated: 3
  • Review effort level: Low

Comment thread src/testing-utils.ts Outdated
Comment thread src/testing-utils.ts
Comment thread src/config/remote-file.test.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L May be hard to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants