@@ -513,16 +513,24 @@ and/or
513
513
can be used within the callback to include [ npm] ( https://www.npmjs.com/ )
514
514
packages and other files.
515
515
516
- If you utilize a custom preprocessor, note that this feature requires the latest
517
- version of
518
- [ ` @cypress/webpack-preprocessor ` ] ( https://github.com/cypress-io/cypress/tree/master/npm/webpack-preprocessor )
519
- to work. If using a custom preprocessor or an older version of the webpack
520
- preprocessor, you'll see an error that includes the following text:
516
+ <Alert type =" warning " >
521
517
522
- ```
523
- Using require() or import() to include dependencies requires using the
524
- latest version of @cypress/webpack-preprocessor.
525
- ```
518
+ Using ` import() ` and ` require() ` within the callback requires version 5.15.0 or
519
+ greater of the
520
+ [ ` @cypress/webpack-preprocessor ` ] ( https://github.com/cypress-io/cypress/tree/master/npm/webpack-preprocessor ) .
521
+ This is included in Cypress by default, but if your project installs its own
522
+ version of ` @cypress/webpack-preprocessor ` that is set up in your Cypress
523
+ config, make sure it is version 5.15.0 or greater.
524
+
525
+ If using an older version of the webpack or a different preprocessor, you'll see
526
+ an error that includes the following text:
527
+
528
+ _ Using require() or import() to include dependencies requires using the latest
529
+ version of @cypress/webpack-preprocessor ._
530
+
531
+ </Alert >
532
+
533
+ #### Example
526
534
527
535
``` js
528
536
// ES modules
@@ -542,6 +550,8 @@ cy.origin('somesite.com', () => {
542
550
})
543
551
```
544
552
553
+ #### Custom commands
554
+
545
555
This makes it possible to share custom commands between tests run in primary and
546
556
secondary origins. We recommend this pattern for setting up your
547
557
[ support file] ( /guides/core-concepts/writing-and-organizing-tests#Support-file )
@@ -589,6 +599,8 @@ it('tests somesite.com', () => {
589
599
})
590
600
```
591
601
602
+ #### Shared execution context
603
+
592
604
The JavaScript execution context is persisted between ` cy.origin() ` callbacks
593
605
that share the same origin. This can be utilized to share code between
594
606
successive ` cy.origin() ` calls.
0 commit comments