Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Cypress io Cypress IsValidBrowser

From Leeroopedia
Knowledge Sources
Domains Configuration, Validation
Last Updated 2026-02-12 00:00 GMT

Overview

Concrete tool for validating browser objects and configuration values provided by the @packages/config validation module.

Description

The validation module (packages/config/src/validation.ts) provides several validation functions: isValidBrowser checks individual browser object schema, isValidBrowserList validates the entire browser array, isValidClientCertificatesSet validates client certificate configurations, and resolveConfigValues (in project/utils.ts) resolves and validates the full configuration object.

Usage

Called during configuration resolution to validate user-provided browser lists, client certificates, and general configuration values before test execution begins.

Code Reference

Source Location

  • Repository: cypress-io/cypress
  • Files:
    • packages/config/src/validation.ts:L61-87 (isValidBrowser)
    • packages/config/src/validation.ts:L92-119 (isValidBrowserList)
    • packages/config/src/validation.ts:L324-369 (isValidClientCertificatesSet)
    • packages/config/src/project/utils.ts:L186-200 (resolveConfigValues)

Signature

export const isValidBrowser = (browser: any): ErrResult | true

export const isValidBrowserList = (
  _key: string,
  browsers: any
): ErrResult | true | string

export const isValidClientCertificatesSet = (
  _key: string,
  certsForUrls: any
): ErrResult | true | string

// From project/utils.ts
export function resolveConfigValues(
  config: Record<string, any>,
  defaults: Record<string, any>,
  resolved?: Record<string, any>
): Record<string, any>

Import

import { isValidBrowser, isValidBrowserList } from '@packages/config/src/validation'
import { resolveConfigValues } from '@packages/config/src/project/utils'

I/O Contract

Inputs

Name Type Required Description
browser object Yes (isValidBrowser) Browser object to validate
browsers array Yes (isValidBrowserList) Array of browser objects
certsForUrls array Yes (isValidClientCertificatesSet) Client certificate configurations
config object Yes (resolveConfigValues) Full configuration object to resolve

Outputs

Name Type Description
true boolean Validation passed
ErrResult { key, value, type } Validation error with details
string string Error message (for list validation)

Usage Examples

Validating a Browser Object

import { isValidBrowser } from '@packages/config/src/validation'

const result = isValidBrowser({
  name: 'chrome',
  family: 'chromium',
  displayName: 'Chrome',
  version: '120.0.6099.129',
  path: '/usr/bin/google-chrome',
  majorVersion: '120',
})

if (result === true) {
  console.log('Browser is valid')
} else {
  console.error(`Invalid ${result.key}: expected ${result.type}`)
}

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment