CRUD Testing Command
Thecrud-testing
command generates test files for CRUD (Create, Read, Update, Delete) operations in your zopio
project. This helps ensure your API endpoints and data handling functions work correctly.
Usage
Options
Option | Description |
---|---|
-m, --model <name> | Model name |
-f, --fields <fields> | Fields in format “name:type:example,age:number:30” |
-o, --output <directory> | Output directory for tests |
-t, --test-framework <framework> | Test framework (jest, mocha) (default: “jest”) |
-h, --help | Display help for command |
Examples
Generate Jest tests for a User model
Generate Mocha tests for a Product model
Generated Files
When you run thecrud-testing
command, the following test files will be generated:
- API Tests: Tests for API endpoints
- Service Tests: Tests for service functions
- Repository Tests: Tests for database operations
- Model Tests: Tests for model validation
- Test Fixtures: Sample data for testing
Example Test Structure
Example Jest Test
Related Commands
crud
- Generate basic CRUD operationscrud-unified
- Generate a complete CRUD setup