Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create and run automated tests for WordPress blocks #269

Open
bph opened this issue Jun 7, 2024 Discussed in #24 · 1 comment
Open

How to create and run automated tests for WordPress blocks #269

bph opened this issue Jun 7, 2024 Discussed in #24 · 1 comment
Labels

Comments

@bph
Copy link
Collaborator

bph commented Jun 7, 2024

Discussed in #24

Originally posted by juanmaguitar November 28, 2022
An article about how to create and run automated tests for our custom blocks in WordPress could be useful for both the product itself and the extenders using blocks.

In fact, I see this content as a series of two posts:

  • Unit Tests for Blocks: The first one covers a more granular way of testing blocks: Unit Tests with Jest to test a block from its main components (Edit and save)
  • E2E Tests (or Integration Tests) for Blocks: A second one covering a more generic way of testing blocks: End-to-end tests with playwright to test the expected block behavior in the WordPress context (the block is properly registered, the frontend behavior works as expected, ...)

The first post could be called "Unit Testing for Blocks" and could cover the following ideas:

  • Why having automated tests is a good way to ensure our block work as expected and to document it (among other benefits)
  • The difference between Unit Tests and E2E tests
  • What is Jest
  • Preparing the environment in our project to test our block with Jest
  • What to test in a Unit Test for a block - creating some tests for our block
  • Launching our test in local
  • Bonus: Creating a CI/CD pipeline with GitHub Actions to only allow merge if tests are passing

These posts could even include a brief explanation of what BDD is, what CI is, and how these tests allow the Gutenberg project to grow in a more solid way.

Inspired by this answer in the support forums

@flexseth
Copy link

flexseth commented Jun 7, 2024

+1 great content idea

@bph bph added the flow: needs writer the idea/pitch needs a writer label Sep 26, 2024
@bph bph moved this from To-do to Needs a writer in Developer Blog Content Board Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Needs a writer
Development

No branches or pull requests

3 participants