Skip to content

Commit 42354f2

Browse files
committed
add specific preprocessor version, improve copy, and add headers
1 parent 590ce26 commit 42354f2

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

content/api/commands/origin.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -513,16 +513,24 @@ and/or
513513
can be used within the callback to include [npm](https://www.npmjs.com/)
514514
packages and other files.
515515

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">
521517

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
526534

527535
```js
528536
// ES modules
@@ -542,6 +550,8 @@ cy.origin('somesite.com', () => {
542550
})
543551
```
544552

553+
#### Custom commands
554+
545555
This makes it possible to share custom commands between tests run in primary and
546556
secondary origins. We recommend this pattern for setting up your
547557
[support file](/guides/core-concepts/writing-and-organizing-tests#Support-file)
@@ -589,6 +599,8 @@ it('tests somesite.com', () => {
589599
})
590600
```
591601

602+
#### Shared execution context
603+
592604
The JavaScript execution context is persisted between `cy.origin()` callbacks
593605
that share the same origin. This can be utilized to share code between
594606
successive `cy.origin()` calls.

0 commit comments

Comments
 (0)