mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
add tests for snapshots external to the tests directory
This commit is contained in:
@ -16,6 +16,7 @@
|
|||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="default">
|
<testsuite name="default">
|
||||||
<directory suffix=".php">./tests</directory>
|
<directory suffix=".php">./tests</directory>
|
||||||
|
<directory suffix=".php">./tests-external</directory>
|
||||||
<exclude>./tests/.snapshots</exclude>
|
<exclude>./tests/.snapshots</exclude>
|
||||||
<exclude>./tests/.tests</exclude>
|
<exclude>./tests/.tests</exclude>
|
||||||
<exclude>./tests/Fixtures/Inheritance</exclude>
|
<exclude>./tests/Fixtures/Inheritance</exclude>
|
||||||
|
|||||||
35
tests-external/Features/Expect/toMatchSnapshot.php
Normal file
35
tests-external/Features/Expect/toMatchSnapshot.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Pest\TestSuite;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
$this->snapshotable = <<<'HTML'
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<h1>Snapshot</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
HTML;
|
||||||
|
});
|
||||||
|
|
||||||
|
test('pass with dataset', function ($data) {
|
||||||
|
TestSuite::getInstance()->snapshots->save($this->snapshotable);
|
||||||
|
[$filename] = TestSuite::getInstance()->snapshots->get();
|
||||||
|
|
||||||
|
expect($filename)->toStartWith('tests/.pest/snapshots-external/')
|
||||||
|
->toEndWith('pass_with_dataset_with_data_set____my_datas_set_value______my_datas_set_value__.snap')
|
||||||
|
->and($this->snapshotable)->toMatchSnapshot();
|
||||||
|
})->with(['my-datas-set-value']);
|
||||||
|
|
||||||
|
describe('within describe', function () {
|
||||||
|
test('pass with dataset', function ($data) {
|
||||||
|
TestSuite::getInstance()->snapshots->save($this->snapshotable);
|
||||||
|
[$filename] = TestSuite::getInstance()->snapshots->get();
|
||||||
|
|
||||||
|
expect($filename)->toStartWith('tests/.pest/snapshots-external/')
|
||||||
|
->toEndWith('pass_with_dataset_with_data_set____my_datas_set_value______my_datas_set_value__.snap')
|
||||||
|
->and($this->snapshotable)->toMatchSnapshot();
|
||||||
|
});
|
||||||
|
})->with(['my-datas-set-value']);
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<h1>Snapshot</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<h1>Snapshot</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@ -74,7 +74,8 @@ test('pass with dataset', function ($data) {
|
|||||||
TestSuite::getInstance()->snapshots->save($this->snapshotable);
|
TestSuite::getInstance()->snapshots->save($this->snapshotable);
|
||||||
[$filename] = TestSuite::getInstance()->snapshots->get();
|
[$filename] = TestSuite::getInstance()->snapshots->get();
|
||||||
|
|
||||||
expect($filename)->toEndWith('pass_with_dataset_with_data_set____my_datas_set_value______my_datas_set_value__.snap')
|
expect($filename)->toStartWith('tests/.pest/snapshots/')
|
||||||
|
->toEndWith('pass_with_dataset_with_data_set____my_datas_set_value______my_datas_set_value__.snap')
|
||||||
->and($this->snapshotable)->toMatchSnapshot();
|
->and($this->snapshotable)->toMatchSnapshot();
|
||||||
})->with(['my-datas-set-value']);
|
})->with(['my-datas-set-value']);
|
||||||
|
|
||||||
@ -83,7 +84,8 @@ describe('within describe', function () {
|
|||||||
TestSuite::getInstance()->snapshots->save($this->snapshotable);
|
TestSuite::getInstance()->snapshots->save($this->snapshotable);
|
||||||
[$filename] = TestSuite::getInstance()->snapshots->get();
|
[$filename] = TestSuite::getInstance()->snapshots->get();
|
||||||
|
|
||||||
expect($filename)->toEndWith('pass_with_dataset_with_data_set____my_datas_set_value______my_datas_set_value__.snap')
|
expect($filename)->toStartWith('tests/.pest/snapshots/')
|
||||||
|
->toEndWith('pass_with_dataset_with_data_set____my_datas_set_value______my_datas_set_value__.snap')
|
||||||
->and($this->snapshotable)->toMatchSnapshot();
|
->and($this->snapshotable)->toMatchSnapshot();
|
||||||
});
|
});
|
||||||
})->with(['my-datas-set-value']);
|
})->with(['my-datas-set-value']);
|
||||||
|
|||||||
Reference in New Issue
Block a user