jest: How to teardown after (just) an individual test
问题 jest provides afterEach , beforeEach , afterAll and beforeAll to complete setup and teardown logic. What I would like to do, is to clear up after one particular test. Consider the following: describe("a family of tests it makes sense to group together", () => { ... test("something I want to test", () => { // some setup needed for just this test global.foo = "bar" // the test expect(myTest()).toBe(true) // clear up delete global.foo } ... } The problem with the above... If the test above fails