Skip to content

Commit

Permalink
utils: Workaround to prevent checkStyles from running in tests w/ CJS…
Browse files Browse the repository at this point in the history
… build (#466)
  • Loading branch information
chaance committed Feb 13, 2020
1 parent 9fe11d9 commit 2fab1f0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/utils/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,20 @@ let checkedPkgs: { [key: string]: boolean } = {};
// @ts-ignore
let checkStyles = (packageName: string): void => void packageName;

// In CJS files, process.env.NODE_ENV is stripped from our build, but we need it
// to prevent style checks from clogging up user logs while testing.
// This is a workaround until we can tweak the build a bit to accommodate.
let { env } = process;
let nodeEnv = env.NODE_ENV;

if (__DEV__) {
checkStyles = (packageName: string) => {
// only check once per package
if (checkedPkgs[packageName]) return;
checkedPkgs[packageName] = true;

if (
process.env.NODE_ENV !== "test" &&
nodeEnv !== "test" &&
parseInt(
window
.getComputedStyle(document.body)
Expand Down

0 comments on commit 2fab1f0

Please sign in to comment.