@gfdelarue/testkit 0.6.1 → 0.6.3

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/bin/testkit.mjs CHANGED
@@ -32,11 +32,13 @@ if (!hostNodeIsSupported(process.versions.node)) {
32
32
  const versionMismatch = versionDrift.checkCliVersionDrift(effectiveArgs, {
33
33
  binUrl: import.meta.url,
34
34
  });
35
- if (
36
- !versionDrift.emitCliVersionDriftAndExit(versionMismatch, {
37
- json: versionDrift.isJsonMode(effectiveArgs),
38
- })
39
- ) {
35
+ const json = versionDrift.isJsonMode(effectiveArgs);
36
+ let handedOff = false;
37
+ if (versionMismatch) {
38
+ const { handOffToProductCli } = await import("../dist/cli/product-handoff.js");
39
+ handedOff = await handOffToProductCli(versionMismatch, process.argv.slice(2), { json });
40
+ }
41
+ if (!handedOff && !versionDrift.emitCliVersionDriftAndExit(versionMismatch, { json })) {
40
42
  const { executeCli } = await import("../dist/cli/index.js");
41
43
  await executeCli(
42
44
  effectiveArgs,
@@ -0,0 +1 @@
1
+ import o from"node:fs";import e from"node:path";import{isUnknownRecord as l}from"../kernel/unknown-values.js";import{runProductCli as u}from"../process/product-cli.js";export async function runInstalledProductCli(r,n,{onStart:i}){const t=s(r);return t===null?!1:(i(),await u(t,n),!0)}function s(r){let n;try{n=JSON.parse(o.readFileSync(e.join(r,"package.json"),"utf8"))}catch{return null}if(!l(n))return null;const i=l(n.bin)?n.bin.testkit:n.bin;if(typeof i!="string")return null;const t=e.resolve(r,i);return o.statSync(t,{throwIfNoEntry:!1})?.isFile()?t:null}
@@ -0,0 +1,2 @@
1
+ import{runInstalledProductCli as i}from"../app/product-handoff.js";export async function handOffToProductCli(t,e,{json:n=!1}={}){const{packageRoot:r,version:o}=t.product;return r===null?!1:await i(r,e,{onStart:()=>{n||process.stderr.write(`Using the product's @gfdelarue/testkit ${String(o)} (${r}) instead of ${t.current.version}
2
+ `)}})}
@@ -1 +1 @@
1
- export*from"@playwright/test";export{readPlaywrightContext}from"./runtime-input.js";export{defineTestkitConfig}from"./config.js";export{emulateCpu,emulateNetwork}from"./emulation.js";export{browserRequests}from"./browser-traffic.js";export{assertSafeUiTarget,assertSafeUiTargets,createAuthedApiClient,createSandboxId,createUiSandbox,resolveBackendBaseUrl,resolveFrontendBaseUrl,waitForAnimationFrames,waitForElementStable,waitForImagesLoaded,waitForNetworkIdle,waitForUiSettled}from"./sandbox.js";
1
+ import{_android as e,_baseTest as r,_electron as t,chromium as o,defineConfig as a,devices as s,errors as i,expect as m,firefox as d,mergeExpects as n,mergeTests as f,request as l,selectors as x,test as p,webkit as c}from"@playwright/test";export{e as _android,r as _baseTest,t as _electron,o as chromium,a as defineConfig,s as devices,i as errors,m as expect,d as firefox,n as mergeExpects,f as mergeTests,l as request,x as selectors,p as test,c as webkit};export{readPlaywrightContext}from"./runtime-input.js";export{defineTestkitConfig}from"./config.js";export{emulateCpu,emulateNetwork}from"./emulation.js";export{browserRequests}from"./browser-traffic.js";export{assertSafeUiTarget,assertSafeUiTargets,createAuthedApiClient,createSandboxId,createUiSandbox,resolveBackendBaseUrl,resolveFrontendBaseUrl,waitForAnimationFrames,waitForElementStable,waitForImagesLoaded,waitForNetworkIdle,waitForUiSettled}from"./sandbox.js";
@@ -3,7 +3,7 @@
3
3
  "entrypoint": "dist/process/process.js",
4
4
  "sourceSha256": "e7301ca010796bb92d983c039db47f36e155c26ccfb42ff2d057d47addab3121",
5
5
  "bundleSha256": "db5da25a23e4577451c0c047360de70af8abbd63be686dd7b97d65486cbba3b8",
6
- "packageLockSha256": "0b4351d48801de63d0a5ceb85a7eac01fc24259d3cc3537f18ee0cd5db5101be",
6
+ "packageLockSha256": "baeb7a46d3a7c0a092ff04f5a5d82115ff9ed748bb9563fdda2e154aa9ab19e3",
7
7
  "esbuildVersion": "0.28.1",
8
8
  "options": {
9
9
  "format": "esm",
@@ -0,0 +1 @@
1
+ import{spawn as f}from"node:child_process";const i=process.platform==="win32"?["SIGINT","SIGBREAK"]:["SIGINT","SIGTERM","SIGHUP"];export async function runProductCli(c,n){const e=f(process.execPath,[...process.execArgv,c,...n],{stdio:"inherit"}),r=o=>{process.platform!=="win32"&&e.kill(o)};for(const o of i)process.on(o,r);let s;try{s=await new Promise((o,t)=>{e.once("error",t),e.once("exit",(l,p)=>{o({code:l,signal:p})})})}finally{for(const o of i)process.off(o,r)}s.signal?process.kill(process.pid,s.signal):process.exitCode=s.code??1}
@@ -1,4 +1,4 @@
1
- import { APIRequest, APIRequestContext, Page, PlaywrightTestConfig } from '@playwright/test';
1
+ import { APIRequest, APIRequestContext, Page, PlaywrightTestConfig, _android, _baseTest, _electron, chromium, defineConfig, devices, errors, expect, firefox, mergeExpects, mergeTests, request, selectors, test, webkit } from '@playwright/test';
2
2
 
3
3
  export type JsonPrimitive = boolean | null | number | string;
4
4
  export type JsonValue = JsonPrimitive | readonly JsonValue[] | JsonObject;
@@ -139,13 +139,28 @@ export declare function waitForElementStable(page: UiStableElementPage, selector
139
139
  timeout?: number;
140
140
  }): Promise<void>;
141
141
  export declare function waitForImagesLoaded(page: UiImagesPage, containerSelector?: string | null): Promise<void>;
142
- export * from "@playwright/test";
142
+ export type * from "@playwright/test";
143
143
 
144
144
  export {
145
145
  APIRequest,
146
146
  APIRequestContext,
147
147
  Page,
148
148
  PlaywrightTestConfig,
149
+ _android,
150
+ _baseTest,
151
+ _electron,
152
+ chromium,
153
+ defineConfig,
154
+ devices,
155
+ errors,
156
+ expect,
157
+ firefox,
158
+ mergeExpects,
159
+ mergeTests,
160
+ request,
161
+ selectors,
162
+ test,
163
+ webkit,
149
164
  };
150
165
 
151
166
  export {};
@@ -1,3 +1,40 @@
1
+ # 0.6.3
2
+
3
+ ## A global Testkit runs the product's own install
4
+
5
+ When you start the CLI in a product that installs a different version of
6
+ `@gfdelarue/testkit`, the CLI now runs the product's install with the same
7
+ arguments. That covers a global install, a Homebrew, Scoop, AUR, or Chocolatey
8
+ package, and `npx @gfdelarue/testkit@latest`. Before, the CLI stopped with
9
+ `testkit_cli_version_mismatch` and printed the command to run the product's
10
+ install instead.
11
+
12
+ The CLI names the install it runs in one line on stderr, except in `--json`
13
+ mode. The exit code comes from the product's install. On Linux and macOS, a
14
+ stop signal sent to the CLI reaches the product's install, and the CLI ends
15
+ with the signal that ended it. A product that declares a version of
16
+ `@gfdelarue/testkit` but doesn't install one still gets
17
+ `testkit_cli_version_mismatch`.
18
+
19
+ # 0.6.2
20
+
21
+ ## Static imports from `@gfdelarue/testkit/playwright` work in a CommonJS product
22
+
23
+ In a product whose `package.json` doesn't set `"type": "module"`, a `ui` test
24
+ that imported a Testkit helper from `@gfdelarue/testkit/playwright` got
25
+ `undefined`, and threw a `TypeError` when it called it
26
+ ([gfdelarue/testkit#505](https://github.com/gfdelarue/testkit/issues/505)).
27
+ Every helper was affected, from `browserRequests` and `emulateNetwork` to
28
+ `waitForUiSettled`. `test`, `expect`, and Playwright's other exports still
29
+ worked. Static imports now get every helper, as they do in an ES module product.
30
+
31
+ Playwright compiles such a test to CommonJS, so each static import becomes a
32
+ `require()`. The entry re-exported Playwright with `export *`, which also passed
33
+ on the `"module.exports"` export of Testkit's managed `@playwright/test`. Node's
34
+ `require()` returns that export in place of the module, so it returned the
35
+ managed `test`. The entry now names each of Playwright's runtime exports.
36
+ `require("@playwright/test")` in a test still returns the managed `test`.
37
+
1
38
  # 0.6.1
2
39
 
3
40
  ## Each `ui` test's browser traffic is in the run evidence
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gfdelarue/testkit",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "Test orchestration platform for product acceptance and QA workflows",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -96,9 +96,9 @@
96
96
  ],
97
97
  "devDependencies": {
98
98
  "@eslint/js": "^10.0.1",
99
- "@gfdelarue/code-budget": "0.1.2",
100
99
  "@homebridge/node-pty-prebuilt-multiarch": "^0.13.1",
101
100
  "@kitschpatrol/tokei": "2.0.2",
101
+ "@moontern-labs/code-budget": "0.1.3",
102
102
  "@types/picomatch": "4.0.3",
103
103
  "@types/yauzl": "3.4.0",
104
104
  "dts-bundle-generator": "9.5.1",