_buildMonitors()

in src/core/runner.ts [429:476]


  _buildMonitors(options: PushOptions) {
    /**
     * Update the global monitor configuration required for setting defaults
     */
    this._updateMonitor({
      throttling: options.throttling,
      schedule: options.schedule,
      locations: options.locations,
      privateLocations: options.privateLocations,
      params: options.params,
      playwrightOptions: options.playwrightOptions,
      screenshot: options.screenshots,
      tags: options.tags,
      alert: options.alert,
      retestOnFailure: options.retestOnFailure,
      enabled: options.enabled,
      fields: options.fields,
    });

    const monitors: Monitor[] = [];
    for (const journey of this.#journeys) {
      this.#currentJourney = journey;
      if (journey.skip) {
        throw new Error(
          `Journey ${journey.name} is skipped. Please remove the journey.skip annotation and try again.`
        );
      }
      /**
       * Before pushing a browser monitor, three things need to be done:
       *
       * - execute callback `monitor.use` in particular to get monitor configurations
       * - update the monitor config with global configuration
       * - filter out monitors based on matched tags and name after applying both
       *  global and local monitor configurations
       */

      // TODO: Fix backwards compatibility with 1.14 and prior
      (journey.cb ?? journey.callback)({ params: options.params } as any);
      const monitor = journey.monitor ?? journey?._getMonitor();
      monitor.update(this.#monitor?.config);
      if (!monitor.isMatch(options.grepOpts?.match, options.grepOpts?.tags)) {
        continue;
      }
      monitor.validate();
      monitors.push(monitor);
    }
    return monitors;
  }