Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(test): add automatic retry to all mocha tests. #6005

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 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,6 +79,7 @@ export async function runTests(
mochaFile: outputFile,
},
},
retries: options?.retries ?? 0,
timeout: 0,
})

Expand All @@ -91,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 @@ -143,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 }
)
}
Loading