Skip to content

Commit 1cdd244

Browse files
authored
Merge pull request #5 from cypress-io/add-spec-parameter
feat: add spec parameter
2 parents 8bae6b5 + 014e65d commit 1cdd244

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,31 @@ plugins:
6969
record: true
7070
```
7171

72+
### spec
73+
74+
Run only a single spec or specs matching a wildcard
75+
76+
```yaml
77+
# Netlify config file
78+
build:
79+
command: "npm run build"
80+
publish: "build"
81+
environment:
82+
# do not show Cypress installation progress messages
83+
CI: 1
84+
# cache Cypress binary in local "node_modules" folder
85+
# so Netlify caches it
86+
CYPRESS_CACHE_FOLDER: "./node_modules/CypressBinary"
87+
# set TERM variable for terminal output
88+
TERM: "xterm"
89+
90+
plugins:
91+
# local Cypress plugin will test our site after it is built
92+
- package: netlify-plugin-cypress
93+
config:
94+
spec: 'cypress/integration/smoke*.js'
95+
```
96+
7297
## Debugging
7398

7499
Set environment variable `DEBUG=netlify-plugin-cypress` to see the debug logs. To see even more information, set `DEBUG=netlify-plugin-cypress,netlify-plugin-cypress:verbose`

index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,18 @@ function serveFolder (folder, port) {
1111
return http.createServer(server).listen(port)
1212
}
1313

14-
async function runCypressTests (baseUrl, record) {
14+
async function runCypressTests (baseUrl, record, spec) {
1515
// we will use Cypress via its NPM module API
1616
// https://on.cypress.io/module-api
1717
const cypress = require('cypress')
1818

1919
console.log('running Cypress against url %s recording?', baseUrl, record)
20+
2021
return await cypress.run({
2122
config: {
22-
baseUrl
23+
baseUrl,
2324
},
25+
spec,
2426
record
2527
})
2628
}
@@ -46,7 +48,9 @@ module.exports = function cypressPlugin (pluginConfig) {
4648
typeof process.env.CYPRESS_RECORD_KEY === 'string' &&
4749
Boolean(pluginConfig.record)
4850
const baseUrl = `http://localhost:${port}`
49-
const results = await runCypressTests(baseUrl, record)
51+
const spec = pluginConfig.spec
52+
53+
const results = await runCypressTests(baseUrl, record, spec)
5054

5155
await new Promise((resolve, reject) => {
5256
server.close(err => {

0 commit comments

Comments
 (0)