From 2455831f5f62dcd88025ab8e814ca77333920e01 Mon Sep 17 00:00:00 2001 From: Michael Rawlings Date: Fri, 21 Feb 2020 16:42:12 -0800 Subject: [PATCH] fix: call @marko/testing-library's cleanup between test runs (#3) --- src/jest.ts | 3 +++ src/mocha.ts | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/jest.ts b/src/jest.ts index 7aa3f41..6deceab 100644 --- a/src/jest.ts +++ b/src/jest.ts @@ -1,3 +1,4 @@ +import { cleanup } from "@marko/testing-library"; import { findProjectFixtures, defaultNormalizer } from "./"; import { toMatchFile } from "jest-file-snapshot"; @@ -9,6 +10,8 @@ export default function snapshotComponentFixtures( ) { findProjectFixtures(path, otherOptions).forEach(component => { describe(component.name, () => { + beforeAll(cleanup); + afterEach(cleanup); Object.keys(component.fixtures).forEach(name => { it(name, async () => { const fixture = component.fixtures[name]; diff --git a/src/mocha.ts b/src/mocha.ts index bc5e4e5..06ec14e 100644 --- a/src/mocha.ts +++ b/src/mocha.ts @@ -1,14 +1,19 @@ import fs from "fs"; import path from "path"; import assert from "assert"; +import { cleanup } from "@marko/testing-library"; import { findProjectFixtures, defaultNormalizer } from "./"; +declare const before: (fn: () => any) => any; + export default function snapshotComponentFixtures( dir: string, { normalize = defaultNormalizer, ...otherOptions } = {} ) { findProjectFixtures(dir, otherOptions).forEach(component => { describe(component.name, () => { + before(cleanup); + afterEach(cleanup); Object.keys(component.fixtures).forEach(name => { it(name, async () => { const fixture = component.fixtures[name];