Skip to content

Commit 9c5665b

Browse files
committed
fix for updating .env vars on test runs
1 parent 659d8e2 commit 9c5665b

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/tests.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@ const TestDriverAgent = require('testdriverai');
2424
/**
2525
* Load environment variables from the workspace .env file
2626
* This ensures testdriverai gets the correct environment variables from the user's workspace
27+
* Uses override: true to reload variables even if they already exist in process.env
2728
*/
2829
function loadWorkspaceEnv(workspaceFolder: vscode.WorkspaceFolder): void {
2930
const workspaceEnvPath = path.join(workspaceFolder.uri.fsPath, '.env');
3031
try {
31-
const envResult = dotenv.config({ path: workspaceEnvPath });
32+
// Use override: true to force reload of environment variables even if they already exist
33+
const envResult = dotenv.config({ path: workspaceEnvPath, override: true });
3234
if (envResult.error) {
3335
console.log('No .env file found in workspace folder or error loading it:', envResult.error.message);
3436
} else {
35-
console.log('Successfully loaded .env file from workspace folder');
37+
console.log('Successfully loaded .env file from workspace folder (with override)');
3638
// Log the TestDriver-specific environment variables that were loaded
3739
const tdVars = Object.keys(process.env).filter(key => key.startsWith('TD_'));
3840
if (tdVars.length > 0) {

testdriver/test.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
steps:
2+
- commands:
3+
- command: assert
4+
expect: windows is launched

0 commit comments

Comments
 (0)