Skip to content

Commit ac95d02

Browse files
committed
add local testing
1 parent 2852835 commit ac95d02

File tree

8 files changed

+516
-11
lines changed

8 files changed

+516
-11
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ publish = "build"
7676
[[plugins]]
7777
# local Cypress plugin will test our site after it is built
7878
package = "netlify-plugin-cypress"
79-
[plugins.config]
79+
[plugins.inputs]
8080
record = true
8181
```
8282

@@ -102,7 +102,7 @@ publish = "build"
102102
[[plugins]]
103103
# local Cypress plugin will test our site after it is built
104104
package = "netlify-plugin-cypress"
105-
[plugins.config]
105+
[plugins.inputs]
106106
spec = "cypress/integration/smoke*.js"
107107
```
108108

cypress.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"supportFile": false,
33
"pluginsFile": false,
4-
"fixturesFolder": false
4+
"fixturesFolder": false,
5+
"baseUrl": "http://localhost:5000"
56
}

cypress/integration/spec.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
/// <reference types="cypress" />
22
it('loads page', () => {
3-
if (Cypress.config('baseUrl')) {
4-
cy.visit('/')
5-
} else {
6-
cy.visit('public/index.html')
7-
}
3+
cy.visit('/')
84
cy.contains('Placeholder').should('be.visible')
95
})

index.js

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ module.exports = function cypressPlugin (pluginConfig) {
9393
onInit,
9494
postBuild: async (arg) => {
9595
debugVerbose('postBuild arg %o', arg)
96+
debug('cypress plugin postBuild inputs %o', arg.inputs)
9697

9798
const fullPublishFolder = arg.netlifyConfig.build.publish
9899
debug('folder to publish is "%s"', fullPublishFolder)

manifest.yml

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ inputs:
33
- name: record
44
default: false
55
- name: spec
6+
# tells the plugin how to start the server using custom command
7+
# and waiting for an url
8+
- name: preBuild

netlify.toml

+5
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ publish = "public"
1111
[[plugins]]
1212
# local Cypress plugin will test our site after it is built
1313
package = "."
14+
[plugins.inputs]
15+
spec = 'cypress/integration/spec.js'
16+
[plugins.inputs.preBuild]
17+
start = 'npm start'
18+
wait-on = 'http://localhost:5000'

0 commit comments

Comments
 (0)