Merge !82: BodyMap tests: import the geometry before the first render
This commit is contained in:
commit
e94bd1250e
1 file changed
+9
-1
@@ -1,7 +1,7 @@
|
||||
// @vitest-environment happy-dom
|
||||
import React, { act } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import BodyMap, { BodyMapLegend } from './BodyMap.jsx'
|
||||
|
||||
globalThis.IS_REACT_ACT_ENVIRONMENT = true
|
||||
@@ -9,6 +9,14 @@ globalThis.IS_REACT_ACT_ENVIRONMENT = true
|
||||
let container
|
||||
let root
|
||||
|
||||
// BodyMap fetches its ~90 KB of geometry with a dynamic import on first render, and the
|
||||
// waitFor below allows one second for it. That is ample once the module is in the ESM
|
||||
// registry and not always ample when it is not: on a loaded CI runner the first map render
|
||||
// in this file paid the cold import and timed out, while every later test passed on the
|
||||
// component's warm CACHE. Import it here so the wait covers rendering, not module loading,
|
||||
// and the file stops depending on how fast the machine is.
|
||||
beforeAll(() => import('../lib/body-paths.js'))
|
||||
|
||||
beforeEach(() => {
|
||||
container = document.createElement('div')
|
||||
document.body.appendChild(container)
|
||||
|
||||
Reference in new issue
Block a user