async testScript()

in integration/js/utils/SdkBaseTest.js [215:272]


  async testScript() {
    const maxRetries = this.payload.retry === undefined || this.payload.retry < 1 ? 5 : this.payload.retry;
    const numberOfSeleniumSessions = this.numberOfSessions();

    let retryCount = 0;
    while (retryCount < maxRetries) {
      if (retryCount !== 0) {
        console.log(`Retrying : ${retryCount}`);
      }
      try {
        if (!await this.initializeSeleniumSession(numberOfSeleniumSessions)) {
          if (this.testName === 'MediaCapture' || this.testName === 'Transcription') {
            await emitMetric(this.testName, this.capabilities, 'E2E_' + this.region, 0, this.cwNamespaceInfix);
          } else {
            await emitMetric(this.testName, this.capabilities, 'E2E', 0, this.cwNamespaceInfix);
          }
          return;
        }

        //Wait for other to be ready
        if (this.numberOfParticipant > 1 && this.io) {
          this.io.emit('test_ready', true);
          await this.waitForTestReady();
          if (!this.testReady) {
            this.io.emit('test_ready', false);
            console.log('[OTHER_PARTICIPANT] failed to be ready');
            this.remoteFailed = true;
            return;
          }
        }
        this.testFinish = false;
        this.initializeState();
        console.log('Running test on: ' + process.env.SELENIUM_GRID_PROVIDER);
        await this.runIntegrationTest();
      } catch (e) {
        console.error(e);
        this.failedTest = true;
        await SetTestBrokenStep.executeStep(this, 'Error exception when running test');
      } finally {
        await this.closeCurrentTest(!this.failedTest && !this.remoteFailed);
      }
      if (this.payload.canaryLogPath !== undefined) {
        this.writeCompletionTimeTo(this.payload.canaryLogPath);
      }
      // Retry if the local or remote test failed
      if (!this.failedTest && !this.remoteFailed) {
        break;
      }
      if (this.numberOfParticipant > 1 && this.io) {
        this.io.emit('test_ready', false);
        if (!this.testFinish) {
          console.log('[OTHER_PARTICIPANT] timed out');
          break;
        }
      }
      retryCount++;
    }
  }