Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/instructions/testing-workflow.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -574,3 +574,6 @@ envConfig.inspect
- Untestable Node.js APIs → Create proxy abstraction functions (use function overloads to preserve intelligent typing while making functions mockable)

## 🧠 Agent Learnings
- Avoid testing exact error messages or log output - assert only that errors are thrown or rejection occurs to prevent brittle tests (1)
- Create shared mock helpers (e.g., `createMockLogOutputChannel()`) instead of duplicating mock setup across multiple test files (1)

14 changes: 7 additions & 7 deletions src/test/features/envCommands.unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as assert from 'assert';
import * as typeMoq from 'typemoq';
import * as sinon from 'sinon';
import { EnvironmentManagers, InternalEnvironmentManager, PythonProjectManager } from '../../internal.api';
import * as projectApi from '../../common/pickers/projects';
import * as managerApi from '../../common/pickers/managers';
import * as typeMoq from 'typemoq';
import { Uri } from 'vscode';
import { PythonEnvironment, PythonProject } from '../../api';
import * as managerApi from '../../common/pickers/managers';
import * as projectApi from '../../common/pickers/projects';
import { createAnyEnvironmentCommand } from '../../features/envCommands';
import { Uri } from 'vscode';
import { EnvironmentManagers, InternalEnvironmentManager, PythonProjectManager } from '../../internal.api';
import { setupNonThenable } from '../mocks/helper';

suite('Create Any Environment Command Tests', () => {
let em: typeMoq.IMock<EnvironmentManagers>;
Expand Down Expand Up @@ -37,8 +38,7 @@ suite('Create Any Environment Command Tests', () => {

env = typeMoq.Mock.ofType<PythonEnvironment>();
env.setup((e) => e.envId).returns(() => ({ id: 'env1', managerId: 'test' }));
// eslint-disable-next-line @typescript-eslint/no-explicit-any
env.setup((e: any) => e.then).returns(() => undefined);
setupNonThenable(env);

em = typeMoq.Mock.ofType<EnvironmentManagers>();
em.setup((e) => e.managers).returns(() => [manager.object]);
Expand Down
Loading