expect-cli: AI Agent Browser Testing CLI

0.1.3 · active · verified Tue Apr 21

expect-cli is a command-line interface tool designed to enable AI agents to test web applications in a real browser environment. It leverages browser automation tools like Playwright to record user sessions, generate test plans, and perform diffing against expected outcomes, often integrating with version control systems like Git. The current stable version is 0.1.3. Given its low version number and frequent updates (as seen in the release logs), it appears to have a rapid, iterative release cadence. It differentiates itself by explicitly targeting AI agents for automated test generation and execution, moving beyond traditional script-based automation towards more autonomous, intelligent testing within a live browser context.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to programmatically initialize expect-cli for a project using Node.js's child_process module, specifying an AI agent.

import { spawn } from 'child_process';

const agentName = process.env.EXPECT_AGENT_NAME ?? 'claude'; // Example agent
const projectPath = './my-project'; // Path to your project

console.log(`Initializing expect-cli in ${projectPath} with agent: ${agentName}...`);

const initProcess = spawn('npx', [
  'expect-cli@latest',
  'init',
  '--agent', agentName,
  projectPath // Or other initialization parameters
], {
  stdio: 'inherit', // Pipe child process stdio to parent process
  cwd: process.cwd() // Run from current working directory
});

initProcess.on('error', (err) => {
  console.error('Failed to start expect-cli init process:', err);
});

initProcess.on('close', (code) => {
  if (code === 0) {
    console.log('expect-cli initialization completed successfully.');
    console.log(`
Now, try running: npx expect-cli@latest test ${projectPath}`);
  } else {
    console.error(`expect-cli init process exited with code ${code}`);
  }
});

view raw JSON →