dsh-plugin-toolkit 0.2.0 → 0.2.2

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.2
4
+
5
+ - `unmount()` closes the jsdom window, so a panel that polls does not keep the test process alive.
6
+ - The first paint waits for the panel's own fetches inside `act`, which removes the flood of "not wrapped in act" warnings that buried real failures.
7
+
8
+ ## 0.2.1
9
+
10
+ - A missing peer dependency now names the install command instead of failing with `ERR_MODULE_NOT_FOUND`.
11
+
3
12
  ## 0.2.0
4
13
 
5
14
  - `dsh-plugin-toolkit/testkit`: mount a single-file client bundle in jsdom with the real React and a recording host context — `click`, `type`, `press`, `must`, `attributes`, and normalised DOM baselines.
@@ -37,12 +37,19 @@ export async function mountClient(options) {
37
37
  container = 'root',
38
38
  } = options;
39
39
 
40
- const { window, document } = createDom();
40
+ const { dom, window, document } = createDom();
41
41
  const restoreGlobals = installGlobals(window, document);
42
42
 
43
- const React = await import('react');
44
- const reactDom = await import('react-dom/client');
45
- const jsxRuntime = await import('react/jsx-runtime');
43
+ const need = async (name) => {
44
+ try {
45
+ return await import(name);
46
+ } catch {
47
+ throw new Error(`testkit needs ${name}: npm install --save-dev jsdom react react-dom`);
48
+ }
49
+ };
50
+ const React = await need('react');
51
+ const reactDom = await need('react-dom/client');
52
+ const jsxRuntime = await need('react/jsx-runtime');
46
53
  const jsxDevRuntime = await import('react/jsx-dev-runtime').catch(() => jsxRuntime);
47
54
 
48
55
  const modules = {
@@ -84,6 +91,9 @@ export async function mountClient(options) {
84
91
 
85
92
  await act(async () => {
86
93
  clientRoot.render(React.createElement(registered.component, props));
94
+ // The first paint is followed by the panel's own fetches; letting them land
95
+ // inside act keeps the "not wrapped in act" warnings from drowning the run.
96
+ for (let tick = 0; tick < 3; tick += 1) await new Promise((resolve) => setTimeout(resolve, 0));
87
97
  });
88
98
 
89
99
  const settle = async (run) => {
@@ -177,6 +187,9 @@ export async function mountClient(options) {
177
187
  await act(async () => clientRoot.unmount());
178
188
  globalThis.fetch = previousFetch;
179
189
  restoreGlobals();
190
+ // A panel polls; jsdom's timers and rAF would keep the test process alive
191
+ // for as long as the app runs. Closing the window cancels them.
192
+ dom.window.close();
180
193
  },
181
194
  };
182
195
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-toolkit",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Preflight, release and test DeepSeek Harness plugins: checks what the host needs, waits for npm to actually serve the version, and keeps the market index honest.",
5
5
  "type": "module",
6
6
  "bin": {