You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore(docs): Upgrade Cypress to v10 in E2E Testing (#36204)
* Upgraded Cypress to Version 10 (fixes#36097)
* Added chonges to example
* we -> you
* Update end-to-end-testing.md
* fix example
Co-authored-by: Lennart <lekoarts@gmail.com>
We also want the URLs used by `cy.visit()` or `cy.request()` to be prefixed, hence you have to create the file `cypress.json` at the root of your project with the following content:
16
+
You need to create a config file for Cypress at the root of the project called `cypress.config.js`. You can use it to preface the URLs used by `cy.visit()` or `cy.request` as well as set the folder the tests are in by adding the following:
17
17
18
-
```json:title=cypress.json
19
-
{
20
-
"baseUrl": "http://localhost:8000/"
21
-
}
18
+
```js:title=cypress.config.js
19
+
const { defineConfig } =require('cypress')
20
+
21
+
module.exports=defineConfig({
22
+
e2e: {
23
+
baseUrl:'http://localhost:8000',
24
+
specPattern:"cypress/e2e"
25
+
}
26
+
})
22
27
```
23
28
24
-
Last but not least you add additional scripts to your `package.json` to run Cypress:
29
+
You also need to add additional scripts to your `package.json` to run Cypress:
25
30
26
31
```json:title=package.json
27
32
{
@@ -37,7 +42,7 @@ Last but not least you add additional scripts to your `package.json` to run Cypr
37
42
38
43
Type `npm run test:e2e` in your command line and see Cypress running for the first time. A folder named `cypress` will be created at the root of your project and a new application window will pop up. [Cypress' getting started guide](https://docs.cypress.io/guides/getting-started/writing-your-first-test.html#) is a good start to learn how to write tests!
39
44
40
-
_Important note_: If you are running Gatsby with the `--https` flag, whether using your own or automatically generated certificates, you will also need to tell `start-server-and-test` to disable HTTPS certificate checks (otherwise it will wait forever and never actually launch Cypress. You do this by passing in an environmental variable: `START_SERVER_AND_TEST_INSECURE=1`. [start-server-and-test docs](https://github.com/bahmutov/start-server-and-test#disable-https-certificate-checks)).
45
+
**Please note:** If you are running Gatsby with the `--https` flag, whether using your own or automatically generated certificates, you will also need to tell `start-server-and-test` to disable HTTPS certificate checks (otherwise it will wait forever and never actually launch Cypress. You do this by passing in an environmental variable: `START_SERVER_AND_TEST_INSECURE=1`. [start-server-and-test docs](https://github.com/bahmutov/start-server-and-test#disable-https-certificate-checks)).
41
46
42
47
This means your `test:e2e` script would look like this:
43
48
@@ -75,26 +80,16 @@ To use cypress-axe, you have to install the `cypress-axe` and [axe-core](https:/
Then you add the `cypress-axe` and `@testing-library/cypress` commands in `cypress/support/index.js`:
83
+
Then you add the `cypress-axe` and `@testing-library/cypress` commands in `cypress/support/e2e.js`:
79
84
80
-
```js:title=cypress/support/index.js
81
-
import"./commands"
85
+
```js:title=cypress/support/e2e.js
82
86
//highlight-start
83
87
import"cypress-axe"
84
88
import"@testing-library/cypress/add-commands"
85
89
//highlight-end
86
90
```
87
91
88
-
Cypress will look for tests inside the `cypress/integration` folder, but you can change the default test folder if you want. Because you're writing end-to-end tests, create a new folder called `cypress/e2e`, and use it as your `integrationFolder` in your `cypress.json`:
Copy file name to clipboardexpand all lines: examples/using-cypress/gatsby-config.js
+1-27
Original file line number
Diff line number
Diff line change
@@ -4,31 +4,5 @@ module.exports = {
4
4
description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
5
5
author: `@gatsbyjs`,
6
6
},
7
-
plugins: [
8
-
`gatsby-plugin-react-helmet`,
9
-
{
10
-
resolve: `gatsby-source-filesystem`,
11
-
options: {
12
-
name: `images`,
13
-
path: `${__dirname}/src/images`,
14
-
},
15
-
},
16
-
`gatsby-transformer-sharp`,
17
-
`gatsby-plugin-sharp`,
18
-
{
19
-
resolve: `gatsby-plugin-manifest`,
20
-
options: {
21
-
name: `gatsby-starter-default`,
22
-
short_name: `starter`,
23
-
start_url: `/`,
24
-
background_color: `#663399`,
25
-
theme_color: `#663399`,
26
-
display: `minimal-ui`,
27
-
icon: `src/images/gatsby-icon.png`,// This path is relative to the root of the site.
28
-
},
29
-
},
30
-
// this (optional) plugin enables Progressive Web App + Offline functionality
31
-
// To learn more, visit: https://gatsby.dev/offline
0 commit comments