feat: custom presets

This commit is contained in:
Nuno Maduro
2024-09-04 20:53:33 +01:00
parent a7ca7afe4e
commit dd20323ca7
12 changed files with 158 additions and 28 deletions

View File

@ -66,6 +66,7 @@
--fail-on-warning Signal failure using shell exit code when a warning was triggered
--fail-on-risky Signal failure using shell exit code when a test was considered risky
--fail-on-deprecation Signal failure using shell exit code when a deprecation was triggered
--fail-on-phpunit-deprecation Signal failure using shell exit code when a PHPUnit deprecation was triggered
--fail-on-notice Signal failure using shell exit code when a notice was triggered
--fail-on-skipped Signal failure using shell exit code when a test was skipped
--fail-on-incomplete Signal failure using shell exit code when a test was marked incomplete
@ -85,6 +86,7 @@
--display-incomplete .................. Display details for incomplete tests
--display-skipped ........................ Display details for skipped tests
--display-deprecations . Display details for deprecations triggered by tests
--display-phpunit-deprecations .... Display details for PHPUnit deprecations
--display-errors ............. Display details for errors triggered by tests
--display-notices ........... Display details for notices triggered by tests
--display-warnings ......... Display details for warnings triggered by tests

View File

@ -1,8 +1,8 @@
PASS Tests\Arch
arch "php" preset
arch "strict" preset
arch "security" preset
preset → php → ignoring ['Pest\Expectation', 'debug_backtrace', 'var_export', …]
preset → strict → ignoring ['usleep']
preset → security → ignoring ['eval', 'str_shuffle', 'exec', …]
✓ globals
✓ dependencies
✓ contracts
@ -1423,6 +1423,10 @@
PASS Tests\Unit\Plugins\Retry
✓ it orders by defects and stop on defects if when --retry is used
PASS Tests\Unit\Preset
✓ preset invalid name
✓ preset → myFramework
PASS Tests\Unit\Support\Backtrace
✓ it gets file name from called file
@ -1574,4 +1578,4 @@
WARN Tests\Visual\Version
- visual snapshot of help command output
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 17 todos, 28 skipped, 1089 passed (2621 assertions)
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 17 todos, 28 skipped, 1091 passed (2624 assertions)

13
tests/Unit/Preset.php Normal file
View File

@ -0,0 +1,13 @@
<?php
pest()->presets()->custom('myFramework', function (array $userNamespaces) {
return [
expect($userNamespaces)->toBe(['Pest']),
];
});
test('preset invalid name', function () {
$this->preset()->myAnotherFramework();
})->throws(InvalidArgumentException::class, 'The preset [myAnotherFramework] does not exist. The available presets are [php, laravel, strict, security, relaxed, myFramework].');
arch()->preset()->myFramework();

View File

@ -16,7 +16,7 @@ $run = function () {
test('parallel', function () use ($run) {
expect($run('--exclude-group=integration'))
->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 17 todos, 19 skipped, 1079 passed (2597 assertions)')
->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 17 todos, 19 skipped, 1081 passed (2600 assertions)')
->toContain('Parallel: 3 processes');
})->skipOnWindows();