WordPress / block-development-examples

Practical examples for building WordPress blocks and extending the Editor.
https://wordpress.github.io/block-development-examples/
GNU General Public License v2.0
213 stars 32 forks source link

Add basic insertion E2E tests. #81

Closed ryanwelcher closed 11 months ago

ryanwelcher commented 11 months ago

This PR adds basic E2E tests for each block to be sure that they are correctly inserted into the block editor.

Closes: #78.

Testing

If you run into issues, you may need to have pnpm install the devDependencies using pnpm install -D

juanmaguitar commented 11 months ago

I'm getting this error after following the instructions

⬢  block-development-examples  feature/add-e2e-tests ⦾ npm run test:e2e:debug

> block-development-examples@1.0.0 test:e2e:debug
> wp-scripts test-playwright --debug

Running 23 tests using 1 worker

  ✘  1 [chromium] › insertion.spec.js:36:7 › Block added to block editor › block-development-examples/counter-alpine-99def1 (41ms)

  1) [chromium] › insertion.spec.js:36:7 › Block added to block editor › block-development-examples/counter-alpine-99def1

    Error: browserType.launch: Executable doesn't exist at /Users/juanmanuelgarrido/Library/Caches/ms-playwright/chromium-1091/chrome-mac/Chromium.app/Contents/MacOS/Chromium
    ╔═════════════════════════════════════════════════════════════════════════╗
    ║ Looks like Playwright Test or Playwright was just installed or updated. ║
    ║ Please run the following command to download new browsers:              ║
    ║                                                                         ║
    ║     npx playwright install                                              ║
    ║                                                                         ║
    ║ <3 Playwright Team                                                      ║
    ╚═════════════════════════════════════════════════════════════════════════╝

    attachment #1: trace (application/zip) ─────────────────────────────────────────────────────────
    artifacts/test-results/insertion-Block-added-to-block-editor-block-development-examples-counter-alpine-99def1-chromium/trace.zip
    Usage:

        npx playwright show-trace artifacts/test-results/insertion-Block-added-to-block-editor-block-development-examples-counter-alpine-99def1-chromium/trace.zip

    ────────────────────────────────────────────────────────────────────────────────────────────────

Testing stopped early after 1 maximum allowed failures.
  1 failed
    [chromium] › insertion.spec.js:36:7 › Block added to block editor › block-development-examples/counter-alpine-99def1
  22 did not run

If I do npx playwright install I get

⬢  block-development-examples  feature/add-e2e-tests ⦾  npx playwright install
sh: playwright: command not found
juanmaguitar commented 11 months ago

Running npx playwright@latest install did the trick. The tests work and pass now for me ✅