markhuot / craft-pest

https://craft-pest.com
Other
38 stars 11 forks source link

initial playwright thinking #74

Open markhuot opened 1 year ago

markhuot commented 1 year ago

This adds a ->playwright() method on the TestCase that will kick off a child process to run Playwright against a local server. This opens up a lot of potential features, but most exciting is using Factories to spin up a test case that can then be inspected via Javascript. E.g.,

it('tests guest entries', function () {
  $entry = Entry::factory()
    ->title('My Awesome Entry')
    ->create();

  $this->playwright()->assertOk();
});

That would automatically create an entry and run a playwright test file like,

tests('edits entry', async ({ page }) => {
  await page.gotTo('/guest-entry/edit');
  await page.getByLabel('Title').toBeVisible().toHaveValue('My Awesome Entry');
});