swup / fragment-plugin

A swup plugin for dynamically replacing containers based on rules 🧩
https://swup-fragment-plugin.netlify.app
MIT License
15 stars 1 forks source link

feat: playwright tests #64

Closed hirasso closed 10 months ago

hirasso commented 10 months ago

Description

Adds basic e2e test coverage to the plugin.

Checks

hirasso commented 10 months ago

@daun how exactly do I install the browsers for playwright? Is the action test:e2e:install in swup actually being exectued from somewhere?

https://github.com/swup/fragment-plugin/actions/runs/6852523927/job/18631255071?pr=64#step:7:12

daun commented 10 months ago

@hirasso I don't think it's being executed. The core's rather complicated GitHub action does that on its own. With the much simpler action files for the plugin, you could run the npm script from there.

hirasso commented 10 months ago

TIL caching playwright isn't necessarily speeding up actions.

Without cache: 2m 20s With cache: 2m 57s

hirasso commented 10 months ago

@daun do you understand what's happening here?

https://github.com/swup/fragment-plugin/actions/runs/6860973311/job/18655736640?pr=64#step:8:10

Error: Report file results.json not found. Make sure Playwright is configured to generate a JSON report.

If I understand the config correctly, it should spit out the results.json at the root when in CI:

reporter: process.env.CI
    ? [['dot'], ['github'], ['json', { outputFile: '../../report.json' }]]
    : [['list'], ['html', { outputFolder: '../reports/html', open: 'on-failure' }]],

Although swup's playwright config doesn't even report JSON at all when in CI: https://github.com/swup/swup/blob/1cd87ea335b95b9b8caee602634974f5011d2cc7/tests/config/playwright.config.ts#L32-L40

hirasso commented 10 months ago

It's not THAT important I'd say, I could totally live without the reporter in the PR tbh :)

daun commented 10 months ago

@hirasso It's currently report.json vs. results.json 🤠 Matching both should fix it hopefully.

hirasso commented 10 months ago

Haha true 😆 so many trees 🌲🌳🌴🏝️

github-actions[bot] commented 10 months ago

Playwright test results

passed  12 passed

Details

stats  12 tests across 1 suite
duration  28.7 seconds
commit  b2332df

hirasso commented 10 months ago

OMG it's working! 🤯🥳

...ready for review 🤪

hirasso commented 10 months ago

I guess the playwright shield status will appear when this is merged.

hirasso commented 10 months ago

I decided to use "vitest" and "playwright" instead of "unit" and "e2e" since the vitest tests aren't all real unit tests. The line is blurry.

daun commented 10 months ago

Makes sense! The reason I've used functional and unit was mostly to make it understandable for people who haven't used/heard of both tools, but that's probably not too many people anyway.