Skip to content

Commit b589fbd

Browse files
authored
fix: Guard against process not being defined (#68)
Webpack 5 doesn't shim Node's `process` object by default anymore. Only instances of `process.env.NODE_ENV` are replaced statically. This means that unguarded checks of `process.env` will crash in browser environments (such as Karma). This is a port of testing-library/react-testing-library#911
1 parent 651cbc4 commit b589fbd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { cleanup } from './pure'
55
// this ensures that tests run in isolation from each other.
66
// If you don't like this then either import the `pure` module
77
// or set the PTL_SKIP_AUTO_CLEANUP env variable to 'true'.
8-
if (!process.env.PTL_SKIP_AUTO_CLEANUP) {
8+
if (typeof process === "undefined" || !process.env.PTL_SKIP_AUTO_CLEANUP) {
99
if (typeof afterEach === 'function') {
1010
afterEach(async () => {
1111
await cleanup()

0 commit comments

Comments
 (0)