Skip to content

Commit

Permalink
add specific preprocessor version, improve copy, and add headers
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbreiding committed Oct 19, 2022
1 parent 590ce26 commit 42354f2
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions content/api/commands/origin.md
Original file line number Diff line number Diff line change
Expand Up @@ -513,16 +513,24 @@ and/or
can be used within the callback to include [npm](https://www.npmjs.com/)
packages and other files.

If you utilize a custom preprocessor, note that this feature requires the latest
version of
[`@cypress/webpack-preprocessor`](https://github.com/cypress-io/cypress/tree/master/npm/webpack-preprocessor)
to work. If using a custom preprocessor or an older version of the webpack
preprocessor, you'll see an error that includes the following text:
<Alert type="warning">

```
Using require() or import() to include dependencies requires using the
latest version of @cypress/webpack-preprocessor.
```
Using `import()` and `require()` within the callback requires version 5.15.0 or
greater of the
[`@cypress/webpack-preprocessor`](https://github.com/cypress-io/cypress/tree/master/npm/webpack-preprocessor).
This is included in Cypress by default, but if your project installs its own
version of `@cypress/webpack-preprocessor` that is set up in your Cypress
config, make sure it is version 5.15.0 or greater.

If using an older version of the webpack or a different preprocessor, you'll see
an error that includes the following text:

_Using require() or import() to include dependencies requires using the latest
version of @cypress/webpack-preprocessor._

</Alert>

#### Example

```js
// ES modules
Expand All @@ -542,6 +550,8 @@ cy.origin('somesite.com', () => {
})
```

#### Custom commands

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

#### Shared execution context

The JavaScript execution context is persisted between `cy.origin()` callbacks
that share the same origin. This can be utilized to share code between
successive `cy.origin()` calls.
Expand Down

0 comments on commit 42354f2

Please sign in to comment.