fix(tia): replayable scenarios running afterEach

This commit is contained in:
nuno maduro
2026-08-04 20:19:12 +01:00
parent 668809bc75
commit 872f0a50c2
29 changed files with 168 additions and 57 deletions
@@ -0,0 +1,9 @@
<?php
dataset('throws', function () {
throw new RuntimeException('boom from dataset');
});
it('x', function ($a) {
expect($a)->toBeTrue();
})->with('throws');
+34
View File
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
it('can fail with comparison', function () {
expect(true)->toEqual(false);
});
it('can be ignored because of no assertions', function () {
});
it('can be ignored because it is skipped', function () {
expect(true)->toBeTrue();
})->skip("this is why");
it('can fail', function () {
$this->fail("oh noo");
});
it('throws exception', function () {
throw new Exception('test error');
});
it('is not done yet', function () {
})->todo();
todo("build this one.");
it('is passing', function () {
expect(true)->toEqual(true);
});
+5
View File
@@ -0,0 +1,5 @@
<?php
it('fails after exhausting all retries', function () {
throw new Exception('Always fails');
})->flaky(tries: 2);
+7
View File
@@ -0,0 +1,7 @@
<?php
declare(strict_types=1);
it('references a missing dataset', function ($value) {
expect($value)->toBeTruthy();
})->with('missing');
@@ -0,0 +1,11 @@
<?php
declare(strict_types=1);
it('passes normally', function () {
expect(true)->toBeTrue();
});
it('references a missing dataset', function ($value) {
expect($value)->toBeTruthy();
})->with('missing');
@@ -0,0 +1,5 @@
<?php
it('belongs to group one', function () {
expect(true)->toBeTrue();
})->group('one');
@@ -0,0 +1,5 @@
<?php
it('belongs to group three', function () {
expect(true)->toBeTrue();
})->group('three');
@@ -0,0 +1,5 @@
<?php
it('belongs to group two', function () {
expect(true)->toBeTrue();
})->group('two');
@@ -0,0 +1,5 @@
<?php
test('missing dataset', function (string $value) {
expect($value)->toBe('x');
})->with('missing.dataset');
@@ -0,0 +1,3 @@
<?php
it('passes')->assertTrue(true);
+3
View File
@@ -0,0 +1,3 @@
<?php
it('tests unicode filename with ß')->assertTrue(true);
+21
View File
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
it('can pass with comparison', function () {
expect(true)->toEqual(true);
});
test('can also pass', function () {
expect("string")->toBeString();
});
test('can pass with dataset', function ($value) {
expect($value)->toEqual(true);
})->with([true]);
describe('block', function () {
test('can pass with dataset in describe block', function ($number) {
expect($number)->toBeInt();
})->with([1]);
});
+24
View File
@@ -0,0 +1,24 @@
<?php
// Only ever run through `tests/Features/Tia.php`, against a seeded TIA graph.
// Both hooks throw, so a replayed test that wrongly runs one fails the run.
beforeEach(function (): void {
throw new RuntimeException('The beforeEach hook must not run for replayed tests.');
});
afterEach(function (): void {
throw new RuntimeException('The afterEach hook must not run for replayed tests.');
});
test('replayed pass', function (): void {
expect(true)->toBeTrue();
});
test('replayed skip', function (): void {
expect(true)->toBeTrue();
});
test('replayed incomplete', function (): void {
expect(true)->toBeTrue();
});