On today’s live stream, we worked through adding some e2e tests to a block we created in a previous stream. This was a lot of fun and I learned a lot about using the various packages available to developers when working with custom blocks.

Read More: Live Stream Recap: Adding e2e tests to custom a Gutenberg block

Highlights:

  • Discussed how the @wordpress/scripts package contains the e2e testing tools
  • Discussed how we also need @wordpress/env to run them.
  • Created a basic e2e test suite to test if the block was inserted and that the content was correct
  • Discussed using snapshots and the difference between toMatchSnapshot and toMatchInlineSnapshot
  • Discussed how to pre-populate the test database with content using npm pre commands and the wp-env run command
  • Created a test to ensure that the block saved test input by the test as the message attribute.

If you missed me live, you can view the recorded stream below and you can get the code for all of my live streams at https://github.com/ryanwelcher/twitch.

Watch: https://www.youtube.com/watch?v=pI1hGE3IFqc&t=42s

I typically stream Thursdays at 10:30 EST/EDT to both my Twitch and YouTube channels. If you like anything you see, please follow/subscribe to any or all of my accounts and if there is a topic you’d like to see streamed, please add it to https://github.com/ryanwelcher/twitch/issues or leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *