@magic/test
CLI Flags Reference
Available command-line flags for @magic/test:
Flag Reference Table
| Flag | Aliases | Default | Env Var | Description | Example || :--- | :----- | :-----: | :------ | :---------- | :------ || -p, --production, --prod | | | | Run tests without coverage (faster) | t -p || -l, --verbose, --loud | | | | Show detailed output including passing tests | t -l || -i, --include | | | | Files to include in coverage | t -i "src/*.js" || -e, --exclude | | | | Files to exclude from coverage and .d.ts type tests | t -e "src/test.js" || --shards N | | | | Total number of shards to split tests across | t --shards 4 --shard-id 0 || --shard-id N | | | | Shard ID (0-indexed) to run | t --shards 4 --shard-id 2 || -s, --slow, --timing | | | MAGIC_TEST_TIMING | Show the slowest tests | t -s || --error-length N | | 70 | MAGIC_TEST_ERROR_LENGTH | Max length for error strings (0 = no limit) | t --error-length 0 || --timeout N | -t, --to | 30000 | MAGIC_TEST_TIMEOUT | Test timeout in ms | t --timeout 60000 || -w, --workers N | | auto | MAGIC_TEST_WORKERS | Max parallel workers (auto: capped at 4, load-adaptive) | t -p --workers 2 || --nice N | | 10 | MAGIC_TEST_NICE | CPU nice value 0-19 for the test process (0 disables) | t --nice 5 || --native | | | | Run with the native node --test runner (with coverage) | t --native || --help | | | | Show help text | t --help |
Flag Notes
- --shards and --shard-id must be used together
- --shard-id is 0-indexed (0 to N-1)
- Use -p flag for faster development runs (no coverage)
- --workers controls parallel test execution
Example Usage
Basic Test Run
npm run coverage # runs with coveragenpm test # t -p, no coverage (faster)
Shard Large Test Suite
# Run 4 shards, this is shard 0 (of 0-3)t --shards 4 --shard-id 0# Run shard 1t --shards 4 --shard-id 1# Combine with other flagst -p --shards 4 --shard-id 2 --workers 2
See Also
- CLI & Usage - detailed usage guide
- Performance Tips - optimization techniques
- CLI Sharding Cheat-Sheet - CI/CD examples