Skip to content

Commit f6a1de8

Browse files
bahmutovalexjfno1
andauthored
feat: add start option to post build (#151) (#171)
Co-authored-by: Alex Foster <[email protected]>
1 parent 9872894 commit f6a1de8

17 files changed

+905
-480
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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ jobs:
1212
- node/with-cache:
1313
steps:
1414
- run: npm ci
15+
- run:
16+
name: show package contents 📦
17+
command: npm pack --dry
1518

1619
release:
1720
executor:
@@ -105,6 +108,19 @@ jobs:
105108
environment:
106109
DEBUG: netlify-plugin-cypress
107110

111+
'test-postbuild-start':
112+
executor: cypress/base-12-14-0
113+
steps:
114+
# all dependencies were installed in previous job
115+
- attach_workspace:
116+
at: ~/
117+
- run:
118+
name: Netlify Build 🏗
119+
command: npm run netlify:build
120+
working_directory: tests/test-postbuild-start
121+
environment:
122+
DEBUG: netlify-plugin-cypress
123+
108124
'test-using-chromium':
109125
executor: cypress/base-12-14-0
110126
steps:
@@ -194,6 +210,9 @@ workflows:
194210
- 'test-prebuild-only':
195211
requires:
196212
- cypress/install
213+
- 'test-postbuild-start':
214+
requires:
215+
- cypress/install
197216
- test-using-chromium:
198217
requires:
199218
- cypress/install
@@ -217,6 +236,7 @@ workflows:
217236
- 'recording test'
218237
- 'test-twice'
219238
- 'test-prebuild-only'
239+
- 'test-postbuild-start'
220240
- test-using-chromium
221241
- test-netlify-dev
222242
- 'routing'

package.json

Lines changed: 7 additions & 1 deletion
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
},
@@ -16,7 +17,8 @@
1617
"author": "Gleb Bahmutov <[email protected]>",
1718
"files": [
1819
"manifest.yml",
19-
"src"
20+
"src",
21+
"!src/**/*.test.js"
2022
],
2123
"license": "ISC",
2224
"dependencies": {
@@ -41,6 +43,7 @@
4143
"node": ">=10.18.1"
4244
},
4345
"devDependencies": {
46+
"jest": "^24.9.0",
4447
"cypress": "6.8.0",
4548
"netlify-cli": "3.13.7",
4649
"prettier": "2.2.1",
@@ -61,5 +64,8 @@
6164
"prerelease": true
6265
}
6366
]
67+
},
68+
"jest": {
69+
"rootDir": "./src"
6470
}
6571
}

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)