mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 17:31:12 -05:00
Add delays between tests
Introduce automatic delay between test executions in the test runner to prevent rate limiting. Added a delayBetweenTests config (default 2.5s), a delay() helper, and updated runSuite to wait between tests. This helps avoid "Too many submissions in a short time" errors during test runs.
This commit is contained in:
@@ -51,9 +51,18 @@ export class IntegrationTestRunner {
|
|||||||
private isRunning = false;
|
private isRunning = false;
|
||||||
private shouldStop = false;
|
private shouldStop = false;
|
||||||
private onProgress?: (result: TestResult) => void;
|
private onProgress?: (result: TestResult) => void;
|
||||||
|
private delayBetweenTests: number;
|
||||||
|
|
||||||
constructor(onProgress?: (result: TestResult) => void) {
|
constructor(onProgress?: (result: TestResult) => void, delayBetweenTests: number = 2500) {
|
||||||
this.onProgress = onProgress;
|
this.onProgress = onProgress;
|
||||||
|
this.delayBetweenTests = delayBetweenTests; // Default 2.5 seconds to prevent rate limiting
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wait for specified milliseconds (for rate limiting prevention)
|
||||||
|
*/
|
||||||
|
private async delay(ms: number): Promise<void> {
|
||||||
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -123,13 +132,19 @@ export class IntegrationTestRunner {
|
|||||||
async runSuite(suite: TestSuite): Promise<TestResult[]> {
|
async runSuite(suite: TestSuite): Promise<TestResult[]> {
|
||||||
const suiteResults: TestResult[] = [];
|
const suiteResults: TestResult[] = [];
|
||||||
|
|
||||||
for (const test of suite.tests) {
|
for (let i = 0; i < suite.tests.length; i++) {
|
||||||
|
const test = suite.tests[i];
|
||||||
const result = await this.runTest(test, suite.name);
|
const result = await this.runTest(test, suite.name);
|
||||||
suiteResults.push(result);
|
suiteResults.push(result);
|
||||||
|
|
||||||
if (this.shouldStop) {
|
if (this.shouldStop) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add delay between tests to prevent rate limiting (except after the last test)
|
||||||
|
if (i < suite.tests.length - 1 && this.delayBetweenTests > 0) {
|
||||||
|
await this.delay(this.delayBetweenTests);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return suiteResults;
|
return suiteResults;
|
||||||
|
|||||||
Reference in New Issue
Block a user