Skip to content

Commit 9017277

Browse files
committed
feat: ability to specify "env" via vscode settings
1 parent 650f854 commit 9017277

8 files changed

Lines changed: 56 additions & 4 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,5 @@ Adds a keybinding (`cmd+shift+8` for mac and `ctrl+shift+8` for others) to run a
7777

7878
You can configure Testplane using [user and workspace settings](https://code.visualstudio.com/docs/getstarted/settings#_workspace-settings). Available settings:
7979

80-
- `testplane.configPath`: The path to the Testplane [configuration file](https://testplane.io/docs/v8/config/main/).
80+
- `testplane.configPath`: The path to the Testplane [configuration file](https://testplane.io/docs/v8/config/main/);
81+
- `testplane.env`: Environment variables passed to the Testplane process in addition to `process.env`.

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@
4646
"markdownDescription": "The path to the Testplane [configuration file](https://testplane.io/docs/v8/config/main/)",
4747
"type": "string",
4848
"scope": "window"
49+
},
50+
"testplane.env": {
51+
"markdownDescription": "Environment variables passed to the Testplane process in addition to `process.env`",
52+
"type": [
53+
"object",
54+
"null"
55+
],
56+
"default": null,
57+
"scope": "window"
4958
}
5059
}
5160
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"testplane.configPath": "./another-config/testplane.config.ts"
2+
"testplane.configPath": "./another-config/testplane.config.ts",
3+
"testplane.env": {
4+
"TESTPLANE_SKIP_BROWSERS": "another-bro"
5+
}
36
}

src/api/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ export async function createChildProcess(wf: vscode.WorkspaceFolder, config: VSC
1313
const workerPath = resolve(__dirname, "worker.js");
1414
const execPath = await findNodePath();
1515

16-
const proc = fork(workerPath, { cwd: normalize(wf.uri.fsPath), stdio: "overlapped", execPath });
16+
const proc = fork(workerPath, {
17+
cwd: normalize(wf.uri.fsPath),
18+
stdio: "overlapped",
19+
execPath,
20+
env: {
21+
...process.env,
22+
...config.env,
23+
},
24+
});
1725

1826
proc.stdout?.on("data", d => logger.worker("info", d.toString()));
1927
proc.stderr?.on("data", d => logger.worker("error", d.toString()));

src/config/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ export const getVSCodeConfig = async (wf?: vscode.WorkspaceFolder): Promise<VSCo
88
const settings = getVSCodeSettings(wf);
99
const configPath = settings.configPath ? settings.configPath : await findTestplaneConfigFile();
1010

11-
return { configPath };
11+
return {
12+
configPath,
13+
env: settings.env,
14+
};
1215
};

src/config/settings.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as vscode from "vscode";
44

55
export type VSCodeSettings = {
66
configPath: string | undefined;
7+
env: Record<string, string> | null;
78
};
89

910
export const getVSCodeSettings = (wf?: vscode.WorkspaceFolder): VSCodeSettings => {
@@ -19,9 +20,11 @@ export const getVSCodeSettings = (wf?: vscode.WorkspaceFolder): VSCodeSettings =
1920
});
2021

2122
const configPath = get<string>("configPath");
23+
const env = get<Record<string, string> | null>("env", null)!;
2224

2325
return {
2426
configPath: resolveConfigPath(configPath, wf),
27+
env,
2528
};
2629
};
2730

File renamed without changes.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { expect } from "@wdio/globals";
2+
import { VSCodePO } from "../../page-objects";
3+
4+
describe(".vscode/settings.json", () => {
5+
it("should be skipped by 'TESTPLANE_SKIP_BROWSERS' env variable from user settings", async () => {
6+
const vscodePO = await VSCodePO.create();
7+
const testingViewControl = vscodePO.getTestingViewControl();
8+
await testingViewControl.open();
9+
10+
const sidebar = vscodePO.getTestingSideBar();
11+
await sidebar.waitTestsRead();
12+
await sidebar.runAllTests();
13+
await sidebar.waitTestsRunComplete();
14+
15+
await expect(await sidebar.getTestsRunStats()).toBe("0/0");
16+
17+
const [firstSection] = await sidebar.getSections();
18+
const [mainTreeItem] = await firstSection.getVisibleItems();
19+
await mainTreeItem.expandAll();
20+
21+
const items = await firstSection.getVisibleItems();
22+
23+
await expect(await items[0].getAriaLabelAttr()).toContain("tests (Skipped)");
24+
});
25+
});

0 commit comments

Comments
 (0)