Skip to content

Conversation

@anyoung-tableau
Copy link
Collaborator

@anyoung-tableau anyoung-tableau commented Feb 10, 2026

I initially made these changes as I was working on #216 but pulled them out to isolate them and make the other PR smaller.

Copilot AI review requested due to automatic review settings February 10, 2026 00:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors unit tests to stub environment variables directly (via Vitest) instead of mocking the Config module, centralizing common env setup in shared test utilities.

Changes:

  • Replace vi.mock('../../config.js') patterns across multiple test suites with vi.stubEnv(...) and a shared stubDefaultEnvVars() helper.
  • Add stubDefaultEnvVars() to src/testShared.ts and use it from src/testSetup.ts and updated tests.
  • Update src/config.test.ts to use vi.stubEnv/vi.unstubAllEnvs rather than manual process.env mutation.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/tools/workbooks/getWorkbook.test.ts Switch config mocking to env stubbing via stubDefaultEnvVars() and per-test vi.stubEnv.
src/tools/views/getViewImage.test.ts Switch config mocking to env stubbing via stubDefaultEnvVars() and per-test vi.stubEnv.
src/tools/views/getViewData.test.ts Switch config mocking to env stubbing via stubDefaultEnvVars() and per-test vi.stubEnv.
src/tools/queryDatasource/queryDatasource.test.ts Replace config mocking with env stubbing for datasource credentials and bounded-context filtering.
src/tools/queryDatasource/datasourceCredentials.test.ts Replace config mocking with DATASOURCE_CREDENTIALS env stubbing.
src/tools/pulse/generateMetricValueInsightBundle/generatePulseMetricValueInsightBundleTool.test.ts Replace config mocking with env stubbing for bounded-context datasource filtering.
src/tools/pulse/generateInsightBrief/generatePulseInsightBriefTool.test.ts Replace config mocking with env stubbing for bounded-context datasource filtering.
src/tools/getDatasourceMetadata/getDatasourceMetadata.test.ts Replace config mocking with env stubbing for feature flags and bounded-context datasource filtering.
src/testShared.ts Introduce stubDefaultEnvVars() helper for shared env defaults.
src/testSetup.ts Use stubDefaultEnvVars() instead of duplicating env stubs inline.
src/telemetry/init.test.ts Replace config mocking with TELEMETRY_PROVIDER / TELEMETRY_PROVIDER_CONFIG env stubbing.
src/config.test.ts Refactor env setup/teardown to use vi.unstubAllEnvs + vi.stubEnv rather than rewriting process.env.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@anyoung-tableau anyoung-tableau merged commit 34a3cbd into main Feb 10, 2026
5 checks passed
@anyoung-tableau anyoung-tableau deleted the anyoung/stub-env branch February 10, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants