Company
Date Published
Author
Javier Pérez Anaya
Word count
871
Language
English
Hacker News points
None

Summary

This article discusses managing artifacts created during end-to-end testing, specifically in the context of Checkly's monitoring platform. The authors aim to keep not only the testing flow but also the maintenance flow contained within Checkly as much as possible. They introduce a method for declaring an API module factory that returns a wrapped API module with two extra methods: `addToCleanupQueue` and `cleanup`. The `addToCleanupQueue` method adds IDs to an internal pile of pending-to-remove artifact IDs, while the `cleanup` method invokes sequentially the cleanup method declared in the module call. The authors also declare an API fixture for showcasing purposes, which is configurable to pass any HTTP client. The fixture includes a global method for iterating over declared modules and invoking cleanup on every one of them. Finally, the article shows how to use this API fixture in checks by adding created entity IDs to the cleanup pile. The goal is to reduce bloat required for garbage collection at the end of each check to a single line of code.