-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Taking screenshots in Electron and Chrome (#97)
* adding example * report image sizes after the test * capture more images * add badge to README * try 1280,1024 chrome size
- Loading branch information
Showing
10 changed files
with
1,900 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: example-chrome | ||
on: [push] | ||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v1 | ||
|
||
- name: Electron | ||
uses: ./ | ||
with: | ||
working-directory: examples/chrome | ||
|
||
# store screenshot captured during the test | ||
- uses: actions/upload-artifact@v1 | ||
with: | ||
name: screenshots-in-electron | ||
path: examples/chrome/cypress/screenshots | ||
|
||
- run: npx image-size cypress/screenshots/**/*.png | ||
working-directory: examples/chrome | ||
|
||
- name: Chrome | ||
uses: ./ | ||
with: | ||
working-directory: examples/chrome | ||
browser: chrome | ||
|
||
- uses: actions/upload-artifact@v1 | ||
with: | ||
name: screenshots-in-chrome | ||
path: examples/chrome/cypress/screenshots | ||
|
||
- run: npx image-size cypress/screenshots/**/*.png | ||
working-directory: examples/chrome | ||
|
||
- name: Chrome headless | ||
uses: ./ | ||
with: | ||
working-directory: examples/chrome | ||
browser: chrome | ||
headless: true | ||
|
||
- uses: actions/upload-artifact@v1 | ||
with: | ||
name: screenshots-in-headless-chrome | ||
path: examples/chrome/cypress/screenshots | ||
|
||
- run: npx image-size cypress/screenshots/**/*.png | ||
working-directory: examples/chrome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules/ | ||
cypress/videos/ | ||
examples/env/cypress/videos/ | ||
examples/*/cypress/videos | ||
examples/*/cypress/screenshots |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
it('works', () => { | ||
expect(42).to.equal(21 + 21) | ||
cy.visit('https://example.cypress.io') | ||
cy.screenshot('example', { capture: 'runner' }) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"fixturesFolder": false, | ||
"supportFile": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
it('works', () => { | ||
expect(42).to.equal(21 + 21) | ||
cy.visit('https://example.cypress.io') | ||
// runner includes the application in the viewport | ||
// and the reporter showing the command log | ||
cy.screenshot('runner', { capture: 'runner' }) | ||
// just the visible portion of the viewport | ||
cy.screenshot('viewport', { capture: 'viewport' }) | ||
// you can take the screenshot of the entire page | ||
// which will be stitched into one tall image | ||
cy.screenshot('fullPage', { capture: 'fullPage' }) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const os = require('os') | ||
module.exports = on => { | ||
on('before:browser:launch', (browser, launchOptions) => { | ||
console.log('before launching browser') | ||
console.log(browser) | ||
|
||
if (browser.name === 'chrome') { | ||
// https://www.ghacks.net/2013/10/06/list-useful-google-chrome-command-line-switches/ | ||
launchOptions.args.push('--window-size=1280,1024') | ||
|
||
console.log('chrome launch args:') | ||
console.log(launchOptions.args.join(os.EOL)) | ||
return launchOptions | ||
} | ||
}) | ||
} |
Oops, something went wrong.