detectAndResolveTests() function chains test detection and resolution into a single operation. It’s a convenience function that combines setConfig(), detectTests(), and resolveTests() to prepare tests for execution.
Function Signature
Parameters
Configuration object defining test detection and resolution behavior. Must conform to the config schema.
Return Value
Resolved tests ready for execution, or
null if no tests were detected.Basic Usage
Passing to runTests()
Use resolved tests to skip detection/resolution inrunTests():
Multiple Input Sources
Detect and resolve from multiple paths:Context Resolution
Resolve tests for specific platform/browser combinations:Inspecting Resolved Tests
Inspect the structure of resolved tests:Pre-Execution Validation
Validate tests before execution:Error Handling
Handle detection and resolution errors:CI/CD Integration
Prepare tests in CI/CD pipelines:Behavior
ThedetectAndResolveTests() function performs the following steps:
- Config Validation - Calls
setConfig()to validate and normalize configuration - Test Detection - Calls
detectTests()to scan and parse test specifications - Empty Check - Returns
nullif no tests are detected - Test Resolution - Calls
resolveTests()to expand contexts and resolve paths - Return - Returns resolved test object ready for execution
Notes
- Returns
nullif no tests are detected, not an empty object - A warning is logged if no tests are detected
- The function validates config and detects tests before resolution
- Relative paths in tests are resolved based on
relativePathBasesetting - The returned config includes all defaults and computed values
- Test contexts are fully expanded based on
runOnconfiguration - The
resolvedTestsIdis a unique identifier for the test run
When to Use
UsedetectAndResolveTests() when you want to:
- Prepare tests once, run multiple times - Detect and resolve once, then execute repeatedly
- Inspect test structure - Examine what tests will run before execution
- Validate tests - Check test structure and context resolution before running
- Separate detection from execution - Split the pipeline for complex workflows
- Cache resolved tests - Save resolved tests for later use
runTests() directly when you want a single operation that detects, resolves, and executes.
See Also
- detectTests() - Detect tests without resolution
- resolveTests() - Resolve detected tests
- runTests() - Detect, resolve, and execute in one operation
- Config schema - Full configuration reference