Skip to content

Commit a12011e

Browse files
committed
fix(workflow-renderer): declare the act-environment global
`vitest.setup.ts` is inside the package's tsconfig, so assigning an undeclared property on `globalThis` failed type-check (TS7017) even though the tests ran.
1 parent 70576a2 commit a12011e

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
declare global {
2+
/**
3+
* React reads this to decide whether `act` is supported. It is not one of the
4+
* ambient globals, so it has to be declared before it can be assigned.
5+
*/
6+
var IS_REACT_ACT_ENVIRONMENT: boolean
7+
}
8+
19
/**
210
* jest-dom only registers DOM matchers (`toHaveStyle`, `toHaveClass`, …), so it is
311
* dead weight outside a DOM environment. This package's mount tests opt into jsdom
@@ -6,11 +14,10 @@
614
if (typeof document !== 'undefined') {
715
await import('@testing-library/jest-dom/vitest')
816
/*
9-
* React only treats `act` as supported when it can see this flag, and without
10-
* it every render in the mount tests logs "The current testing environment is
11-
* not configured to support act(...)". The warning is noise here — the tests
12-
* already wrap their renders — but it buries real output, and React does not
13-
* flush effects the way the tests assume until the flag is set.
17+
* Without this React treats `act` as unsupported, and every render in the
18+
* mount tests logs "The current testing environment is not configured to
19+
* support act(...)" — around forty lines a run, which buries the output that
20+
* matters when one of them fails.
1421
*/
1522
globalThis.IS_REACT_ACT_ENVIRONMENT = true
1623
}

0 commit comments

Comments
 (0)