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:DevExpress Testcafe Testcafe CLI Entry

From Leeroopedia
Knowledge Sources
Domains Testing, Web_Automation
Last Updated 2026-02-12 04:00 GMT

Overview

Concrete CLI entry point provided by TestCafe that filters V8 flags, enables ESM loader support, and bootstraps the test execution framework.

Description

The TestCafe CLI entry consists of two executable scripts that provide command-line access to the framework. The primary entry point testcafe-with-v8-flag-filter.js intercepts V8 debugging and performance flags (like --inspect, --harmony, --max-old-space-size) and forwards them to the Node.js runtime while keeping application arguments clean. It conditionally registers an ESM loader for Node.js versions that require it (< 18.19.0 or < 20.8.0), enabling native ES module support for test files. The secondary entry point testcafe.js provides a simple passthrough for environments that don't require flag filtering.

Both entry points delegate to src/cli/cli.js for main orchestration, maintaining a clean separation between bootstrap concerns and application logic.

Usage

Use these entry points when invoking TestCafe from the command line to run end-to-end tests across browsers.

Code Reference

Source Location

  • Repository: testcafe
  • File: bin/testcafe-with-v8-flag-filter.js, bin/testcafe.js
  • Lines: L1-23 (v8-flag-filter), L1-5 (simple entry)

Signature

#!/usr/bin/env node
// Entry point with V8 flag filtering and ESM support
v8FlagsFilter(cliPath, options)

// Simple entry point
require('../lib/cli')

Import

// Invoked via package.json bin mapping
// Command line:
npx testcafe chrome tests/
testcafe firefox:headless tests/ --reporter spec

I/O Contract

Inputs

Name Type Required Description
process.argv string[] Yes Command-line arguments including V8 flags and TestCafe options
--esm flag No Enable ESM loader for native ES module support
--inspect V8 flag No Enable Node.js debugging (filtered and forwarded)
--harmony V8 flag No Enable experimental JavaScript features (filtered and forwarded)
--max-old-space-size V8 flag No Set V8 heap size limit (filtered and forwarded)

Outputs

Name Type Description
Exit code number 0 on success, non-zero on failure (number of failed tests)
Process restart side effect Restarts Node.js process with V8 flags if needed
Loader registration side effect Registers ESM loader for compatible Node.js versions

Usage Examples

Basic Test Execution

// Run tests in Chrome
testcafe chrome tests/

// Run with V8 debugging enabled
testcafe --inspect chrome tests/

// Run with ESM support
testcafe --esm chrome tests/**/*.mjs

Advanced Usage with V8 Flags

// Increase heap size for large test suites
testcafe --max-old-space-size=4096 chrome tests/

// Enable experimental features and debugging
testcafe --harmony --inspect-brk chrome tests/login.test.js

Entry Point Implementation

// bin/testcafe-with-v8-flag-filter.js
const v8FlagsFilter = require('@devexpress/bin-v8-flags-filter');
const semver = require('semver');

const ESM_OPTION = '--esm';
const forcedArgs = [];

if (process.argv.slice(2).includes(ESM_OPTION)) {
    forcedArgs.push('--no-warnings');
    if (!semver.satisfies(process.version, '18.19.0 - 18.x || >=20.8.0'))
        forcedArgs.push(`--experimental-loader=${loaderPath}`);
}

v8FlagsFilter(path.join(__dirname, '../lib/cli'), {
    useShutdownMessage: true,
    forcedArgs,
});

Related Pages

Implements Principle

Requires Environment

Page Connections

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