Skip to content

Commit e22de49

Browse files
authored
testing: search for tests in $TEST_DIR directory #4352
Problem: - Test jobs cannot control the directory where tests are found. Solution: - If $TEST_DIR is defined, search for tests there instead of the usual place.
1 parent 8e04901 commit e22de49

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,21 @@ To run a single test in VSCode, do any one of:
189189
rootTestsPath: __dirname + '/shared/sam/debugger/'
190190
```
191191
192+
#### Run all tests in a specific folder
193+
194+
To run tests against a specific folder in VSCode, do any one of:
195+
196+
- Add the TEST_DIR environment variable to one of the testing launch configs and run it
197+
- Run in your terminal
198+
- Unix/macOS/POSIX shell:
199+
```
200+
TEST_DIR=src/test/foo npm run test
201+
```
202+
- Powershell:
203+
```
204+
$Env:TEST_DIR = "src/test/foo"; npm run test
205+
```
206+
192207
### Browser Support
193208
194209
Running the extension in the browser (eg: [vscode.dev](https://vscode.dev/)).
@@ -403,6 +418,7 @@ Environment variables can be used to modify the behaviour of VSCode. The followi
403418
- `AWS_TOOLKIT_AUTOMATION`: If tests are currently being ran
404419
- `DEVELOPMENT_PATH`: The path to the aws toolkit vscode project
405420
- `AWS_TOOLKIT_TEST_NO_COLOR`: If the tests should include colour in their output
421+
- `TEST_DIR` - The directory where the test runner should find the tests
406422

407423
### SAM/CFN ("goformation") JSON schema
408424

scripts/test/launchTestUtilities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ async function getVSCodeCliArgs(params: {
9191
extensionTestsEnv: {
9292
['DEVELOPMENT_PATH']: projectRootDir,
9393
['AWS_TOOLKIT_AUTOMATION']: params.suite,
94+
['TEST_DIR']: process.env.TEST_DIR,
9495
...params.env,
9596
},
9697
}

src/test/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
import { runTests } from './testRunner'
77

88
export function run(): Promise<void> {
9-
return runTests('src/test', ['src/test/globalSetup.test.ts'])
9+
return runTests(process.env.TEST_DIR ?? 'src/test', ['src/test/globalSetup.test.ts'])
1010
}

src/testE2E/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
import { runTests } from '../test/testRunner'
77

88
export function run(): Promise<void> {
9-
return runTests('src/testE2E', ['src/testInteg/globalSetup.test.ts'])
9+
return runTests(process.env.TEST_DIR ?? 'src/testE2E', ['src/testInteg/globalSetup.test.ts'])
1010
}

src/testInteg/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
import { runTests } from '../test/testRunner'
77

88
export function run(): Promise<void> {
9-
return runTests('src/testInteg', ['src/testInteg/globalSetup.test.ts'])
9+
return runTests(process.env.TEST_DIR ?? 'src/testInteg', ['src/testInteg/globalSetup.test.ts'])
1010
}

0 commit comments

Comments
 (0)