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

Stream request: TDD driven stream #12

Open
KevinBatdorf opened this issue Feb 3, 2022 · 1 comment
Open

Stream request: TDD driven stream #12

KevinBatdorf opened this issue Feb 3, 2022 · 1 comment
Labels
Topic Request A topic you'd like to see covered

Comments

@KevinBatdorf
Copy link

It would be nice to learn some tricks on testing during block development.

If possible, something that interacts with or mocks the database.

Thanks!

@ryanwelcher ryanwelcher added the Topic Request A topic you'd like to see covered label Feb 16, 2022
@KevinBatdorf
Copy link
Author

I had some time last night and worked something out using Cypress on a block starter I'm maintaining.

Basically it will set up wp-env to run in a GitHub action, then run integration tests on your block as you define them. I've ported a handful of the wp-e2e puppeteer tests as well, so you can do something like cy.loginUser() and expect it to log the user in.

I also set it up to run on both the latest WP install, plugin the master branch dev version. That way you can be sure the block won't break. Optionally the workflow can be set to run daily too without interaction.

Some files that may help anyone:

GH Action workflow: https://github.com/KevinBatdorf/gutenberg-rust-starter/blob/main/.github/workflows/cypress.yml
WP e2e ported commands: https://github.com/KevinBatdorf/gutenberg-rust-starter/tree/main/cypress/support
What a Cypress test looks like; https://github.com/KevinBatdorf/gutenberg-rust-starter/blob/main/cypress/integration/sanity-checks.spec.js

Might be a cool stream? Was fun to set up and write the tests. I remember reading that Gutenberg might use playwright though, so maybe better to use that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Topic Request A topic you'd like to see covered
Projects
None yet
Development

No branches or pull requests

2 participants