Skip to content

Commit 79019d5

Browse files
fix: add safety check around process before cleaning up (#218)
This fixes the problems with Karma.
1 parent 5bf154f commit 79019d5

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

projects/testing-library/src/lib/testing-library.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,16 @@ function cleanupAtFixture(fixture) {
352352
mountedFixtures.delete(fixture);
353353
}
354354

355-
if (typeof afterEach === 'function' && !process.env.ATL_SKIP_AUTO_CLEANUP) {
356-
afterEach(async () => {
357-
cleanup();
358-
});
355+
// if we're running in a test runner that supports afterEach
356+
// then we'll automatically run cleanup afterEach test
357+
// this ensures that tests run in isolation from each other
358+
// if you don't like this, set the ATL_SKIP_AUTO_CLEANUP env variable to 'true'
359+
if (typeof process === 'undefined' || !process.env?.ATL_SKIP_AUTO_CLEANUP) {
360+
if (typeof afterEach === 'function') {
361+
afterEach(() => {
362+
cleanup();
363+
});
364+
}
359365
}
360366

361367
// TODO: rename to `atl-wrapper-component`

0 commit comments

Comments
 (0)