Skip to content

Commit

Permalink
fix: call @marko/testing-library's cleanup between test runs (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlrawlings authored Feb 22, 2020
1 parent da76bfd commit 2455831
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/jest.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { cleanup } from "@marko/testing-library";
import { findProjectFixtures, defaultNormalizer } from "./";
import { toMatchFile } from "jest-file-snapshot";

Expand All @@ -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];
Expand Down
5 changes: 5 additions & 0 deletions src/mocha.ts
Original file line number Diff line number Diff line change
@@ -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];
Expand Down

0 comments on commit 2455831

Please sign in to comment.