Skip to content

feat: add start option to post build #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node_modules/
**/cypress/screenshots
**/cypress/videos
build
.DS_Store

# Local Netlify folder
.netlify
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ See [netlify-plugin-prebuild-example](https://github.com/cypress-io/netlify-plug

### testing the site after build

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
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

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

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

#### The SPA parameter

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

See [the routing example](./tests/routing/netlify.toml).
Expand Down
17 changes: 17 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,19 @@ jobs:
environment:
DEBUG: netlify-plugin-cypress

'test-postbuild-start':
executor: cypress/base-12-14-0
steps:
# all dependencies were installed in previous job
- attach_workspace:
at: ~/
- run:
name: Netlify Build 🏗
command: npm run netlify:build
working_directory: tests/test-postbuild-start
environment:
DEBUG: netlify-plugin-cypress

'test-using-chromium':
executor: cypress/base-12-14-0
steps:
Expand Down Expand Up @@ -194,6 +207,9 @@ workflows:
- 'test-prebuild-only':
requires:
- cypress/install
- 'test-postbuild-start':
requires:
- cypress/install
- test-using-chromium:
requires:
- cypress/install
Expand All @@ -217,6 +233,7 @@ workflows:
- 'recording test'
- 'test-twice'
- 'test-prebuild-only'
- 'test-postbuild-start'
- test-using-chromium
- test-netlify-dev
- 'routing'
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"main": "src",
"scripts": {
"test": "cypress run",
"test:unit": "jest",
"semantic-release": "semantic-release",
"start": "serve public"
},
Expand Down Expand Up @@ -41,6 +42,7 @@
"node": ">=10.18.1"
},
"devDependencies": {
"jest": "^24.9.0",
"cypress": "6.8.0",
"netlify-cli": "3.13.7",
"prettier": "2.2.1",
Expand All @@ -61,5 +63,8 @@
"prerelease": true
}
]
},
"jest": {
"rootDir": "./src"
}
}
4 changes: 4 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
PLUGIN_NAME: 'netlify-plugin-cypress',
DEFAULT_BROWSER: 'chromium',
}
Loading