cypress 16.2.0 → 16.3.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 (53) hide show
  1. package/angular/dist/index.js +10 -12
  2. package/angular/package.json +7 -22
  3. package/dist/bin/cypress +8 -8
  4. package/dist/{cli-AgTnS5LO.js → cli-y9Bb9Y77.js} +215 -40
  5. package/dist/cli.js +6 -6
  6. package/dist/{cypress-CdDm9AVa.js → cypress-CvEs5adm.js} +2 -2
  7. package/dist/cypress.js +8 -8
  8. package/dist/exec/spawn.js +4 -4
  9. package/dist/exec/xvfb.js +7 -4
  10. package/dist/index.js +8 -8
  11. package/dist/{spawn-DElwyZHC.js → spawn-Bx99tBTm.js} +529 -69
  12. package/dist/{tap-WHD3nHJC.js → tap-BMFGLoCT.js} +108 -26
  13. package/dist/{xvfb-CbW2_YXR.js → xvfb-DxbcANVl.js} +238 -25
  14. package/mount-utils/dist/index.js +1 -1
  15. package/mount-utils/package.json +15 -14
  16. package/package.json +5 -5
  17. package/react/dist/cypress-react.cjs.js +9 -7
  18. package/react/dist/cypress-react.esm-bundler.js +9 -7
  19. package/react/package.json +26 -46
  20. package/svelte/dist/cypress-svelte.cjs.js +3 -2
  21. package/svelte/dist/cypress-svelte.esm-bundler.js +3 -2
  22. package/svelte/package.json +24 -22
  23. package/types/cy-bluebird.d.ts +1 -0
  24. package/types/cy-chai.d.ts +99 -2
  25. package/types/cypress.d.ts +216 -43
  26. package/types/net-stubbing.d.ts +1 -1
  27. package/vue/dist/cypress-vue.cjs.js +4 -2
  28. package/vue/dist/cypress-vue.esm-bundler.js +4 -2
  29. package/vue/dist/index.d.ts +3 -3
  30. package/vue/package.json +35 -42
  31. package/angular/angular/README.md +0 -18
  32. package/angular/angular/dist/index.d.ts +0 -120
  33. package/angular/angular/dist/index.js +0 -479
  34. package/angular/angular/package.json +0 -82
  35. package/mount-utils/mount-utils/README.md +0 -140
  36. package/mount-utils/mount-utils/dist/index.d.ts +0 -12
  37. package/mount-utils/mount-utils/dist/index.js +0 -41
  38. package/mount-utils/mount-utils/package.json +0 -52
  39. package/react/react/README.md +0 -19
  40. package/react/react/dist/cypress-react.cjs.js +0 -293
  41. package/react/react/dist/cypress-react.esm-bundler.js +0 -268
  42. package/react/react/dist/index.d.ts +0 -95
  43. package/react/react/package.json +0 -113
  44. package/svelte/svelte/README.md +0 -19
  45. package/svelte/svelte/dist/cypress-svelte.cjs.js +0 -122
  46. package/svelte/svelte/dist/cypress-svelte.esm-bundler.js +0 -120
  47. package/svelte/svelte/dist/index.d.ts +0 -31
  48. package/svelte/svelte/package.json +0 -63
  49. package/vue/vue/README.md +0 -14
  50. package/vue/vue/dist/cypress-vue.cjs.js +0 -8692
  51. package/vue/vue/dist/cypress-vue.esm-bundler.js +0 -8671
  52. package/vue/vue/dist/index.d.ts +0 -1413
  53. package/vue/vue/package.json +0 -97
@@ -1,18 +1,20 @@
1
1
  'use strict';
2
2
 
3
- var xvfb = require('./xvfb-CbW2_YXR.js');
3
+ var xvfb = require('./xvfb-DxbcANVl.js');
4
4
  var Debug = require('debug');
5
5
  var commander = require('commander');
6
6
  var path = require('path');
7
- var cli = require('./cli-AgTnS5LO.js');
7
+ var cli = require('./cli-y9Bb9Y77.js');
8
8
  var CRI = require('chrome-remote-interface');
9
9
  var chalk = require('chalk');
10
10
  var crypto = require('crypto');
11
+ require('lodash');
11
12
  require('os');
13
+ require('child_process');
14
+ require('fs-extra');
12
15
  require('bluebird');
13
16
  require('@cypress/xvfb');
14
17
  require('common-tags');
15
- require('lodash');
16
18
  require('assert');
17
19
  require('arch');
18
20
  require('ospath');
@@ -27,18 +29,16 @@ require('executable');
27
29
  require('process');
28
30
  require('supports-color');
29
31
  require('is-installed-globally');
30
- require('fs-extra');
31
32
  require('fs');
32
33
  require('untildify');
33
34
  require('cli-table3');
34
35
  require('dayjs');
35
36
  require('dayjs/plugin/relativeTime');
36
- require('./spawn-DElwyZHC.js');
37
- require('child_process');
37
+ require('./spawn-Bx99tBTm.js');
38
+ require('string_decoder');
38
39
  require('listr2');
39
40
  require('readline');
40
41
  require('stream');
41
- require('string_decoder');
42
42
  require('node:string_decoder');
43
43
  require('timers/promises');
44
44
  require('fs/promises');
@@ -57,19 +57,30 @@ const matchesProject = (record, projectRoot) => {
57
57
  const matchesSession = (record, session) => {
58
58
  return session === undefined || record.pid === session;
59
59
  };
60
- // A dead pid is skipped without a probe (it proves the writer is gone); the
61
- // survivors carry the live browser CDP state from their probe response.
60
+ // Every match is probed, whether or not its pid can be signalled from here: the
61
+ // pid check cannot see across PID namespaces. The survivors carry the live
62
+ // browser CDP state from their probe response.
62
63
  const probeMatches = (matches, probeTimeoutMs) => xvfb.__awaiter(void 0, void 0, void 0, function* () {
63
- const probed = yield Promise.all(matches.map((record) => xvfb.__awaiter(void 0, void 0, void 0, function* () {
64
- return cli.isPidAlive(record.pid) ? cli.verifySessionRecord(record, probeTimeoutMs) : null;
65
- })));
64
+ const probed = yield Promise.all(matches.map((record) => cli.verifySessionRecord(record, probeTimeoutMs)));
66
65
  return probed.filter((session) => session !== null);
67
66
  });
68
67
  const listLiveSessions = (...args_1) => xvfb.__awaiter(void 0, [...args_1], void 0, function* (options = {}) {
69
68
  const records = yield cli.readLiveSessions();
70
- const matches = records.filter((record) => matchesSession(record, options.session));
69
+ const matches = records.filter((record) => !cli.distExports.isStartingRecord(record) && matchesSession(record, options.session));
71
70
  return probeMatches(matches, options.probeTimeoutMs);
72
71
  });
72
+ // The session whose project failed to load, if there is one: it never became a
73
+ // live session, so `status` goes looking for it to say why, and every other command
74
+ // points to `status`. Prefers the project at the cwd, then the lowest pid, as
75
+ // selection does.
76
+ const findStartingSession = (_a) => xvfb.__awaiter(void 0, [_a], void 0, function* ({ session, cwd }) {
77
+ const starting = (yield cli.readStartingSessions()).filter((record) => matchesSession(record, session));
78
+ if (starting.length === 0) {
79
+ return null;
80
+ }
81
+ const atCwd = starting.filter((record) => matchesProject(record, cwd));
82
+ return lowestPid(atCwd.length > 0 ? atCwd : starting);
83
+ });
73
84
  let lastResolvedIdentity = null;
74
85
  // Read rather than threaded through every caller: each tap command resolves its
75
86
  // own session, several of them below this module.
@@ -93,9 +104,21 @@ const selectSession = (candidates, options) => {
93
104
  // for — STALE_SESSION when matches exist but none responds, and
94
105
  // UNSUPPORTED_BROWSER when every one that does has a browser tap cannot drive.
95
106
  const liveMatches = (options) => xvfb.__awaiter(void 0, void 0, void 0, function* () {
96
- const { session, probeTimeoutMs } = options;
107
+ const { session, cwd, probeTimeoutMs } = options;
97
108
  const records = yield cli.readLiveSessions();
98
- const matches = records.filter((record) => matchesSession(record, session));
109
+ // A project that failed to load has a starting record but no session to drive, so it is
110
+ // never among the matches
111
+ const matches = records.filter((record) => !cli.distExports.isStartingRecord(record) && matchesSession(record, session));
112
+ // With nothing live to drive, or only sessions of other projects when none was named, a
113
+ // project that failed to load at the caller's directory is the one to report. Cypress is
114
+ // running, so telling an agent to start it would start a second one.
115
+ const noneAtCwd = session === undefined && !matches.some((record) => matchesProject(record, cwd));
116
+ if (matches.length === 0 || noneAtCwd) {
117
+ const starting = yield cli.readStartingSessions();
118
+ if (starting.some((record) => matchesSession(record, session) && (matches.length === 0 || matchesProject(record, cwd)))) {
119
+ throw new cli.distExports.TapError('PROJECT_NOT_LOADED');
120
+ }
121
+ }
99
122
  if (matches.length === 0) {
100
123
  throw session === undefined
101
124
  ? new cli.distExports.TapError('NO_SESSION')
@@ -987,6 +1010,7 @@ const pinnedBlock = (view) => {
987
1010
  const PHASE = {
988
1011
  passed: { icon: stateBadge.passed.icon, tint: color.pass },
989
1012
  failed: { icon: stateBadge.failed.icon, tint: color.fail },
1013
+ error: { icon: color.fail('●'), tint: color.fail },
990
1014
  running: { icon: color.pending('●'), tint: color.pending },
991
1015
  };
992
1016
  const phaseOf = (status) => { var _a; return (_a = PHASE[status]) !== null && _a !== void 0 ? _a : { icon: color.muted('●'), tint: color.muted }; };
@@ -1560,7 +1584,7 @@ function requireDist () {
1560
1584
  hasRequiredDist = 1;
1561
1585
  (function (exports) {
1562
1586
  Object.defineProperty(exports, "__esModule", { value: true });
1563
- exports.isAgent = exports.detectAgent = void 0;
1587
+ exports.isAgentMode = exports.isAgent = exports.detectAgent = void 0;
1564
1588
  const envMatcher = (key, regex, opts = {}) => {
1565
1589
  return (env) => {
1566
1590
  var _a, _b;
@@ -1616,6 +1640,22 @@ function requireDist () {
1616
1640
  return !!(0, exports.detectAgent)(env);
1617
1641
  };
1618
1642
  exports.isAgent = isAgent;
1643
+ const AGENT_MODE_VARIABLE = 'CYPRESS_AGENT_MODE';
1644
+ // Detection cannot know every host, so a person can force the agent behavior on
1645
+ // for one the table misses, or off for a human whose shell carries a marker.
1646
+ // Any other value defers to detection.
1647
+ const isAgentMode = (env = process.env) => {
1648
+ var _a;
1649
+ const override = (_a = env[AGENT_MODE_VARIABLE]) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase();
1650
+ if (override === '1' || override === 'true') {
1651
+ return true;
1652
+ }
1653
+ if (override === '0' || override === 'false') {
1654
+ return false;
1655
+ }
1656
+ return (0, exports.isAgent)(env);
1657
+ };
1658
+ exports.isAgentMode = isAgentMode;
1619
1659
 
1620
1660
  } (dist));
1621
1661
  return dist;
@@ -1865,6 +1905,8 @@ const defineNativeCommand = (name, handler) => {
1865
1905
  };
1866
1906
 
1867
1907
  const NO_SESSIONS_GUIDANCE = `No running ${cli.distExports.TAP_TARGET} found. Start Cypress in open mode (e.g. \`cypress open\`) and select a testing type to get started.`;
1908
+ // Cypress is running, so telling the reader to start it would start a second one
1909
+ const PROJECT_NOT_LOADED_GUIDANCE = `Cypress is running, but its project could not load, so there is no ${cli.distExports.TAP_TARGET} to list. Run \`cypress tap status\` to see why.`;
1868
1910
  // Bounded, and never throws: `sessions` is what a caller reaches for when
1869
1911
  // everything else is failing, so an unanswered probe is a reported fact rather
1870
1912
  // than an error. Absent means there was nothing to ask, not that it went unasked.
@@ -1883,7 +1925,8 @@ const listSessions = (options) => xvfb.__awaiter(void 0, void 0, void 0, functio
1883
1925
  var _a;
1884
1926
  const sessions = yield listLiveSessions({ session: options.session });
1885
1927
  if (sessions.length === 0) {
1886
- renderResult(NO_SESSIONS_GUIDANCE);
1928
+ const starting = yield findStartingSession({ session: options.session, cwd: process.cwd() });
1929
+ renderResult(starting ? PROJECT_NOT_LOADED_GUIDANCE : NO_SESSIONS_GUIDANCE);
1887
1930
  return 0;
1888
1931
  }
1889
1932
  const timeoutMs = (_a = options.timeout) !== null && _a !== void 0 ? _a : FIND_SESSION_TIMEOUT_MS;
@@ -1901,7 +1944,7 @@ const sessionsCommand = defineNativeCommand('sessions', listSessions);
1901
1944
  // browser tap cannot drive is not a stage polling can outlast, so it is absent.
1902
1945
  // A named `--session` that has gone is one of them, so a poller watching one pid
1903
1946
  // keeps reading `not connected` after it exits rather than starting to error.
1904
- const NOT_CONNECTED_CODES = new Set(['NO_SESSION', 'SESSION_NOT_FOUND', 'STALE_SESSION']);
1947
+ const NOT_CONNECTED_CODES = new Set(['NO_SESSION', 'PROJECT_NOT_LOADED', 'SESSION_NOT_FOUND', 'STALE_SESSION']);
1905
1948
  const mergeRunState = (base, runState) => {
1906
1949
  var _a;
1907
1950
  const pinned = runState.pinned ? { pinned: runState.pinned } : {};
@@ -1910,6 +1953,21 @@ const mergeRunState = (base, runState) => {
1910
1953
  }
1911
1954
  return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, base), { status: runState.state, totalSpecs: runState.totalSpecs }), (runState.spec !== null ? { spec: runState.spec } : {})), { startedAt: (_a = runState.startedAt) !== null && _a !== void 0 ? _a : null, totalTests: runState.totalTests, results: runState.results }), (runState.error ? { error: runState.error } : {})), pinned);
1912
1955
  };
1956
+ // A project that could not load never starts a session, so it would otherwise read
1957
+ // as `not connected` for as long as it stays broken.
1958
+ const notConnectedStatus = (options) => xvfb.__awaiter(void 0, void 0, void 0, function* () {
1959
+ const starting = yield findStartingSession({ session: options.session, cwd: process.cwd() });
1960
+ if (!(starting === null || starting === void 0 ? void 0 : starting.loadError)) {
1961
+ return { status: 'not connected' };
1962
+ }
1963
+ return {
1964
+ status: 'error',
1965
+ pid: starting.pid,
1966
+ projectRoot: starting.projectRoot,
1967
+ testingType: starting.testingType,
1968
+ error: starting.loadError.message,
1969
+ };
1970
+ });
1913
1971
  const reportStatus = (options) => xvfb.__awaiter(void 0, void 0, void 0, function* () {
1914
1972
  let selection;
1915
1973
  try {
@@ -1918,7 +1976,7 @@ const reportStatus = (options) => xvfb.__awaiter(void 0, void 0, void 0, functio
1918
1976
  catch (err) {
1919
1977
  // No live session is a status a poller waits on, not a failure.
1920
1978
  if (cli.distExports.isTapError(err) && NOT_CONNECTED_CODES.has(err.code)) {
1921
- renderOutcome('status', { status: 'not connected' }, options.json);
1979
+ renderOutcome('status', yield notConnectedStatus(options), options.json);
1922
1980
  return 0;
1923
1981
  }
1924
1982
  throw err;
@@ -2649,6 +2707,22 @@ const argumentsOf = (params) => {
2649
2707
  const argumentDescriptions = (params) => {
2650
2708
  return Object.fromEntries(params.map(({ name, description }) => [name, description]));
2651
2709
  };
2710
+ const longFlagOf = ({ name, type }) => type === 'boolean' ? `--${name}` : `--${name} <${name}>`;
2711
+ // commander renders a mandatory option exactly like an optional one, and has no
2712
+ // notion of one flag depending on another, so the help states both itself, in
2713
+ // the same trailing style as its `(default: …)`.
2714
+ const describeOption = ({ description, required, requires }) => {
2715
+ const unless = (requires === null || requires === void 0 ? void 0 : requires.unless) ? ` unless --${requires.unless}` : '';
2716
+ const notes = [required && '(required)', requires && `(requires --${requires.option}${unless})`];
2717
+ return [description, ...notes].filter(Boolean).join(' ');
2718
+ };
2719
+ // commander's default usage collapses every flag into `[options]`; a flag the
2720
+ // command cannot run without is spelled out so the usage line alone is enough
2721
+ // to build a valid invocation.
2722
+ const usageOf = (params, options) => {
2723
+ const requiredFlags = options.filter(({ required }) => required).map(longFlagOf);
2724
+ return ['[options]', ...requiredFlags, argumentsOf(params)].filter(Boolean).join(' ');
2725
+ };
2652
2726
  const JSON_DESCRIPTION = 'print the raw JSON result instead of the human-readable rendering';
2653
2727
  // commander wraps the option and command descriptions it renders but prints a
2654
2728
  // program description verbatim, so this one is wrapped to the same width by hand.
@@ -2679,14 +2753,13 @@ const declareOptions = (command, options) => {
2679
2753
  // so the schema contributes only its description.
2680
2754
  const json = options.find(({ name }) => name === 'json');
2681
2755
  for (const option of options.filter((candidate) => candidate !== json)) {
2682
- const { name, alias, type, required, description } = option;
2683
- const lead = alias ? `-${alias}, ` : '';
2684
- const flags = type === 'boolean' ? `${lead}--${name}` : `${lead}--${name} <${name}>`;
2685
- if (required && type !== 'boolean') {
2686
- command.requiredOption(flags, description);
2756
+ const lead = option.alias ? `-${option.alias}, ` : '';
2757
+ const flags = `${lead}${longFlagOf(option)}`;
2758
+ if (option.required) {
2759
+ command.requiredOption(flags, describeOption(option));
2687
2760
  }
2688
2761
  else {
2689
- declareOption(command, flags, description, option.defaultValue);
2762
+ declareOption(command, flags, describeOption(option), option.defaultValue);
2690
2763
  }
2691
2764
  }
2692
2765
  declareSharedOptions(command, (_a = json === null || json === void 0 ? void 0 : json.description) !== null && _a !== void 0 ? _a : JSON_DESCRIPTION);
@@ -2766,6 +2839,7 @@ const declareCommand = (program, spec, dispatch) => {
2766
2839
  // Keep option values in opts() so schema names such as `command` cannot
2767
2840
  // collide with Command instance methods.
2768
2841
  command.storeOptionsAsProperties(false);
2842
+ command.usage(usageOf(params, options));
2769
2843
  if (params.length) {
2770
2844
  command.arguments(argumentsOf(params));
2771
2845
  command.description(description, argumentDescriptions(params));
@@ -2779,7 +2853,14 @@ const declareCommand = (program, spec, dispatch) => {
2779
2853
  if (dispatch) {
2780
2854
  command.action(() => {
2781
2855
  rejectExcessArguments(name, params, command.args);
2782
- return dispatch(name, forwardedArgs(params, command.args), forwardedOptions(command, options));
2856
+ // Answered here as well as by the session, because a CLI-native command
2857
+ // never reaches the session's checks.
2858
+ const forwarded = forwardedOptions(command, options);
2859
+ const unmet = cli.distExports.unmetDependency(options, forwarded);
2860
+ if (unmet) {
2861
+ throw unmet;
2862
+ }
2863
+ return dispatch(name, forwardedArgs(params, command.args), forwarded);
2783
2864
  });
2784
2865
  }
2785
2866
  };
@@ -2849,6 +2930,7 @@ const debug = Debug('cypress:cli:tap');
2849
2930
  // without one, so these — and only these — lose to a help invocation.
2850
2931
  const DISCOVERY_CODES = new Set([
2851
2932
  'NO_SESSION',
2933
+ 'PROJECT_NOT_LOADED',
2852
2934
  'SESSION_NOT_FOUND',
2853
2935
  'STALE_SESSION',
2854
2936
  'NO_BROWSER_ATTACHED',