Skip to content

Commit

Permalink
docs(cypress): update file config to latest cypress c… (#7733)
Browse files Browse the repository at this point in the history
docs(testing-with-cypress.md): update file config to latest cypress config filename
  • Loading branch information
ImBIOS authored Jun 5, 2023
1 parent d73812b commit 2318e44
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions docs/docs/guides/testing/testing-with-cypress.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,18 @@ Next you will have to create some configuration files for Cypress.

First, the primary cypress config:

```js title="cypress.json"
{
"baseUrl": "http://localhost:3000",
"chromeWebSecurity": false
}
```ts title="cypress.config.ts"
import { defineConfig } from 'cypress'

export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
chromeWebSecurity: false,
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
})
```

This initial Cypress config will tell Cypress where to find your site on initial launch as well as allow it to open up URLs at domains that aren't your page, for example to be able to login to a social provider.
Expand All @@ -46,14 +53,24 @@ You must change the login credentials you want to use, but you can also redefine

Third, if you're using the `cypress-social-login` plugin, you must add this to your `/cypress/plugins/index.js` file like so:

```js title="cypress/plugins/index.js"
const { GoogleSocialLogin } = require("cypress-social-logins").plugins
```js title="cypress.config.ts" {3-4,10-14}
import { defineConfig } from 'cypress'

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { GoogleSocialLogin } = require('cypress-social-logins').plugins

export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
chromeWebSecurity: false,
setupNodeEvents(on, config) {
on('task', {
GoogleSocialLogin,
})
},
},
})

module.exports = (on, config) => {
on("task", {
GoogleSocialLogin: GoogleSocialLogin,
})
}
```

Finally, you can also add the following npm scripts to your `package.json`:
Expand Down

1 comment on commit 2318e44

@vercel
Copy link

@vercel vercel bot commented on 2318e44 Jun 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.