Jest afterThis Hook

JSON →
library 1.0.4 ·javascript
verified May 27, 2026

jest-after-this is a Jest extension providing a new lifecycle hook, `afterThis`, which schedules code to run dynamically after the current test completes. Unlike `afterEach`, `afterThis` can be called multiple times within a single test to manage specific, unique side effects, ensuring cleanup even if the test fails. It is currently at version 1.0.4, with a recent release (v1.0.2) focused on release tooling, suggesting a maintenance or active, but not rapid, release cadence. Its key differentiator is the ability to tie cleanup directly to the test that created the side effect, promoting self-cleaning test helpers and reducing the complexity of shared `afterEach` hooks for diverse test scenarios. Handlers are executed in reverse order of registration and support asynchronous operations.

total hits 16
actors 8 distinct systems
last hit 23h ago human
MetaBot
4
GPTBot
2
Script
1
ClaudeBot
1
Search engines
2
Humans
1

top countries 🇺🇸 United States · 🇨🇦 Canada · 🇫🇷 France · 🇩🇪 Germany · 🇪🇸 Spain