testivai-cli
v1.0.13
Published
CLI tool for testivAI Visual Regression testing
Maintainers
Readme
testivAI CLI
Command-line interface for testivAI Visual Regression testing.
Installation
npm install -g testivai-cliQuick Start
Initialize a Project
testivai init --framework playwright --baseline-dir .testivai/baselineCompare Screenshots
testivai compare --baseline-dir .testivai/baseline --compare-dir .testivai/compareGet Help
testivai help
testivai help init
testivai help compareCommands
testivai init
Initialize testivAI Visual Regression in the current project.
Options:
--framework, -f- Testing framework to use (playwright, cypress, puppeteer, selenium) [default: playwright]--baseline-dir, -b- Directory to store baseline screenshots [default: .testivai/visual-regression/baseline]--compare-dir, -c- Directory to store comparison screenshots [default: .testivai/visual-regression/compare]--report-dir, -r- Directory to store generated reports [default: .testivai/visual-regression/reports]--diff-threshold, -t- Threshold for acceptable difference between screenshots (0-1) [default: 0.1]
Example:
testivai init --framework playwright --baseline-dir ./screenshots/baseline --diff-threshold 0.05testivai compare
Compare screenshots against baselines.
Options:
--baseline-dir, -b- Directory containing baseline screenshots [default: .testivai/visual-regression/baseline]--compare-dir, -c- Directory containing comparison screenshots [default: .testivai/visual-regression/compare]--report-dir, -r- Directory to store generated reports [default: .testivai/visual-regression/reports]--diff-threshold, -t- Threshold for acceptable difference between screenshots (0-1) [default: 0.1]--update-baselines, -u- Update baselines with comparison screenshots if different [default: false]
Example:
testivai compare --baseline-dir ./screenshots/baseline --compare-dir ./screenshots/current --update-baselinestestivai help
Display help information for commands.
Usage:
testivai help [command]Examples:
testivai help # Show general help
testivai help init # Show help for init command
testivai help compare # Show help for compare commandConfiguration File
The CLI can generate a configuration file (testivai.config.js) to store your settings:
module.exports = {
framework: 'playwright',
baselineDir: '.testivai/visual-regression/baseline',
compareDir: '.testivai/visual-regression/compare',
reportDir: '.testivai/visual-regression/reports',
diffThreshold: 0.1,
updateBaselines: false
};Integration with Testing Frameworks
The CLI is designed to work alongside the testivAI Visual Regression SDK. For programmatic usage in your tests, install the SDK:
npm install testivai-visual-regressionSee testivai-visual-regression for SDK documentation.
Workflow
Initialize: Set up testivAI in your project
testivai init --framework playwrightRun Tests: Use the SDK in your test files to capture screenshots
Compare: Compare captured screenshots against baselines
testivai compareReview: Check the generated HTML report for visual differences
Update: Update baselines when changes are intentional
testivai compare --update-baselines
Examples
Basic Workflow
# Initialize project
testivai init
# Run your tests (using the SDK)
npm test
# Compare screenshots
testivai compare
# Update baselines if changes are intentional
testivai compare --update-baselinesCustom Configuration
# Initialize with custom settings
testivai init \
--framework cypress \
--baseline-dir ./visual-tests/baseline \
--compare-dir ./visual-tests/current \
--report-dir ./visual-tests/reports \
--diff-threshold 0.05
# Compare with custom settings
testivai compare \
--baseline-dir ./visual-tests/baseline \
--compare-dir ./visual-tests/current \
--diff-threshold 0.05Exit Codes
0- Success1- Error occurred
License
MIT
