Skip to content

Commit 6bebba6

Browse files
authored
test: allow environment variables in toolkit test scripts #4323
Problem: - Teams want to re-use the toolkits test script so that they can launch tests outside of the vscode repo. This requires some teams to provide additional information (like environment variables) to the spawned VSCode instance Solution: - Allow teams re-using the toolkits test script to set environment variables
1 parent 4912697 commit 6bebba6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

scripts/test/launchTestUtilities.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ type SuiteName = 'integration' | 'e2e' | 'unit'
2828
* If you want to run the tests manually you should use the `Run & Debug` menu in VS Code instead
2929
* to be able to use to breakpoints.
3030
*/
31-
export async function runToolkitTests(suite: SuiteName, relativeTestEntryPoint: string) {
31+
export async function runToolkitTests(suite: SuiteName, relativeTestEntryPoint: string, env?: Record<string, string>) {
3232
try {
3333
console.log(`Running ${suite} test suite...`)
3434

3535
const args = await getVSCodeCliArgs({
3636
vsCodeExecutablePath: await setupVSCodeTestInstance(suite),
3737
relativeTestEntryPoint,
3838
suite,
39+
env,
3940
})
4041
console.log(`runTests() args:\n${JSON.stringify(args, undefined, 2)}`)
4142
const result = await runTests(args)
@@ -56,6 +57,7 @@ async function getVSCodeCliArgs(params: {
5657
vsCodeExecutablePath: string
5758
relativeTestEntryPoint: string
5859
suite: SuiteName
60+
env?: Record<string, string>
5961
}): Promise<TestOptions> {
6062
const projectRootDir = process.cwd()
6163

@@ -89,6 +91,7 @@ async function getVSCodeCliArgs(params: {
8991
extensionTestsEnv: {
9092
['DEVELOPMENT_PATH']: projectRootDir,
9193
['AWS_TOOLKIT_AUTOMATION']: params.suite,
94+
...params.env,
9295
},
9396
}
9497
}

0 commit comments

Comments
 (0)