mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Merge pull request #1304 from jshayes/fix/sibling-describe-blocks
Fix an issue with describe blocks with matching names
This commit is contained in:
@ -32,7 +32,7 @@ final class TestCaseMethodFactory
|
||||
/**
|
||||
* The test's describing, if any.
|
||||
*
|
||||
* @var array<int, string>
|
||||
* @var array<int, \Pest\Support\Description>
|
||||
*/
|
||||
public array $describing = [];
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@ use Pest\Repositories\DatasetsRepository;
|
||||
use Pest\Support\Backtrace;
|
||||
use Pest\Support\Container;
|
||||
use Pest\Support\DatasetInfo;
|
||||
use Pest\Support\Description;
|
||||
use Pest\Support\HigherOrderTapProxy;
|
||||
use Pest\TestSuite;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@ -98,7 +99,7 @@ if (! function_exists('describe')) {
|
||||
{
|
||||
$filename = Backtrace::testFile();
|
||||
|
||||
return new DescribeCall(TestSuite::getInstance(), $filename, $description, $tests);
|
||||
return new DescribeCall(TestSuite::getInstance(), $filename, new Description($description), $tests);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -12,14 +12,14 @@ trait Describable
|
||||
/**
|
||||
* Note: this is property is not used; however, it gets added automatically by rector php.
|
||||
*
|
||||
* @var array<int, string>
|
||||
* @var array<int, \Pest\Support\Description>
|
||||
*/
|
||||
public array $__describing;
|
||||
|
||||
/**
|
||||
* The describing of the test case.
|
||||
*
|
||||
* @var array<int, string>
|
||||
* @var array<int, \Pest\Support\Description>
|
||||
*/
|
||||
public array $describing = [];
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ namespace Pest\PendingCalls;
|
||||
|
||||
use Closure;
|
||||
use Pest\Support\Backtrace;
|
||||
use Pest\Support\Description;
|
||||
use Pest\TestSuite;
|
||||
|
||||
/**
|
||||
@ -16,7 +17,7 @@ final class DescribeCall
|
||||
/**
|
||||
* The current describe call.
|
||||
*
|
||||
* @var array<int, string>
|
||||
* @var array<int, Description>
|
||||
*/
|
||||
private static array $describing = [];
|
||||
|
||||
@ -31,7 +32,7 @@ final class DescribeCall
|
||||
public function __construct(
|
||||
public readonly TestSuite $testSuite,
|
||||
public readonly string $filename,
|
||||
public readonly string $description,
|
||||
public readonly Description $description,
|
||||
public readonly Closure $tests
|
||||
) {
|
||||
//
|
||||
@ -40,7 +41,7 @@ final class DescribeCall
|
||||
/**
|
||||
* What is the current describing.
|
||||
*
|
||||
* @return array<int, string>
|
||||
* @return array<int, Description>
|
||||
*/
|
||||
public static function describing(): array
|
||||
{
|
||||
|
||||
15
src/Support/Description.php
Normal file
15
src/Support/Description.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pest\Support;
|
||||
|
||||
final readonly class Description implements \Stringable
|
||||
{
|
||||
public function __construct(private string $description) {}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
}
|
||||
@ -101,7 +101,7 @@ final class Str
|
||||
/**
|
||||
* Creates a describe block as `$describeDescription` → `$testDescription` format.
|
||||
*
|
||||
* @param array<int, string> $describeDescriptions
|
||||
* @param array<int, Description> $describeDescriptions
|
||||
*/
|
||||
public static function describe(array $describeDescriptions, string $testDescription): string
|
||||
{
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
↓ todo on describe → should not fail
|
||||
↓ todo on describe → should run
|
||||
|
||||
TODO Tests\Features\Todo - 28 todos
|
||||
TODO Tests\Features\Todo - 29 todos
|
||||
↓ something todo later
|
||||
↓ something todo later chained
|
||||
↓ something todo later chained and with function body
|
||||
@ -45,6 +45,7 @@
|
||||
// nested describe note
|
||||
// test note
|
||||
↓ todo on describe → todo block → it should not execute
|
||||
↓ todo on describe with matching name → describe block → it should not execute
|
||||
↓ todo on test after describe block
|
||||
↓ todo with note on test after describe block
|
||||
// test note
|
||||
@ -80,6 +81,6 @@
|
||||
PASS Tests\CustomTestCase\ParentTest
|
||||
✓ override method
|
||||
|
||||
Tests: 38 todos, 3 passed (20 assertions)
|
||||
Tests: 39 todos, 3 passed (21 assertions)
|
||||
Duration: x.xxs
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
↓ todo on describe → should not fail
|
||||
↓ todo on describe → should run
|
||||
|
||||
TODO Tests\Features\Todo - 28 todos
|
||||
TODO Tests\Features\Todo - 29 todos
|
||||
↓ something todo later
|
||||
↓ something todo later chained
|
||||
↓ something todo later chained and with function body
|
||||
@ -45,6 +45,7 @@
|
||||
// nested describe note
|
||||
// test note
|
||||
↓ todo on describe → todo block → it should not execute
|
||||
↓ todo on describe with matching name → describe block → it should not execute
|
||||
↓ todo on test after describe block
|
||||
↓ todo with note on test after describe block
|
||||
// test note
|
||||
@ -80,6 +81,6 @@
|
||||
PASS Tests\CustomTestCase\ParentTest
|
||||
✓ override method
|
||||
|
||||
Tests: 38 todos, 3 passed (20 assertions)
|
||||
Tests: 39 todos, 3 passed (21 assertions)
|
||||
Duration: x.xxs
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
↓ todo on describe → should not fail
|
||||
↓ todo on describe → should run
|
||||
|
||||
TODO Tests\Features\Todo - 28 todos
|
||||
TODO Tests\Features\Todo - 29 todos
|
||||
↓ something todo later
|
||||
↓ something todo later chained
|
||||
↓ something todo later chained and with function body
|
||||
@ -45,6 +45,7 @@
|
||||
// nested describe note
|
||||
// test note
|
||||
↓ todo on describe → todo block → it should not execute
|
||||
↓ todo on describe with matching name → describe block → it should not execute
|
||||
↓ todo on test after describe block
|
||||
↓ todo with note on test after describe block
|
||||
// test note
|
||||
@ -80,6 +81,6 @@
|
||||
PASS Tests\CustomTestCase\ParentTest
|
||||
✓ override method
|
||||
|
||||
Tests: 38 todos, 3 passed (20 assertions)
|
||||
Tests: 39 todos, 3 passed (21 assertions)
|
||||
Duration: x.xxs
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
↓ todo on describe → should not fail
|
||||
↓ todo on describe → should run
|
||||
|
||||
TODO Tests\Features\Todo - 28 todos
|
||||
TODO Tests\Features\Todo - 29 todos
|
||||
↓ something todo later
|
||||
↓ something todo later chained
|
||||
↓ something todo later chained and with function body
|
||||
@ -45,6 +45,7 @@
|
||||
// nested describe note
|
||||
// test note
|
||||
↓ todo on describe → todo block → it should not execute
|
||||
↓ todo on describe with matching name → describe block → it should not execute
|
||||
↓ todo on test after describe block
|
||||
↓ todo with note on test after describe block
|
||||
// test note
|
||||
@ -80,6 +81,6 @@
|
||||
PASS Tests\CustomTestCase\ParentTest
|
||||
✓ override method
|
||||
|
||||
Tests: 38 todos, 3 passed (20 assertions)
|
||||
Tests: 39 todos, 3 passed (21 assertions)
|
||||
Duration: x.xxs
|
||||
|
||||
|
||||
@ -28,6 +28,12 @@
|
||||
✓ it gets executed after the test
|
||||
✓ outer → inner → it does not get executed before the test
|
||||
✓ outer → inner → it should call all parent afterEach functions
|
||||
✓ matching describe block names → outer → middle → inner → it does not get executed before the test
|
||||
✓ matching describe block names → outer → middle → inner → it should call all parent afterEach functions
|
||||
✓ matching describe block names → outer → middle → it does not get executed before the test
|
||||
✓ matching describe block names → outer → middle → it should not call afterEach functions for sibling describe blocks with the same name
|
||||
✓ matching describe block names → outer → inner → it does not get executed before the test
|
||||
✓ matching describe block names → outer → inner → it should not call afterEach functions for descendent of sibling describe blocks with the same name
|
||||
|
||||
PASS Tests\Features\Assignee
|
||||
✓ it may be associated with an assignee [@nunomaduro, @taylorotwell]
|
||||
@ -44,6 +50,13 @@
|
||||
✓ outer → inner → it should call all parent beforeEach functions
|
||||
✓ with expectations → nested block → test
|
||||
✓ with expectations → test
|
||||
✓ matching describe block names → outer → middle → inner → it should call all parent beforeEach functions
|
||||
✓ matching describe block names → outer → middle → it should not call beforeEach functions for sibling describe blocks with the same name
|
||||
✓ matching describe block names → outer → inner → it should not call beforeEach functions for descendent of sibling describe blocks with the same name
|
||||
✓ matching name → it should call the before each
|
||||
✓ matching name → it should not call the before each on the describe block with the same name
|
||||
✓ called on all tests → beforeEach should be called
|
||||
✓ called on all tests → beforeEach should be called for all tests
|
||||
|
||||
PASS Tests\Features\BeforeEachProxiesToTestCallWithExpectations
|
||||
✓ runs 1
|
||||
@ -196,6 +209,11 @@
|
||||
✓ with on nested describe → nested → describe → it should include the with value from all parent describe blocks with (1) / (2)
|
||||
✓ with on nested describe → nested → describe → should include the with value from all parent describe blocks and the test with (1) / (2) / (3)
|
||||
✓ with on nested describe → nested → after inner describe block with (1)
|
||||
✓ matching describe block names → outer → before inner describe block with (1)
|
||||
✓ matching describe block names → outer → inner → it should include the with value from all parent describe blocks with (1) / (2)
|
||||
✓ matching describe block names → outer → inner → should include the with value from all parent describe blocks and the test with (1) / (2) / (3)
|
||||
✓ matching describe block names → outer → inner → it should not include the value from the other describe block with the same name with (1)
|
||||
✓ matching describe block names → outer → after inner describe block with (1)
|
||||
✓ after describe block with (5)
|
||||
✓ it may be used with high order after describe block with dataset "formal"
|
||||
✓ it may be used with high order after describe block with dataset "informal"
|
||||
@ -1124,6 +1142,25 @@
|
||||
// This is before each describe runtime note
|
||||
// This is before each nested describe runtime note
|
||||
// This is a runtime note within a nested describe
|
||||
✓ matching describe names → describe block → it may have a static note and runtime note
|
||||
// This is before each static note
|
||||
// This is before each matching describe static note
|
||||
// This is a nested matching static note
|
||||
// This is a static note within a matching describe
|
||||
// This is before each runtime note
|
||||
// This is before each matching describe runtime note
|
||||
// This is before each matching describe runtime note
|
||||
// This is a runtime note within a matching describe
|
||||
✓ matching describe names → describe block → it may have a static note and runtime note, that are different than the matching describe block
|
||||
// This is before each static note
|
||||
// This is before each matching describe static note
|
||||
// This is a nested matching static note, and should not contain the matching describe notes
|
||||
// This is before each matching describe static note, and should not contain the matching describe notes
|
||||
// This is a static note within a matching describe, and should not contain the matching describe notes
|
||||
// This is before each runtime note
|
||||
// This is before each matching describe runtime note
|
||||
// This is before each matching describe runtime note, and should not contain the matching describe notes
|
||||
// This is a runtime note within a matching describe, and should not contain the matching describe notes
|
||||
✓ multiple notes
|
||||
// This is before each static note
|
||||
// This is before each runtime note
|
||||
@ -1274,6 +1311,10 @@
|
||||
✓ describe blocks → describe with repeat → nested describe with repeat → test with no repeat should repeat the number of times specified in the parent describe block @ repetition 2 of 2
|
||||
✓ describe blocks → describe with repeat → nested describe with repeat → test with repeat should repeat the number of times specified in the test @ repetition 1 of 2
|
||||
✓ describe blocks → describe with repeat → nested describe with repeat → test with repeat should repeat the number of times specified in the test @ repetition 2 of 2
|
||||
✓ matching describe blocks → describe block → it should repeat the number of times specified in the parent describe block @ repetition 1 of 3
|
||||
✓ matching describe blocks → describe block → it should repeat the number of times specified in the parent describe block @ repetition 2 of 3
|
||||
✓ matching describe blocks → describe block → it should repeat the number of times specified in the parent describe block @ repetition 3 of 3
|
||||
✓ matching describe blocks → describe block → should not repeat the number of times of the describe block with the same name
|
||||
|
||||
PASS Tests\Features\ScopedDatasets\Directory\NestedDirectory1\TestFileInNestedDirectoryWithDatasetsFile
|
||||
✓ uses dataset with (1)
|
||||
@ -1340,6 +1381,12 @@
|
||||
- skip on beforeEach → skipped tests → nested inside skipped block → it should not execute
|
||||
- skip on beforeEach → skipped tests → it should not execute
|
||||
✓ skip on beforeEach → it should execute
|
||||
- matching describe with skip → describe block → it should not execute
|
||||
✓ matching describe with skip → describe block → it should execute a test in a describe block with the same name as a skipped describe block
|
||||
✓ matching describe with skip → it should execute
|
||||
- matching describe with skip on beforeEach → describe block → it should not execute
|
||||
✓ matching describe with skip on beforeEach → describe block → it should execute a test in a describe block with the same name as a skipped describe block
|
||||
✓ matching describe with skip on beforeEach → it should execute
|
||||
✓ it does not skip after the describe block
|
||||
- it can skip after the describe block
|
||||
|
||||
@ -1362,7 +1409,7 @@
|
||||
✓ nested → it may be associated with an ticket #1, #4, #5, #6, #3
|
||||
// an note between an the ticket
|
||||
|
||||
PASS Tests\Features\Todo - 28 todos
|
||||
PASS Tests\Features\Todo - 29 todos
|
||||
↓ something todo later
|
||||
↓ something todo later chained
|
||||
↓ something todo later chained and with function body
|
||||
@ -1394,6 +1441,9 @@
|
||||
// test note
|
||||
↓ todo on describe → todo block → it should not execute
|
||||
✓ todo on describe → it should execute
|
||||
↓ todo on describe with matching name → describe block → it should not execute
|
||||
✓ todo on describe with matching name → describe block → it should execute a test in a describe block with the same name as a todo describe block
|
||||
✓ todo on describe with matching name → it should execute
|
||||
↓ todo on test after describe block
|
||||
↓ todo with note on test after describe block
|
||||
// test note
|
||||
@ -1735,4 +1785,5 @@
|
||||
✓ pass with dataset with ('my-datas-set-value')
|
||||
✓ within describe → pass with dataset with ('my-datas-set-value')
|
||||
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 38 todos, 33 skipped, 1159 passed (2774 assertions)
|
||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 38 todos, 33 skipped, 1159 passed (2774 assertions)
|
||||
|
||||
|
||||
@ -48,3 +48,55 @@ describe('outer', function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('matching describe block names', function () {
|
||||
afterEach(function () {
|
||||
$this->state->foo = 1;
|
||||
});
|
||||
|
||||
describe('outer', function () {
|
||||
afterEach(function () {
|
||||
$this->state->foo++;
|
||||
});
|
||||
|
||||
describe('middle', function () {
|
||||
afterEach(function () {
|
||||
$this->state->foo++;
|
||||
});
|
||||
|
||||
describe('inner', function () {
|
||||
afterEach(function () {
|
||||
$this->state->foo++;
|
||||
});
|
||||
|
||||
it('does not get executed before the test', function () {
|
||||
expect($this)->not->toHaveProperty('foo');
|
||||
});
|
||||
|
||||
it('should call all parent afterEach functions', function () {
|
||||
expect($this->state->foo)->toBe(4);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('middle', function () {
|
||||
it('does not get executed before the test', function () {
|
||||
expect($this)->not->toHaveProperty('foo');
|
||||
});
|
||||
|
||||
it('should not call afterEach functions for sibling describe blocks with the same name', function () {
|
||||
expect($this)->not->toHaveProperty('foo');
|
||||
});
|
||||
});
|
||||
|
||||
describe('inner', function () {
|
||||
it('does not get executed before the test', function () {
|
||||
expect($this)->not->toHaveProperty('foo');
|
||||
});
|
||||
|
||||
it('should not call afterEach functions for descendent of sibling describe blocks with the same name', function () {
|
||||
expect($this)->not->toHaveProperty('foo');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -51,3 +51,78 @@ describe('with expectations', function () {
|
||||
|
||||
test('test', function () {});
|
||||
});
|
||||
|
||||
describe('matching describe block names', function () {
|
||||
beforeEach(function () {
|
||||
$this->foo = 1;
|
||||
});
|
||||
|
||||
describe('outer', function () {
|
||||
beforeEach(function () {
|
||||
$this->foo++;
|
||||
});
|
||||
|
||||
describe('middle', function () {
|
||||
beforeEach(function () {
|
||||
$this->foo++;
|
||||
});
|
||||
|
||||
describe('inner', function () {
|
||||
beforeEach(function () {
|
||||
$this->foo++;
|
||||
});
|
||||
|
||||
it('should call all parent beforeEach functions', function () {
|
||||
expect($this->foo)->toBe(4);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('middle', function () {
|
||||
it('should not call beforeEach functions for sibling describe blocks with the same name', function () {
|
||||
expect($this->foo)->toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('inner', function () {
|
||||
it('should not call beforeEach functions for descendent of sibling describe blocks with the same name', function () {
|
||||
expect($this->foo)->toBe(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$matchingNameCalls = 0;
|
||||
describe('matching name', function () use (&$matchingNameCalls) {
|
||||
beforeEach(function () use (&$matchingNameCalls) {
|
||||
$matchingNameCalls++;
|
||||
});
|
||||
|
||||
it('should call the before each', function () use (&$matchingNameCalls) {
|
||||
expect($matchingNameCalls)->toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('matching name', function () use (&$matchingNameCalls) {
|
||||
it('should not call the before each on the describe block with the same name', function () use (&$matchingNameCalls) {
|
||||
expect($matchingNameCalls)->toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
$this->baz = 1;
|
||||
});
|
||||
|
||||
describe('called on all tests', function () {
|
||||
beforeEach(function () {
|
||||
$this->baz++;
|
||||
});
|
||||
|
||||
test('beforeEach should be called', function () {
|
||||
expect($this->baz)->toBe(2);
|
||||
});
|
||||
|
||||
test('beforeEach should be called for all tests', function () {
|
||||
expect($this->baz)->toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
@ -415,6 +415,34 @@ describe('with on nested describe', function () {
|
||||
})->with([1]);
|
||||
});
|
||||
|
||||
describe('matching describe block names', function () {
|
||||
describe('outer', function () {
|
||||
test('before inner describe block', function (...$args) {
|
||||
expect($args)->toBe([1]);
|
||||
});
|
||||
|
||||
describe('inner', function () {
|
||||
it('should include the with value from all parent describe blocks', function (...$args) {
|
||||
expect($args)->toBe([1, 2]);
|
||||
});
|
||||
|
||||
test('should include the with value from all parent describe blocks and the test', function (...$args) {
|
||||
expect($args)->toBe([1, 2, 3]);
|
||||
})->with([3]);
|
||||
})->with([2]);
|
||||
|
||||
describe('inner', function () {
|
||||
it('should not include the value from the other describe block with the same name', function (...$args) {
|
||||
expect($args)->toBe([1]);
|
||||
});
|
||||
});
|
||||
|
||||
test('after inner describe block', function (...$args) {
|
||||
expect($args)->toBe([1]);
|
||||
});
|
||||
})->with([1]);
|
||||
});
|
||||
|
||||
test('after describe block', function (...$args) {
|
||||
expect($args)->toBe([5]);
|
||||
})->with([5]);
|
||||
|
||||
@ -44,6 +44,36 @@ describe('nested', function () {
|
||||
})->note('This is a nested describe static note');
|
||||
})->note('This is describe static note');
|
||||
|
||||
describe('matching describe names', function () {
|
||||
beforeEach(function () {
|
||||
$this->note('This is before each matching describe runtime note');
|
||||
})->note('This is before each matching describe static note');
|
||||
|
||||
describe('describe block', function () {
|
||||
beforeEach(function () {
|
||||
$this->note('This is before each matching describe runtime note');
|
||||
})->note('This is before each matching describe static note');
|
||||
|
||||
it('may have a static note and runtime note', function () {
|
||||
expect(true)->toBeTrue(true);
|
||||
|
||||
$this->note('This is a runtime note within a matching describe');
|
||||
})->note('This is a static note within a matching describe');
|
||||
})->note('This is a nested matching static note');
|
||||
|
||||
describe('describe block', function () {
|
||||
beforeEach(function () {
|
||||
$this->note('This is before each matching describe runtime note, and should not contain the matching describe notes');
|
||||
})->note('This is before each matching describe static note, and should not contain the matching describe notes');
|
||||
|
||||
it('may have a static note and runtime note, that are different than the matching describe block', function () {
|
||||
expect(true)->toBeTrue(true);
|
||||
|
||||
$this->note('This is a runtime note within a matching describe, and should not contain the matching describe notes');
|
||||
})->note('This is a static note within a matching describe, and should not contain the matching describe notes');
|
||||
})->note('This is a nested matching static note, and should not contain the matching describe notes');
|
||||
});
|
||||
|
||||
test('multiple notes', function () {
|
||||
expect(true)->toBeTrue(true);
|
||||
|
||||
|
||||
@ -79,3 +79,17 @@ describe('describe blocks', function () {
|
||||
})->repeat(times: 2);
|
||||
})->repeat(times: 3);
|
||||
});
|
||||
|
||||
describe('matching describe blocks', function () {
|
||||
describe('describe block', function () {
|
||||
it('should repeat the number of times specified in the parent describe block', function () {
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
})->repeat(times: 3);
|
||||
|
||||
describe('describe block', function () {
|
||||
test('should not repeat the number of times of the describe block with the same name', function () {
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -125,6 +125,74 @@ describe('skip on beforeEach', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('matching describe with skip', function () {
|
||||
beforeEach(function () {
|
||||
$this->ran = false;
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
match ($this->name()) {
|
||||
'__pest_evaluable__matching_describe_with_skip__→__describe_block__→_it_should_not_execute' => expect($this->ran)->toBe(false),
|
||||
'__pest_evaluable__matching_describe_with_skip__→__describe_block__→_it_should_execute_a_test_in_a_describe_block_with_the_same_name_as_a_skipped_describe_block' => expect($this->ran)->toBe(true),
|
||||
'__pest_evaluable__matching_describe_with_skip__→_it_should_execute' => expect($this->ran)->toBe(true),
|
||||
default => $this->fail('Unexpected test name: '.$this->name()),
|
||||
};
|
||||
});
|
||||
|
||||
describe('describe block', function () {
|
||||
it('should not execute', function () {
|
||||
$this->ran = true;
|
||||
$this->fail();
|
||||
});
|
||||
})->skip();
|
||||
|
||||
describe('describe block', function () {
|
||||
it('should execute a test in a describe block with the same name as a skipped describe block', function () {
|
||||
$this->ran = true;
|
||||
});
|
||||
});
|
||||
|
||||
it('should execute', function () {
|
||||
$this->ran = true;
|
||||
expect($this->ran)->toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('matching describe with skip on beforeEach', function () {
|
||||
beforeEach(function () {
|
||||
$this->ran = false;
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
match ($this->name()) {
|
||||
'__pest_evaluable__matching_describe_with_skip_on_beforeEach__→__describe_block__→_it_should_not_execute' => expect($this->ran)->toBe(false),
|
||||
'__pest_evaluable__matching_describe_with_skip_on_beforeEach__→__describe_block__→_it_should_execute_a_test_in_a_describe_block_with_the_same_name_as_a_skipped_describe_block' => expect($this->ran)->toBe(true),
|
||||
'__pest_evaluable__matching_describe_with_skip_on_beforeEach__→_it_should_execute' => expect($this->ran)->toBe(true),
|
||||
default => $this->fail('Unexpected test name: '.$this->name()),
|
||||
};
|
||||
});
|
||||
|
||||
describe('describe block', function () {
|
||||
beforeEach()->skip();
|
||||
|
||||
it('should not execute', function () {
|
||||
$this->ran = true;
|
||||
$this->fail();
|
||||
});
|
||||
});
|
||||
|
||||
describe('describe block', function () {
|
||||
it('should execute a test in a describe block with the same name as a skipped describe block', function () {
|
||||
$this->ran = true;
|
||||
});
|
||||
});
|
||||
|
||||
it('should execute', function () {
|
||||
$this->ran = true;
|
||||
expect($this->ran)->toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('does not skip after the describe block', function () {
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
|
||||
@ -108,6 +108,40 @@ describe('todo on describe', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('todo on describe with matching name', function () {
|
||||
beforeEach(function () {
|
||||
$this->ran = false;
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
match ($this->name()) {
|
||||
'__pest_evaluable__todo_on_describe_with_matching_name__→__describe_block__→_it_should_not_execute' => expect($this->ran)->toBe(false),
|
||||
'__pest_evaluable__todo_on_describe_with_matching_name__→__describe_block__→_it_should_execute_a_test_in_a_describe_block_with_the_same_name_as_a_todo_describe_block' => expect($this->ran)->toBe(true),
|
||||
'__pest_evaluable__todo_on_describe_with_matching_name__→_it_should_execute' => expect($this->ran)->toBe(true),
|
||||
|
||||
default => $this->fail('Unexpected test name: '.$this->name()),
|
||||
};
|
||||
});
|
||||
|
||||
describe('describe block', function () {
|
||||
it('should not execute', function () {
|
||||
$this->ran = true;
|
||||
$this->fail();
|
||||
});
|
||||
})->todo();
|
||||
|
||||
describe('describe block', function () {
|
||||
it('should execute a test in a describe block with the same name as a todo describe block', function () {
|
||||
$this->ran = true;
|
||||
});
|
||||
});
|
||||
|
||||
it('should execute', function () {
|
||||
$this->ran = true;
|
||||
expect($this->ran)->toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
test('todo on test after describe block', function () {
|
||||
$this->fail();
|
||||
})->todo();
|
||||
|
||||
@ -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, 38 todos, 24 skipped, 1149 passed (2750 assertions)')
|
||||
->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 39 todos, 26 skipped, 1172 passed (2761 assertions)')
|
||||
->toContain('Parallel: 3 processes');
|
||||
})->skipOnWindows();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user