Skip to content

Commit cbb8870

Browse files
alexjfno1bahmutov
andauthored
feat: add start option to post build (#151)
Co-authored-by: Gleb Bahmutov <[email protected]>
1 parent 9872894 commit cbb8870

File tree

17 files changed

+900
-479
lines changed

17 files changed

+900
-479
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ node_modules/
22
**/cypress/screenshots
33
**/cypress/videos
44
build
5+
.DS_Store
56

67
# Local Netlify folder
78
.netlify

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ See [netlify-plugin-prebuild-example](https://github.com/cypress-io/netlify-plug
280280

281281
### testing the site after build
282282

283-
By default this plugin tests static site _after deploy_. But maybe you want to run end-to-end tests locally after building the static site. Cypress includes a local static server for this case. Here is a sample config file
283+
By default this plugin tests static site _after deploy_. But maybe you want to run end-to-end tests locally after building the static site. Cypress includes a local static server for this case but you can specify your own command if needed by using the `start` argument. Here is a sample config file
284284

285285
```toml
286286
[[plugins]]
@@ -290,7 +290,7 @@ By default this plugin tests static site _after deploy_. But maybe you want to r
290290
enable = true
291291
```
292292

293-
Parameters you can place into `postBuild` inputs: `spec`, `record`, `group`, `tag`, and `spa`.
293+
Parameters you can place into `postBuild` inputs: `spec`, `record`, `group`, `tag`, `start` and `spa`.
294294

295295
#### The SPA parameter
296296

@@ -306,6 +306,7 @@ If your site requires all unknown URLs to redirect back to the index page, use t
306306
# so that client-side routing can correctly route them
307307
# can be set to true or "index.html" (or similar fallback filename in the built folder)
308308
spa = true
309+
start = 'npm start'
309310
```
310311

311312
See [the routing example](./tests/routing/netlify.toml).

circle.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,19 @@ jobs:
105105
environment:
106106
DEBUG: netlify-plugin-cypress
107107

108+
'test-postbuild-start':
109+
executor: cypress/base-12-14-0
110+
steps:
111+
# all dependencies were installed in previous job
112+
- attach_workspace:
113+
at: ~/
114+
- run:
115+
name: Netlify Build 🏗
116+
command: npm run netlify:build
117+
working_directory: tests/test-postbuild-start
118+
environment:
119+
DEBUG: netlify-plugin-cypress
120+
108121
'test-using-chromium':
109122
executor: cypress/base-12-14-0
110123
steps:
@@ -194,6 +207,9 @@ workflows:
194207
- 'test-prebuild-only':
195208
requires:
196209
- cypress/install
210+
- 'test-postbuild-start':
211+
requires:
212+
- cypress/install
197213
- test-using-chromium:
198214
requires:
199215
- cypress/install
@@ -217,6 +233,7 @@ workflows:
217233
- 'recording test'
218234
- 'test-twice'
219235
- 'test-prebuild-only'
236+
- 'test-postbuild-start'
220237
- test-using-chromium
221238
- test-netlify-dev
222239
- 'routing'

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"main": "src",
77
"scripts": {
88
"test": "cypress run",
9+
"test:unit": "jest",
910
"semantic-release": "semantic-release",
1011
"start": "serve public"
1112
},
@@ -41,6 +42,7 @@
4142
"node": ">=10.18.1"
4243
},
4344
"devDependencies": {
45+
"jest": "^24.9.0",
4446
"cypress": "6.8.0",
4547
"netlify-cli": "3.13.7",
4648
"prettier": "2.2.1",
@@ -61,5 +63,8 @@
6163
"prerelease": true
6264
}
6365
]
66+
},
67+
"jest": {
68+
"rootDir": "./src"
6469
}
6570
}

src/constants.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
PLUGIN_NAME: 'netlify-plugin-cypress',
3+
DEFAULT_BROWSER: 'chromium',
4+
}

0 commit comments

Comments
 (0)