Company
Date Published
Author
Gleb Bahmutov
Word count
2018
Language
English
Hacker News points
None

Summary

This blog post by Gleb Bahmutov explores how to write end-to-end tests for web applications hosted on Codepen.io, using a small counter application built with HyperApp as an example. Initially, the post highlights the challenges faced due to Codepen's security measures, including a CAPTCHA and iframe restrictions that complicate testing with tools like Cypress. Bahmutov demonstrates a workaround using Cypress's built-in proxy to request the HTML of the application, which is then injected directly into the test document through the document.write method, effectively bypassing iframe restrictions. The post covers several test cases, such as verifying the default counter state, ensuring buttons are correctly enabled or disabled, and utilizing the HyperApp's actions object to manipulate the application state directly. Despite the initial challenges, this method allows comprehensive testing while maintaining the ability to observe and interact with the application in real-time through Cypress's Test Runner.