Skip to content

Commit

Permalink
only add retries to unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Hweinstock committed Nov 13, 2024
1 parent 39fc629 commit f04e800
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 5 additions & 5 deletions packages/core/src/test/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function runTests(
testFolder: string | string[],
extensionId: string,
initTests: string[] = [],
testFiles?: string[]
options?: { retries?: number; testFiles?: string[] }
): Promise<void> {
if (!process.env['AWS_TOOLKIT_AUTOMATION']) {
throw new Error('Expected the "AWS_TOOLKIT_AUTOMATION" environment variable to be set for tests.')
Expand Down Expand Up @@ -79,7 +79,7 @@ export async function runTests(
mochaFile: outputFile,
},
},
retries: 3, // runs a max of 4 times (3 retries + original)
retries: options?.retries ?? 0,
timeout: 0,
})

Expand All @@ -92,7 +92,7 @@ export async function runTests(
testFilePath = testFile ? path.resolve(dist, testFile) : undefined
}

if (testFile && testFiles) {
if (testFile && options?.testFiles) {
throw new Error('Individual file and list of files given to run tests on. One must be chosen.')
}

Expand Down Expand Up @@ -144,8 +144,8 @@ export async function runTests(
}

let files: string[] = []
if (testFiles) {
files = testFiles
if (options?.testFiles) {
files = options.testFiles
} else {
for (const f of Array.isArray(testFolder) ? testFolder : [testFolder]) {
files = [...files, ...(await glob(testFilePath ?? `**/${f}/**/**.test.js`, { cwd: dist }))]
Expand Down
9 changes: 6 additions & 3 deletions packages/toolkit/test/unit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { runTests } from 'aws-core-vscode/test'
import { VSCODE_EXTENSION_ID } from 'aws-core-vscode/utils'

export function run(): Promise<void> {
return runTests(process.env.TEST_DIR ?? ['test/unit', '../../core/dist/src/test'], VSCODE_EXTENSION_ID.awstoolkit, [
'../../core/dist/src/test/globalSetup.test.ts',
])
return runTests(
process.env.TEST_DIR ?? ['test/unit', '../../core/dist/src/test'],
VSCODE_EXTENSION_ID.awstoolkit,
['../../core/dist/src/test/globalSetup.test.ts'],
{ retries: 3 }
)
}

0 comments on commit f04e800

Please sign in to comment.