Skip to content

Commit 79c8b5d

Browse files
bahmutoverezrokah
andauthored
feat: add option to use Chromium browser (#110) (#111)
Co-authored-by: Erez Rokah <[email protected]>
1 parent 6f111b6 commit 79c8b5d

File tree

12 files changed

+240
-72
lines changed

12 files changed

+240
-72
lines changed

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ And then add the plugin's name to the list of build plugins in `netlify.toml` fi
2020

2121
*note:* this plugin assumes you have already installed Cypress as a dev NPM dependency.
2222

23+
### Chromium install
24+
25+
This plugin installs [via Puppeteer](https://github.com/puppeteer/puppeteer) Chromium browser, which is also cached inside `./node_modules` folder.
26+
2327
## How does it work
2428

2529
When Netlify Build runs, it "knows" the output folder name and calls the `netlify-plugin-cypress` after the build has finished with that folder. Then the plugin runs Cypress tests using its [NPM module API](https://on.cypress.io/module-api). If the tests pass, the plugin finishes and the Netlify deploy starts.
@@ -173,6 +177,27 @@ package = "netlify-plugin-cypress"
173177

174178
See [cypress-example-kitchensink](https://github.com/cypress-io/cypress-example-kitchensink) for instance.
175179

180+
### Chromium
181+
182+
By default all tests run using built-in Electron browser. If you want to use Chromium:
183+
184+
```toml
185+
[build]
186+
command = "npm run build"
187+
publish = "build"
188+
[build.environment]
189+
# cache Cypress binary in local "node_modules" folder
190+
# so Netlify caches it
191+
CYPRESS_CACHE_FOLDER = "./node_modules/CypressBinary"
192+
# set TERM variable for terminal output
193+
TERM = "xterm"
194+
195+
[[plugins]]
196+
package = "netlify-plugin-cypress"
197+
[plugins.inputs]
198+
browser = "chromium"
199+
```
200+
176201
### testing SPA routes
177202

178203
SPAs need catch-all redirect setup to make non-root paths accesssible by tests. You can enable this with `spa` parameter.

circle.yml

+17
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,19 @@ jobs:
8989
environment:
9090
DEBUG: netlify-plugin-cypress
9191

92+
'test-using-chromium':
93+
executor: cypress/base-12-14-0
94+
steps:
95+
# all dependencies were installed in previous job
96+
- attach_workspace:
97+
at: ~/
98+
- run:
99+
name: Netlify Build 🏗
100+
command: npx netlify build
101+
working_directory: tests/use-chromium
102+
environment:
103+
DEBUG: netlify-plugin-cypress
104+
92105
routing:
93106
executor: cypress/base-12-14-0
94107
steps:
@@ -123,6 +136,9 @@ workflows:
123136
- 'test-prebuild-only':
124137
requires:
125138
- cypress/install
139+
- test-using-chromium:
140+
requires:
141+
- cypress/install
126142
- routing:
127143
requires:
128144
- cypress/install
@@ -134,6 +150,7 @@ workflows:
134150
- 'recording test'
135151
- 'test-twice'
136152
- 'test-prebuild-only'
153+
- test-using-chromium
137154
- 'routing'
138155
filters:
139156
branches:

manifest.yml

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ inputs:
1111
# by default run the tests
1212
- name: skip
1313
default: false
14+
# by default the tests run in Electron
15+
# but because of the dependency we download Chromium
16+
# so you can set "browser = electron"
17+
- name: browser
18+
default: electron
1419

1520
# tells the plugin how to start the server using custom command
1621
# and waiting for an url, record to the dashboard, tag, etc

netlify.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ publish = "public"
1010
[[plugins]]
1111
# local Cypress plugin will test our site after it is built
1212
package = "."
13-
# [plugins.inputs]
14-
# spec = 'cypress/integration/spec.js'
13+
[plugins.inputs]
14+
# browser = "electron"
15+
# spec = 'cypress/integration/spec.js'
1516
# [plugins.inputs.preBuild]
1617
# start = 'npm start'
1718
# wait-on = 'http://localhost:5000'

0 commit comments

Comments
 (0)