@ctrl/dom-jest-environment 0.3.10 → 0.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +27 -0
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -28,6 +28,33 @@ Per file: `/** @jest-environment @ctrl/dom-jest-environment */`. Options
28
28
  [@ctrl/dom's README](https://www.npmjs.com/package/@ctrl/dom). Requires Jest 30+ and Node 26+.
29
29
  Test code that imports `@ctrl/dom` (or its subpaths) gets the environment's own instance.
30
30
 
31
+ ## Differences from jest-environment-jsdom
32
+
33
+ The full list is in [deviations.md](https://github.com/scttcper/dom/blob/main/docs/deviations.md).
34
+
35
+ - `testEnvironmentOptions` takes `createWindow` options (`url`, `width`, `platform`, ...) plus
36
+ `nodeFetch: true` to keep Node's `fetch`/`Request`/`Response` (absent by default, as under
37
+ jsdom). `compat` defaults to `"jsdom-26"`, the surface of jsdom 26 that jest-environment-jsdom
38
+ 30 ships (no `PointerEvent`); `"jsdom-30"` matches environments built on newer jsdom and
39
+ `"modern"` adds what no jsdom has (`matchMedia`, `ResizeObserver`, `inert`).
40
+ - `environment.dom` is a minimal stand-in for jsdom's `JSDOM` object: `window` and
41
+ `reconfigure({ url })`.
42
+ - Timers the test file leaves pending are cleared at teardown, as jsdom's `window.close()` does.
43
+ - The test global is a plain, non-contextified vm global (as jsdom 30 creates its window), so
44
+ global lookups in test and app code are ordinary property loads. Node's globals
45
+ (`TextEncoder`, `structuredClone`, `setImmediate`, streams, ...) are installed lazily, as
46
+ jest-environment-node does. There is no `testEnvironmentOptions.globalsCleanup`: nothing
47
+ scrubs objects a test file left on the global (jsdom's environment doesn't either).
48
+
49
+ ## Idle time skipping
50
+
51
+ Timers run on a virtual clock. Whenever the test is only waiting for a timer (no pending
52
+ immediates, no I/O), the clock jumps to it and `Date`/`performance.now()` advance with it, so
53
+ `findBy*`/`waitFor`, debounces, user-event delays and timeouts finish without spending wall
54
+ time, in the same order and with the same app-visible elapsed time. A `findBy` that never
55
+ matches fails after 1 s of virtual time instead of 1 s of real time. Set `testEnvironmentOptions.timeSkip` to `false` (or
56
+ `CTRL_DOM_TIME_SKIP=0`) for real-time timers.
57
+
31
58
  ## License
32
59
 
33
60
  MIT. Third-party notices are in the package's `NOTICE` file.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl/dom-jest-environment",
3
- "version": "0.3.10",
3
+ "version": "0.3.12",
4
4
  "description": "Jest environment for @ctrl/dom, the fast DOM for testing React components (testEnvironment: \"@ctrl/dom-jest-environment\", or preset: \"@ctrl/dom\").",
5
5
  "keywords": [
6
6
  "jest",
@@ -12,14 +12,14 @@
12
12
  "react"
13
13
  ],
14
14
  "license": "MIT",
15
- "homepage": "https://github.com/scttcper/dom#readme",
15
+ "homepage": "https://github.com/scttcper/dom/tree/main/packages/jest-environment#readme",
16
16
  "bugs": {
17
17
  "url": "https://github.com/scttcper/dom/issues"
18
18
  },
19
19
  "repository": {
20
20
  "type": "git",
21
21
  "url": "git+https://github.com/scttcper/dom.git",
22
- "directory": "publish/dom-jest-environment"
22
+ "directory": "packages/jest-environment"
23
23
  },
24
24
  "author": "Scott Cooper <scttcper@gmail.com>",
25
25
  "type": "module",
@@ -52,7 +52,7 @@
52
52
  "jest-util": "^30.0.0"
53
53
  },
54
54
  "peerDependencies": {
55
- "@ctrl/dom": "^0.3.10",
55
+ "@ctrl/dom": "^0.3.13",
56
56
  "jest": ">=30.0.0"
57
57
  }
58
58
  }