qunitx-cli 0.24.0 → 0.25.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.
Files changed (2) hide show
  1. package/dist/cli.js +26 -6
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -374,7 +374,7 @@ var init_package = __esm({
374
374
  package_default = {
375
375
  name: "qunitx-cli",
376
376
  type: "module",
377
- version: "0.24.0",
377
+ version: "0.25.0",
378
378
  description: "Browser runner for QUnitx: run your qunitx tests in google-chrome",
379
379
  author: "Izel Nakri",
380
380
  license: "MIT",
@@ -2947,9 +2947,16 @@ async function launchBrowser(config, skipPrelaunch = false) {
2947
2947
  }
2948
2948
  async function setupBrowser(config, cachedContent, existingBrowser = null, sharedServer = null) {
2949
2949
  const setupStart = Date.now();
2950
+ const slot = config._daemonPageSlot;
2951
+ const slotPage = slot?.page && !slot.page.isClosed() ? slot.page : null;
2952
+ if (slotPage) {
2953
+ slotPage.removeAllListeners("console");
2954
+ slotPage.removeAllListeners("pageerror");
2955
+ slot.page = null;
2956
+ }
2950
2957
  const [server, browser, page] = await (async () => {
2951
2958
  if (sharedServer) {
2952
- const newPage2 = await existingBrowser.newPage();
2959
+ const newPage2 = slotPage ?? await existingBrowser.newPage();
2953
2960
  perfLog(`browser.js: newPage (shared server) took ${Date.now() - setupStart}ms`);
2954
2961
  return [sharedServer, existingBrowser, newPage2];
2955
2962
  }
@@ -2958,12 +2965,12 @@ async function setupBrowser(config, cachedContent, existingBrowser = null, share
2958
2965
  const activeBrowser = existingBrowser ?? await launchBrowser(config);
2959
2966
  const pageStart = Date.now();
2960
2967
  const isHeadedWatchMode = config.open === true && config.watch;
2961
- const getPage = isHeadedWatchMode ? () => activeBrowser.contexts()[0]?.pages()[0] ?? activeBrowser.newPage() : () => activeBrowser.newPage();
2968
+ const getPage = slotPage ? () => Promise.resolve(slotPage) : isHeadedWatchMode ? () => activeBrowser.contexts()[0]?.pages()[0] ?? activeBrowser.newPage() : () => activeBrowser.newPage();
2962
2969
  const [newPage] = await Promise.all([getPage(), bindServerToPort(newServer, config)]);
2963
2970
  perfLog(`browser.js: newPage + bindServerToPort took ${Date.now() - pageStart}ms`);
2964
2971
  return [newServer, activeBrowser, newPage];
2965
2972
  })();
2966
- if (config.browser === "firefox") {
2973
+ if (config.browser === "firefox" && !slotPage) {
2967
2974
  await page.addInitScript(() => {
2968
2975
  const preSerialize = (arg) => {
2969
2976
  if (arg === null || typeof arg !== "object") return arg;
@@ -4305,6 +4312,12 @@ async function run(config) {
4305
4312
  fsTree: Object.fromEntries(groupFiles.map((filePath) => [filePath, config.fsTree[filePath]])),
4306
4313
  // Single group keeps the root output dir for backward-compatible file paths.
4307
4314
  output: groupCount === 1 ? config.output : `${config.output}/group-${i}`,
4315
+ // Page reuse is single-group only: in concurrent group mode group 0 would
4316
+ // otherwise drain `slot.page` (setupBrowser consumes it) without re-stashing
4317
+ // (cleanup's `groupCount === 1` guard rejects), leaving the slot empty for
4318
+ // the next single-file run. Withhold the slot here so the warm page survives
4319
+ // a transient multi-file invocation untouched.
4320
+ _daemonPageSlot: groupCount === 1 ? config._daemonPageSlot : void 0,
4308
4321
  _groupMode: true,
4309
4322
  _phase: "bundling"
4310
4323
  }));
@@ -4377,9 +4390,11 @@ async function run(config) {
4377
4390
  await runTestsInBrowser(groupConfig, groupCachedContents[i], connections);
4378
4391
  } finally {
4379
4392
  await flushConsoleHandlers(groupConfig._pendingConsoleHandlers, connections.page);
4393
+ const reusePage = groupCount === 1 && groupConfig._daemonPageSlot && connections.page && !connections.page.isClosed();
4394
+ if (reusePage) groupConfig._daemonPageSlot.page = connections.page;
4380
4395
  await closeWithGrace([
4381
4396
  sharedServer ? void 0 : connections.server?.close(),
4382
- connections.page?.close()
4397
+ reusePage ? void 0 : connections.page?.close()
4383
4398
  ]);
4384
4399
  }
4385
4400
  })();
@@ -4655,7 +4670,8 @@ async function runDaemonServer() {
4655
4670
  infoPath,
4656
4671
  consecutiveCrashes: 0,
4657
4672
  listenSucceeded: false,
4658
- esbuildCache: { _esbuildContext: null }
4673
+ esbuildCache: { _esbuildContext: null },
4674
+ pageSlot: { page: null }
4659
4675
  };
4660
4676
  const shutdown = (reason) => shutdownDaemon2(state, reason);
4661
4677
  process.on("SIGTERM", () => void shutdown("SIGTERM"));
@@ -4715,6 +4731,8 @@ async function shutdownDaemon2(state, reason) {
4715
4731
  }) : null,
4716
4732
  state.listenSucceeded ? unlink(state.infoPath).catch(() => {
4717
4733
  }) : null,
4734
+ state.pageSlot.page?.close().catch(() => {
4735
+ }),
4718
4736
  state.browser.close().catch(() => {
4719
4737
  }),
4720
4738
  state.esbuildCache._esbuildContext?.dispose().catch(() => {
@@ -4844,6 +4862,7 @@ async function recoverBrowser(state) {
4844
4862
  );
4845
4863
  state.browser.close().catch(() => {
4846
4864
  });
4865
+ state.pageSlot.page = null;
4847
4866
  try {
4848
4867
  state.browser = await launchBrowser(state.baseConfig, true);
4849
4868
  } catch (err) {
@@ -4866,6 +4885,7 @@ async function runOnce(argv, env, state) {
4866
4885
  config._daemonMode = true;
4867
4886
  config._daemonBrowser = state.browser;
4868
4887
  config._daemonEsbuildCache = state.esbuildCache;
4888
+ config._daemonPageSlot = state.pageSlot;
4869
4889
  config.watch = false;
4870
4890
  config.open = false;
4871
4891
  try {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "qunitx-cli",
3
3
  "type": "module",
4
- "version": "0.24.0",
4
+ "version": "0.25.0",
5
5
  "description": "Browser runner for QUnitx: run your qunitx tests in google-chrome",
6
6
  "author": "Izel Nakri",
7
7
  "license": "MIT",