@gtkx/vitest 0.11.0 → 0.12.0

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/dist/plugin.d.ts CHANGED
@@ -1,3 +1,22 @@
1
1
  import type { Plugin } from "vitest/config";
2
+ /**
3
+ * Creates the GTKX Vitest plugin for running GTK tests.
4
+ *
5
+ * Manages Xvfb virtual display instances for headless GTK testing.
6
+ * Each worker thread gets its own display to avoid interference.
7
+ *
8
+ * @returns Vitest plugin configuration
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * // vitest.config.ts
13
+ * import { defineConfig } from "vitest/config";
14
+ * import gtkx from "@gtkx/vitest";
15
+ *
16
+ * export default defineConfig({
17
+ * plugins: [gtkx()],
18
+ * });
19
+ * ```
20
+ */
2
21
  declare const gtkx: () => Plugin;
3
22
  export default gtkx;
package/dist/plugin.js CHANGED
@@ -2,7 +2,8 @@ import { spawn } from "node:child_process";
2
2
  import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
3
3
  import { availableParallelism, tmpdir } from "node:os";
4
4
  import { join } from "node:path";
5
- const getStateDir = () => join(tmpdir(), `gtkx-vitest-${process.pid}`);
5
+ const getRuntimeDir = () => process.env.XDG_RUNTIME_DIR ?? tmpdir();
6
+ const getStateDir = () => join(getRuntimeDir(), `gtkx-vitest-${process.pid}`);
6
7
  const getBaseDisplay = () => {
7
8
  const slot = process.pid % 500;
8
9
  return 50 + slot * 10;
@@ -36,6 +37,25 @@ const startXvfb = async (display) => {
36
37
  }
37
38
  return xvfb;
38
39
  };
40
+ /**
41
+ * Creates the GTKX Vitest plugin for running GTK tests.
42
+ *
43
+ * Manages Xvfb virtual display instances for headless GTK testing.
44
+ * Each worker thread gets its own display to avoid interference.
45
+ *
46
+ * @returns Vitest plugin configuration
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * // vitest.config.ts
51
+ * import { defineConfig } from "vitest/config";
52
+ * import gtkx from "@gtkx/vitest";
53
+ *
54
+ * export default defineConfig({
55
+ * plugins: [gtkx()],
56
+ * });
57
+ * ```
58
+ */
39
59
  const gtkx = () => {
40
60
  const workerSetupPath = join(import.meta.dirname, "setup.js");
41
61
  const stateDir = getStateDir();
package/package.json CHANGED
@@ -1,13 +1,17 @@
1
1
  {
2
2
  "name": "@gtkx/vitest",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Vitest plugin for GTKX applications with Xvfb display isolation",
5
5
  "keywords": [
6
+ "gtkx",
6
7
  "gtk",
7
8
  "gtk4",
8
9
  "vitest",
9
10
  "testing",
10
- "xvfb"
11
+ "plugin",
12
+ "xvfb",
13
+ "linux",
14
+ "desktop"
11
15
  ],
12
16
  "homepage": "https://eugeniodepalo.github.io/gtkx",
13
17
  "bugs": {