cypress 10.4.0 → 10.7.0
Sign up to get free protection for your applications and to get access to all the features.
- package/angular/CHANGELOG.md +86 -0
- package/angular/README.md +85 -0
- package/angular/dist/index.d.ts +1 -0
- package/angular/dist/index.js +265 -0
- package/angular/dist/mount.d.ts +112 -0
- package/angular/package.json +68 -0
- package/lib/tasks/download.js +4 -3
- package/mount-utils/CHANGELOG.md +7 -0
- package/mount-utils/package.json +5 -1
- package/package.json +16 -4
- package/react/CHANGELOG.md +20 -0
- package/react/dist/createMount.d.ts +7 -6
- package/react/dist/cypress-react.cjs.js +653 -140
- package/react/dist/cypress-react.esm-bundler.js +640 -127
- package/react/dist/mount.d.ts +2 -1
- package/react/dist/mountHook.d.ts +1 -0
- package/react/dist/types.d.ts +2 -7
- package/react/package.json +4 -6
- package/react18/CHANGELOG.md +13 -0
- package/react18/dist/cypress-react.cjs.js +300 -118
- package/react18/dist/cypress-react.esm-bundler.js +286 -104
- package/react18/dist/index.d.ts +2 -1
- package/react18/package.json +2 -2
- package/svelte/CHANGELOG.md +0 -0
- package/svelte/README.md +83 -0
- package/svelte/dist/cypress-svelte.cjs.js +213 -0
- package/svelte/dist/cypress-svelte.esm-bundler.js +209 -0
- package/svelte/dist/index.d.ts +1 -0
- package/svelte/dist/mount.d.ts +30 -0
- package/svelte/package.json +43 -0
- package/types/cypress-type-helpers.d.ts +3 -1
- package/types/cypress.d.ts +61 -5
- package/vue/CHANGELOG.md +14 -0
- package/vue/dist/cypress-vue.cjs.js +30 -38
- package/vue/dist/cypress-vue.esm-bundler.js +30 -38
- package/vue/dist/index.d.ts +1 -0
- package/vue/package.json +2 -8
- package/vue2/CHANGELOG.md +7 -0
- package/vue2/dist/cypress-vue2.cjs.js +53 -84
- package/vue2/dist/cypress-vue2.esm-bundler.js +53 -84
- package/vue2/dist/index.d.ts +1 -0
- package/vue2/package.json +2 -5
- package/vue2/dist/cypress-vue2.browser.js +0 -20197
@@ -9,46 +9,19 @@ import ReactDOM from 'react-dom/client';
|
|
9
9
|
import * as React from 'react';
|
10
10
|
import 'react-dom';
|
11
11
|
|
12
|
-
|
13
|
-
Copyright (c) Microsoft Corporation.
|
14
|
-
|
15
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
16
|
-
purpose with or without fee is hereby granted.
|
17
|
-
|
18
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
19
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
20
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
21
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
22
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
23
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
24
|
-
PERFORMANCE OF THIS SOFTWARE.
|
25
|
-
***************************************************************************** */
|
26
|
-
|
27
|
-
var __assign = function() {
|
28
|
-
__assign = Object.assign || function __assign(t) {
|
29
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
30
|
-
s = arguments[i];
|
31
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
32
|
-
}
|
33
|
-
return t;
|
34
|
-
};
|
35
|
-
return __assign.apply(this, arguments);
|
36
|
-
};
|
37
|
-
|
38
|
-
var cachedDisplayNames = new WeakMap();
|
12
|
+
const cachedDisplayNames = new WeakMap();
|
39
13
|
/**
|
40
14
|
* Gets the display name of the component when possible.
|
41
15
|
* @param type {JSX} The type object returned from creating the react element.
|
42
16
|
* @param fallbackName {string} The alias, or fallback name to use when the name cannot be derived.
|
43
17
|
* @link https://github.com/facebook/react-devtools/blob/master/backend/getDisplayName.js
|
44
18
|
*/
|
45
|
-
function getDisplayName(type, fallbackName) {
|
46
|
-
|
47
|
-
var nameFromCache = cachedDisplayNames.get(type);
|
19
|
+
function getDisplayName(type, fallbackName = 'Unknown') {
|
20
|
+
const nameFromCache = cachedDisplayNames.get(type);
|
48
21
|
if (nameFromCache != null) {
|
49
22
|
return nameFromCache;
|
50
23
|
}
|
51
|
-
|
24
|
+
let displayName = null;
|
52
25
|
// The displayName property is not guaranteed to be a string.
|
53
26
|
// It's only safe to use for our purposes if it's a string.
|
54
27
|
// github.com/facebook/react-devtools/issues/803
|
@@ -60,13 +33,13 @@ function getDisplayName(type, fallbackName) {
|
|
60
33
|
}
|
61
34
|
// Facebook-specific hack to turn "Image [from Image.react]" into just "Image".
|
62
35
|
// We need displayName with module name for error reports but it clutters the DevTools.
|
63
|
-
|
36
|
+
const match = displayName.match(/^(.*) \[from (.*)\]$/);
|
64
37
|
if (match) {
|
65
|
-
|
66
|
-
|
38
|
+
const componentName = match[1];
|
39
|
+
const moduleName = match[2];
|
67
40
|
if (componentName && moduleName) {
|
68
41
|
if (moduleName === componentName ||
|
69
|
-
moduleName.startsWith(componentName
|
42
|
+
moduleName.startsWith(`${componentName}.`)) {
|
70
43
|
displayName = componentName;
|
71
44
|
}
|
72
45
|
}
|
@@ -225,13 +198,13 @@ function setupHooks(optionalCallback) {
|
|
225
198
|
/**
|
226
199
|
* Inject custom style text or CSS file or 3rd party style resources
|
227
200
|
*/
|
228
|
-
|
229
|
-
return
|
230
|
-
|
201
|
+
const injectStyles = (options) => {
|
202
|
+
return () => {
|
203
|
+
const el = getContainerEl();
|
231
204
|
return injectStylesBeforeElement(options, document, el);
|
232
205
|
};
|
233
206
|
};
|
234
|
-
|
207
|
+
let mountCleanup;
|
235
208
|
/**
|
236
209
|
* Create an `mount` function. Performs all the non-React-version specific
|
237
210
|
* behavior related to mounting. The React-version-specific code
|
@@ -241,41 +214,40 @@ var lastMountedReactDom;
|
|
241
214
|
* This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
|
242
215
|
* or people writing adapters for third-party, custom adapters.
|
243
216
|
*/
|
244
|
-
|
245
|
-
if (options === void 0) { options = {}; }
|
217
|
+
const makeMountFn = (type, jsx, options = {}, rerenderKey, internalMountOptions) => {
|
246
218
|
if (!internalMountOptions) {
|
247
219
|
throw Error('internalMountOptions must be provided with `render` and `reactDom` parameters');
|
248
220
|
}
|
221
|
+
mountCleanup = internalMountOptions.cleanup;
|
249
222
|
// Get the display name property via the component constructor
|
250
223
|
// @ts-ignore FIXME
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
? jsxComponentName
|
224
|
+
const componentName = getDisplayName(jsx.type, options.alias);
|
225
|
+
const displayName = options.alias || componentName;
|
226
|
+
const jsxComponentName = `<${componentName} ... />`;
|
227
|
+
const message = options.alias
|
228
|
+
? `${jsxComponentName} as "${options.alias}"`
|
256
229
|
: jsxComponentName;
|
257
230
|
return cy
|
258
231
|
.then(injectStyles(options))
|
259
|
-
.then(
|
232
|
+
.then(() => {
|
260
233
|
var _a, _b, _c;
|
261
|
-
|
262
|
-
|
263
|
-
var el = getContainerEl();
|
234
|
+
const reactDomToUse = internalMountOptions.reactDom;
|
235
|
+
const el = getContainerEl();
|
264
236
|
if (!el) {
|
265
237
|
throw new Error([
|
266
|
-
|
238
|
+
`[@cypress/react] 🔥 Hmm, cannot find root element to mount the component. Searched for ${ROOT_SELECTOR}`,
|
267
239
|
].join(' '));
|
268
240
|
}
|
269
|
-
|
241
|
+
const key = rerenderKey !== null && rerenderKey !== void 0 ? rerenderKey :
|
270
242
|
// @ts-ignore provide unique key to the the wrapped component to make sure we are rerendering between tests
|
271
243
|
(((_c = (_b = (_a = Cypress === null || Cypress === void 0 ? void 0 : Cypress.mocha) === null || _a === void 0 ? void 0 : _a.getRunner()) === null || _b === void 0 ? void 0 : _b.test) === null || _c === void 0 ? void 0 : _c.title) || '') + Math.random();
|
272
|
-
|
273
|
-
key
|
244
|
+
const props = {
|
245
|
+
key,
|
274
246
|
};
|
275
|
-
|
247
|
+
const reactComponent = React.createElement(options.strict ? React.StrictMode : React.Fragment, props, jsx);
|
276
248
|
// since we always surround the component with a fragment
|
277
249
|
// let's get back the original component
|
278
|
-
|
250
|
+
const userComponent = reactComponent.props.children;
|
279
251
|
internalMountOptions.render(reactComponent, el, reactDomToUse);
|
280
252
|
if (options.log !== false) {
|
281
253
|
Cypress.log({
|
@@ -284,7 +256,7 @@ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOption
|
|
284
256
|
message: [message],
|
285
257
|
// @ts-ignore
|
286
258
|
$el: el.children.item(0),
|
287
|
-
consoleProps:
|
259
|
+
consoleProps: () => {
|
288
260
|
return {
|
289
261
|
// @ts-ignore protect the use of jsx functional components use ReactNode
|
290
262
|
props: jsx.props,
|
@@ -298,10 +270,10 @@ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOption
|
|
298
270
|
// Separate alias and returned value. Alias returns the component only, and the thenable returns the additional functions
|
299
271
|
cy.wrap(userComponent, { log: false })
|
300
272
|
.as(displayName)
|
301
|
-
.then(
|
273
|
+
.then(() => {
|
302
274
|
return cy.wrap({
|
303
275
|
component: userComponent,
|
304
|
-
rerender:
|
276
|
+
rerender: (newComponent) => makeMountFn('rerender', newComponent, options, key, internalMountOptions),
|
305
277
|
unmount: internalMountOptions.unmount,
|
306
278
|
}, { log: false });
|
307
279
|
})
|
@@ -319,39 +291,31 @@ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOption
|
|
319
291
|
* This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
|
320
292
|
* or people writing adapters for third-party, custom adapters.
|
321
293
|
*/
|
322
|
-
|
323
|
-
return cy.then(
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
},
|
341
|
-
});
|
342
|
-
}
|
343
|
-
}
|
344
|
-
});
|
294
|
+
const makeUnmountFn = (options) => {
|
295
|
+
return cy.then(() => {
|
296
|
+
var _a;
|
297
|
+
const wasUnmounted = mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
|
298
|
+
if (wasUnmounted && options.log) {
|
299
|
+
Cypress.log({
|
300
|
+
name: 'unmount',
|
301
|
+
type: 'parent',
|
302
|
+
message: [(_a = options.boundComponentMessage) !== null && _a !== void 0 ? _a : 'Unmounted component'],
|
303
|
+
consoleProps: () => {
|
304
|
+
return {
|
305
|
+
description: 'Unmounts React component',
|
306
|
+
parent: getContainerEl().parentNode,
|
307
|
+
home: 'https://github.com/cypress-io/cypress',
|
308
|
+
};
|
309
|
+
},
|
310
|
+
});
|
311
|
+
}
|
345
312
|
});
|
346
313
|
};
|
347
314
|
// Cleanup before each run
|
348
315
|
// NOTE: we cannot use unmount here because
|
349
316
|
// we are not in the context of a test
|
350
|
-
|
351
|
-
|
352
|
-
if (el && lastMountedReactDom) {
|
353
|
-
lastMountedReactDom.unmountComponentAtNode(el);
|
354
|
-
}
|
317
|
+
const preMountCleanup = () => {
|
318
|
+
mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
|
355
319
|
};
|
356
320
|
// Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
|
357
321
|
// by creating an explicit function/import that the user can register in their 'component.js' support file,
|
@@ -366,29 +330,247 @@ var preMountCleanup = function () {
|
|
366
330
|
// @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator-spec.js
|
367
331
|
setupHooks(preMountCleanup);
|
368
332
|
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
333
|
+
const debug = (
|
334
|
+
typeof process === 'object' &&
|
335
|
+
process.env &&
|
336
|
+
process.env.NODE_DEBUG &&
|
337
|
+
/\bsemver\b/i.test(process.env.NODE_DEBUG)
|
338
|
+
) ? (...args) => console.error('SEMVER', ...args)
|
339
|
+
: () => {};
|
340
|
+
|
341
|
+
var debug_1 = debug;
|
342
|
+
|
343
|
+
// Note: this is the semver.org version of the spec that it implements
|
344
|
+
// Not necessarily the package version of this code.
|
345
|
+
const SEMVER_SPEC_VERSION = '2.0.0';
|
346
|
+
|
347
|
+
const MAX_LENGTH$1 = 256;
|
348
|
+
const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
|
349
|
+
/* istanbul ignore next */ 9007199254740991;
|
350
|
+
|
351
|
+
// Max safe segment length for coercion.
|
352
|
+
const MAX_SAFE_COMPONENT_LENGTH = 16;
|
353
|
+
|
354
|
+
var constants = {
|
355
|
+
SEMVER_SPEC_VERSION,
|
356
|
+
MAX_LENGTH: MAX_LENGTH$1,
|
357
|
+
MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
|
358
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
359
|
+
};
|
360
|
+
|
361
|
+
function createCommonjsModule(fn) {
|
362
|
+
var module = { exports: {} };
|
363
|
+
return fn(module, module.exports), module.exports;
|
364
|
+
}
|
365
|
+
|
366
|
+
createCommonjsModule(function (module, exports) {
|
367
|
+
const { MAX_SAFE_COMPONENT_LENGTH } = constants;
|
368
|
+
|
369
|
+
exports = module.exports = {};
|
370
|
+
|
371
|
+
// The actual regexps go on exports.re
|
372
|
+
const re = exports.re = [];
|
373
|
+
const src = exports.src = [];
|
374
|
+
const t = exports.t = {};
|
375
|
+
let R = 0;
|
376
|
+
|
377
|
+
const createToken = (name, value, isGlobal) => {
|
378
|
+
const index = R++;
|
379
|
+
debug_1(name, index, value);
|
380
|
+
t[name] = index;
|
381
|
+
src[index] = value;
|
382
|
+
re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
|
383
|
+
};
|
384
|
+
|
385
|
+
// The following Regular Expressions can be used for tokenizing,
|
386
|
+
// validating, and parsing SemVer version strings.
|
387
|
+
|
388
|
+
// ## Numeric Identifier
|
389
|
+
// A single `0`, or a non-zero digit followed by zero or more digits.
|
390
|
+
|
391
|
+
createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
|
392
|
+
createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+');
|
393
|
+
|
394
|
+
// ## Non-numeric Identifier
|
395
|
+
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
396
|
+
// more letters, digits, or hyphens.
|
397
|
+
|
398
|
+
createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*');
|
399
|
+
|
400
|
+
// ## Main Version
|
401
|
+
// Three dot-separated numeric identifiers.
|
402
|
+
|
403
|
+
createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
|
404
|
+
`(${src[t.NUMERICIDENTIFIER]})\\.` +
|
405
|
+
`(${src[t.NUMERICIDENTIFIER]})`);
|
406
|
+
|
407
|
+
createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
408
|
+
`(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
409
|
+
`(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
410
|
+
|
411
|
+
// ## Pre-release Version Identifier
|
412
|
+
// A numeric identifier, or a non-numeric identifier.
|
413
|
+
|
414
|
+
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
|
415
|
+
}|${src[t.NONNUMERICIDENTIFIER]})`);
|
416
|
+
|
417
|
+
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
|
418
|
+
}|${src[t.NONNUMERICIDENTIFIER]})`);
|
419
|
+
|
420
|
+
// ## Pre-release Version
|
421
|
+
// Hyphen, followed by one or more dot-separated pre-release version
|
422
|
+
// identifiers.
|
423
|
+
|
424
|
+
createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
|
425
|
+
}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
426
|
+
|
427
|
+
createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
|
428
|
+
}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
429
|
+
|
430
|
+
// ## Build Metadata Identifier
|
431
|
+
// Any combination of digits, letters, or hyphens.
|
432
|
+
|
433
|
+
createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+');
|
434
|
+
|
435
|
+
// ## Build Metadata
|
436
|
+
// Plus sign, followed by one or more period-separated build metadata
|
437
|
+
// identifiers.
|
438
|
+
|
439
|
+
createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
|
440
|
+
}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
441
|
+
|
442
|
+
// ## Full Version String
|
443
|
+
// A main version, followed optionally by a pre-release version and
|
444
|
+
// build metadata.
|
445
|
+
|
446
|
+
// Note that the only major, minor, patch, and pre-release sections of
|
447
|
+
// the version string are capturing groups. The build metadata is not a
|
448
|
+
// capturing group, because it should not ever be used in version
|
449
|
+
// comparison.
|
450
|
+
|
451
|
+
createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
|
452
|
+
}${src[t.PRERELEASE]}?${
|
453
|
+
src[t.BUILD]}?`);
|
454
|
+
|
455
|
+
createToken('FULL', `^${src[t.FULLPLAIN]}$`);
|
456
|
+
|
457
|
+
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
458
|
+
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
459
|
+
// common in the npm registry.
|
460
|
+
createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
|
461
|
+
}${src[t.PRERELEASELOOSE]}?${
|
462
|
+
src[t.BUILD]}?`);
|
463
|
+
|
464
|
+
createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
|
465
|
+
|
466
|
+
createToken('GTLT', '((?:<|>)?=?)');
|
467
|
+
|
468
|
+
// Something like "2.*" or "1.2.x".
|
469
|
+
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
470
|
+
// Only the first item is strictly required.
|
471
|
+
createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
472
|
+
createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
473
|
+
|
474
|
+
createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
|
475
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
476
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
477
|
+
`(?:${src[t.PRERELEASE]})?${
|
478
|
+
src[t.BUILD]}?` +
|
479
|
+
`)?)?`);
|
480
|
+
|
481
|
+
createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
482
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
483
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
484
|
+
`(?:${src[t.PRERELEASELOOSE]})?${
|
485
|
+
src[t.BUILD]}?` +
|
486
|
+
`)?)?`);
|
487
|
+
|
488
|
+
createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
489
|
+
createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
490
|
+
|
491
|
+
// Coercion.
|
492
|
+
// Extract anything that could conceivably be a part of a valid semver
|
493
|
+
createToken('COERCE', `${'(^|[^\\d])' +
|
494
|
+
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
|
495
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
496
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
497
|
+
`(?:$|[^\\d])`);
|
498
|
+
createToken('COERCERTL', src[t.COERCE], true);
|
499
|
+
|
500
|
+
// Tilde ranges.
|
501
|
+
// Meaning is "reasonably at or greater than"
|
502
|
+
createToken('LONETILDE', '(?:~>?)');
|
503
|
+
|
504
|
+
createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
505
|
+
exports.tildeTrimReplace = '$1~';
|
506
|
+
|
507
|
+
createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
508
|
+
createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
509
|
+
|
510
|
+
// Caret ranges.
|
511
|
+
// Meaning is "at least and backwards compatible with"
|
512
|
+
createToken('LONECARET', '(?:\\^)');
|
513
|
+
|
514
|
+
createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
515
|
+
exports.caretTrimReplace = '$1^';
|
516
|
+
|
517
|
+
createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
518
|
+
createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
519
|
+
|
520
|
+
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
521
|
+
createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
522
|
+
createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
523
|
+
|
524
|
+
// An expression to strip any whitespace between the gtlt and the thing
|
525
|
+
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
526
|
+
createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
|
527
|
+
}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
528
|
+
exports.comparatorTrimReplace = '$1$2$3';
|
529
|
+
|
530
|
+
// Something like `1.2.3 - 1.2.4`
|
531
|
+
// Note that these all use the loose form, because they'll be
|
532
|
+
// checked against either the strict or loose comparator form
|
533
|
+
// later.
|
534
|
+
createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
|
535
|
+
`\\s+-\\s+` +
|
536
|
+
`(${src[t.XRANGEPLAIN]})` +
|
537
|
+
`\\s*$`);
|
538
|
+
|
539
|
+
createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
|
540
|
+
`\\s+-\\s+` +
|
541
|
+
`(${src[t.XRANGEPLAINLOOSE]})` +
|
542
|
+
`\\s*$`);
|
543
|
+
|
544
|
+
// Star ranges basically just allow anything at all.
|
545
|
+
createToken('STAR', '(<|>)?=?\\s*\\*');
|
546
|
+
// >=0.0.0 is like a star
|
547
|
+
createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
|
548
|
+
createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
|
549
|
+
});
|
550
|
+
|
551
|
+
// @ts-expect-error
|
552
|
+
let root;
|
553
|
+
const cleanup = () => {
|
554
|
+
if (root) {
|
555
|
+
root.unmount();
|
556
|
+
return true;
|
557
|
+
}
|
558
|
+
return false;
|
559
|
+
};
|
560
|
+
function mount(jsx, options = {}, rerenderKey) {
|
561
|
+
const internalOptions = {
|
373
562
|
reactDom: ReactDOM,
|
374
|
-
render:
|
563
|
+
render: (reactComponent, el) => {
|
375
564
|
root = ReactDOM.createRoot(el);
|
376
565
|
return root.render(reactComponent);
|
377
566
|
},
|
378
|
-
unmount
|
567
|
+
unmount,
|
568
|
+
cleanup,
|
379
569
|
};
|
380
|
-
return makeMountFn('mount', jsx,
|
570
|
+
return makeMountFn('mount', jsx, Object.assign({ ReactDom: ReactDOM }, options), rerenderKey, internalOptions);
|
381
571
|
}
|
382
|
-
function unmount(options) {
|
383
|
-
|
384
|
-
var internalOptions = {
|
385
|
-
// type is ReturnType<typeof ReactDOM.createRoot>
|
386
|
-
unmount: function () {
|
387
|
-
root.unmount();
|
388
|
-
return true;
|
389
|
-
},
|
390
|
-
};
|
391
|
-
return makeUnmountFn(options, internalOptions);
|
572
|
+
function unmount(options = { log: true }) {
|
573
|
+
return makeUnmountFn(options);
|
392
574
|
}
|
393
575
|
|
394
576
|
export { mount, unmount };
|
package/react18/dist/index.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
/// <reference types="cypress" />
|
2
|
+
/// <reference types="cypress" />
|
2
3
|
import React from 'react';
|
3
4
|
import type { MountOptions, UnmountArgs } from '@cypress/react';
|
4
5
|
export declare function mount(jsx: React.ReactNode, options?: MountOptions, rerenderKey?: string): Cypress.Chainable<import("@cypress/react").MountReturn>;
|
5
|
-
export declare function unmount(options?: UnmountArgs): Cypress.Chainable<
|
6
|
+
export declare function unmount(options?: UnmountArgs): Cypress.Chainable<undefined>;
|
package/react18/package.json
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
"description": "Test React components using Cypress",
|
5
5
|
"main": "dist/cypress-react.cjs.js",
|
6
6
|
"scripts": {
|
7
|
-
"build": "rimraf dist && rollup -c rollup.config.
|
7
|
+
"build": "rimraf dist && rollup -c rollup.config.mjs",
|
8
8
|
"postbuild": "node ../../scripts/sync-exported-npm-with-cli.js",
|
9
9
|
"build-prod": "yarn build",
|
10
10
|
"watch": "yarn build --watch --watch.exclude ./dist/**/*"
|
@@ -20,7 +20,7 @@
|
|
20
20
|
"react-dom": "^16",
|
21
21
|
"rollup": "^2.38.5",
|
22
22
|
"rollup-plugin-typescript2": "^0.29.0",
|
23
|
-
"typescript": "^4.
|
23
|
+
"typescript": "^4.7.4"
|
24
24
|
},
|
25
25
|
"peerDependencies": {
|
26
26
|
"@types/react": "^18",
|
File without changes
|
package/svelte/README.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# @cypress/svelte
|
2
|
+
|
3
|
+
Mount Svelte components in the open source [Cypress.io](https://www.cypress.io/) test runner **v10.7.0+**
|
4
|
+
|
5
|
+
> **Note:** This package is bundled with the `cypress` package and should not need to be installed separately. See the [Svelte Component Testing Docs](https://docs.cypress.io/guides/component-testing/quickstart-svelte#Configuring-Component-Testing) for mounting Svelte components. Installing and importing `mount` from `@cypress/svelte` should only be used for advanced use-cases.
|
6
|
+
|
7
|
+
## Install
|
8
|
+
|
9
|
+
- Requires Svelte >= 3
|
10
|
+
- Requires Cypress v10.7.0 or later
|
11
|
+
- Requires [Node](https://nodejs.org/en/) version 12 or above
|
12
|
+
|
13
|
+
```sh
|
14
|
+
npm install --save-dev @cypress/svelte
|
15
|
+
```
|
16
|
+
|
17
|
+
## Run
|
18
|
+
|
19
|
+
Open cypress test runner
|
20
|
+
```
|
21
|
+
npx cypress open --component
|
22
|
+
```
|
23
|
+
|
24
|
+
If you need to run test in CI
|
25
|
+
```
|
26
|
+
npx cypress run --component
|
27
|
+
```
|
28
|
+
|
29
|
+
For more information, please check the official docs for [running Cypress](https://on.cypress.io/guides/getting-started/opening-the-app#Quick-Configuration) and for [component testing](https://on.cypress.io/guides/component-testing/writing-your-first-component-test).
|
30
|
+
|
31
|
+
## Example
|
32
|
+
|
33
|
+
```js
|
34
|
+
import { mount } from '@cypress/svelte'
|
35
|
+
import HelloWorld from './HelloWorld.svelte'
|
36
|
+
|
37
|
+
describe('HelloWorld component', () => {
|
38
|
+
it('works', () => {
|
39
|
+
mount(HelloWorld)
|
40
|
+
// now use standard Cypress commands
|
41
|
+
cy.contains('Hello World!').should('be.visible')
|
42
|
+
})
|
43
|
+
})
|
44
|
+
```
|
45
|
+
|
46
|
+
## Options
|
47
|
+
|
48
|
+
In most cases, the component already imports its own styles, thus it looks "right" during the test. If you need another CSS, the simplest way is to import it from the spec file:
|
49
|
+
|
50
|
+
```js
|
51
|
+
// src/HelloWorld.svelte
|
52
|
+
import './styles/main.css'
|
53
|
+
import HelloWorld from './HelloWorld.svelte'
|
54
|
+
|
55
|
+
it('looks right', () => {
|
56
|
+
// styles are applied
|
57
|
+
mount(HelloWorld)
|
58
|
+
})
|
59
|
+
```
|
60
|
+
|
61
|
+
> Note: Global styles can be imported in your component support file, allowing the styles to apply to all mounted components.
|
62
|
+
|
63
|
+
## Compatibility
|
64
|
+
|
65
|
+
| @cypress/svelte | cypress |
|
66
|
+
| -------------- | ------- |
|
67
|
+
| >= v1 | >= v10 |
|
68
|
+
|
69
|
+
## Development
|
70
|
+
|
71
|
+
Run `yarn build` to compile and sync packages to the `cypress` cli package.
|
72
|
+
|
73
|
+
Run `yarn cy:open` to open Cypress component testing against real-world examples.
|
74
|
+
|
75
|
+
Run `yarn test` to execute headless Cypress tests.
|
76
|
+
|
77
|
+
## License
|
78
|
+
|
79
|
+
[![license](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/cypress-io/cypress/blob/master/LICENSE)
|
80
|
+
|
81
|
+
This project is licensed under the terms of the [MIT license](/LICENSE).
|
82
|
+
|
83
|
+
## [Changelog](./CHANGELOG.md)
|