Skip to content

Commit 27797bb

Browse files
authored
docs: remove unneeded module.exports in plugin examples (#5147)
1 parent b89f944 commit 27797bb

File tree

4 files changed

+133
-146
lines changed

4 files changed

+133
-146
lines changed

docs/api/plugins/after-run-api.mdx

+30-33
Original file line numberDiff line numberDiff line change
@@ -51,39 +51,36 @@ awaited before Cypress proceeds running your specs.
5151
:::cypress-config-plugin-example
5252

5353
```ts
54-
module.exports = (on, config) => {
55-
on('after:run', (results) => {
56-
// results will look something like this when run via `cypress run`:
57-
// {
58-
// totalDuration: 81,
59-
// totalSuites: 0,
60-
// totalTests: 1,
61-
// totalFailed: 0,
62-
// totalPassed: 1,
63-
// totalPending: 0,
64-
// totalSkipped: 0,
65-
// browserName: 'electron',
66-
// browserVersion: '59.0.3071.115',
67-
// osName: 'darwin',
68-
// osVersion: '16.7.0',
69-
// cypressVersion: '3.1.0',
70-
// config: {
71-
// projectId: '1qv3w7',
72-
// baseUrl: 'http://example.com',
73-
// viewportWidth: 1000,
74-
// viewportHeight: 660,
75-
// // ... more properties...
76-
// }
77-
// // ... more properties...
78-
// }
79-
// }
80-
81-
if (results) {
82-
// results will be undefined in interactive mode
83-
console.log(results.totalPassed, 'out of', results.totalTests, 'passed')
84-
}
85-
})
86-
}
54+
on('after:run', (results) => {
55+
// results will look something like this when run via `cypress run`:
56+
// {
57+
// totalDuration: 81,
58+
// totalSuites: 0,
59+
// totalTests: 1,
60+
// totalFailed: 0,
61+
// totalPassed: 1,
62+
// totalPending: 0,
63+
// totalSkipped: 0,
64+
// browserName: 'electron',
65+
// browserVersion: '59.0.3071.115',
66+
// osName: 'darwin',
67+
// osVersion: '16.7.0',
68+
// cypressVersion: '3.1.0',
69+
// config: {
70+
// projectId: '1qv3w7',
71+
// baseUrl: 'http://example.com',
72+
// viewportWidth: 1000,
73+
// viewportHeight: 660,
74+
// // ... more properties...
75+
// }
76+
// // ... more properties...
77+
// }
78+
// }
79+
if (results) {
80+
// results will be undefined in interactive mode
81+
console.log(results.totalPassed, 'out of', results.totalTests, 'passed')
82+
}
83+
})
8784
```
8885

8986
:::

docs/api/plugins/after-spec-api.mdx

+34-37
Original file line numberDiff line numberDiff line change
@@ -56,43 +56,40 @@ further specs if there are any.
5656
:::cypress-config-plugin-example
5757

5858
```javascript
59-
module.exports = (on, config) => {
60-
on('after:spec', (spec, results) => {
61-
// spec will look something like this:
62-
// {
63-
// name: 'login.cy.js',
64-
// relative: 'cypress/e2e/login.cy.js',
65-
// absolute: '/Users/janelane/my-app/cypress/e2e/login.cy.js',
66-
// }
67-
68-
// results will look something like this:
69-
// {
70-
// stats: {
71-
// suites: 0,
72-
// tests: 1,
73-
// passes: 1,
74-
// pending: 0,
75-
// skipped: 0,
76-
// failures: 0,
77-
// // ...more properties
78-
// }
79-
// reporter: 'spec',
80-
// tests: [
81-
// {
82-
// title: ['login', 'logs user in'],
83-
// state: 'passed',
84-
// body: 'function () {}',
85-
// // ...more properties...
86-
// }
87-
// ],
88-
// error: null,
89-
// video: '/Users/janelane/my-app/cypress/videos/login.cy.js.mp4',
90-
// screenshots: [],
91-
// // ...more properties...
92-
// }
93-
console.log('Finished running', spec.relative)
94-
})
95-
}
59+
on('after:spec', (spec, results) => {
60+
// spec will look something like this:
61+
// {
62+
// name: 'login.cy.js',
63+
// relative: 'cypress/e2e/login.cy.js',
64+
// absolute: '/Users/janelane/my-app/cypress/e2e/login.cy.js',
65+
// }
66+
// results will look something like this:
67+
// {
68+
// stats: {
69+
// suites: 0,
70+
// tests: 1,
71+
// passes: 1,
72+
// pending: 0,
73+
// skipped: 0,
74+
// failures: 0,
75+
// // ...more properties
76+
// }
77+
// reporter: 'spec',
78+
// tests: [
79+
// {
80+
// title: ['login', 'logs user in'],
81+
// state: 'passed',
82+
// body: 'function () {}',
83+
// // ...more properties...
84+
// }
85+
// ],
86+
// error: null,
87+
// video: '/Users/janelane/my-app/cypress/videos/login.cy.js.mp4',
88+
// screenshots: [],
89+
// // ...more properties...
90+
// }
91+
console.log('Finished running', spec.relative)
92+
})
9693
```
9794

9895
:::

docs/api/plugins/before-run-api.mdx

+60-64
Original file line numberDiff line numberDiff line change
@@ -46,70 +46,66 @@ awaited before Cypress proceeds running your specs.
4646
:::cypress-config-plugin-example
4747

4848
```ts
49-
module.exports = (on, config) => {
50-
on('before:run', (details) => {
51-
// details will look something like this when run via `cypress run`:
52-
// {
53-
// config: {
54-
// projectId: '12345',
55-
// baseUrl: 'http://example.com/',
56-
// viewportWidth: 1000,
57-
// viewportHeight: 660,
58-
// // ...more properties...
59-
// },
60-
// browser: {
61-
// name: 'electron',
62-
// version: '59.0.3071.115',
63-
// // ...more properties...
64-
// },
65-
// system: {
66-
// osName: 'darwin',
67-
// osVersion: '16.7.0',
68-
// }
69-
// cypressVersion: '6.1.0',
70-
// specs: [
71-
// {
72-
// name: 'login_cy.js',
73-
// relative: 'cypress/e2e/login_cy.js',
74-
// absolute: '/Users/janelane/app/cypress/e2e/login_cy.js',
75-
// },
76-
// // ... more specs
77-
// ],
78-
// specPattern: [
79-
// '**/*.cy.{js,jsx,ts,tsx}'
80-
// ],
81-
// parallel: false,
82-
// group: 'group-1',
83-
// tag: 'tag-1'
84-
// }
85-
86-
// details will look something like this when run via `cypress open`:
87-
// {
88-
// config: {
89-
// projectId: '12345',
90-
// baseUrl: 'http://example.com/',
91-
// viewportWidth: 1000,
92-
// viewportHeight: 660,
93-
// // ...more properties...
94-
// },
95-
// system: {
96-
// osName: 'darwin',
97-
// osVersion: '16.7.0',
98-
// }
99-
// cypressVersion: '7.0.0'
100-
// }
101-
102-
if (details.specs && details.browser) {
103-
// details.specs and details.browser will be undefined in interactive mode
104-
console.log(
105-
'Running',
106-
details.specs.length,
107-
'specs in',
108-
details.browser.name
109-
)
110-
}
111-
})
112-
}
49+
on('before:run', (details) => {
50+
// details will look something like this when run via `cypress run`:
51+
// {
52+
// config: {
53+
// projectId: '12345',
54+
// baseUrl: 'http://example.com/',
55+
// viewportWidth: 1000,
56+
// viewportHeight: 660,
57+
// // ...more properties...
58+
// },
59+
// browser: {
60+
// name: 'electron',
61+
// version: '59.0.3071.115',
62+
// // ...more properties...
63+
// },
64+
// system: {
65+
// osName: 'darwin',
66+
// osVersion: '16.7.0',
67+
// }
68+
// cypressVersion: '6.1.0',
69+
// specs: [
70+
// {
71+
// name: 'login_cy.js',
72+
// relative: 'cypress/e2e/login_cy.js',
73+
// absolute: '/Users/janelane/app/cypress/e2e/login_cy.js',
74+
// },
75+
// // ... more specs
76+
// ],
77+
// specPattern: [
78+
// '**/*.cy.{js,jsx,ts,tsx}'
79+
// ],
80+
// parallel: false,
81+
// group: 'group-1',
82+
// tag: 'tag-1'
83+
// }
84+
// details will look something like this when run via `cypress open`:
85+
// {
86+
// config: {
87+
// projectId: '12345',
88+
// baseUrl: 'http://example.com/',
89+
// viewportWidth: 1000,
90+
// viewportHeight: 660,
91+
// // ...more properties...
92+
// },
93+
// system: {
94+
// osName: 'darwin',
95+
// osVersion: '16.7.0',
96+
// }
97+
// cypressVersion: '7.0.0'
98+
// }
99+
if (details.specs && details.browser) {
100+
// details.specs and details.browser will be undefined in interactive mode
101+
console.log(
102+
'Running',
103+
details.specs.length,
104+
'specs in',
105+
details.browser.name
106+
)
107+
}
108+
})
113109
```
114110

115111
:::

docs/api/plugins/before-spec-api.mdx

+9-12
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,15 @@ awaited before Cypress proceeds running the spec.
4747
:::cypress-config-plugin-example
4848

4949
```ts
50-
module.exports = (on, config) => {
51-
on('before:spec', (spec) => {
52-
// spec will look something like this:
53-
// {
54-
// name: 'login.cy.js',
55-
// relative: 'cypress/e2e/login.cy.js',
56-
// absolute: '/Users/janelane/app/cypress/e2e/login.cy.js',
57-
// }
58-
59-
console.log('Running', spec.relative)
60-
})
61-
}
50+
on('before:spec', (spec) => {
51+
// spec will look something like this:
52+
// {
53+
// name: 'login.cy.js',
54+
// relative: 'cypress/e2e/login.cy.js',
55+
// absolute: '/Users/janelane/app/cypress/e2e/login.cy.js',
56+
// }
57+
console.log('Running', spec.relative)
58+
})
6259
```
6360

6461
:::

0 commit comments

Comments
 (0)