This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Pre cropped screenshots #177
Merged
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
e56bcab
Check firefox version before starting run
trotzig c9cd237
Limit screenshot to example box
trotzig 9ff6879
Work around marionette bug when closing geckodriver
trotzig f38fcc4
Ignore lib folder for import-js
trotzig a2a767f
Bump version to 4.0.0-beta.0
trotzig 0cecc80
Allow custom uploader
trotzig d44296c
Bump version to 4.0.0-beta.1
trotzig 90d68b5
Better explain screenshot div
trotzig 39dd22a
Remove export from addGeckoDriverToPath.js
trotzig 17d54bd
Move Constants.js to server folder
trotzig 17d91e7
Remove unused import in cli.js
trotzig 224a8e7
Use Firefox 50 in Travis
trotzig e16e311
Print full firefox version string when too old
trotzig 20eb9f5
Try different Firefox version for Travis
trotzig 270d66c
Stop using object-rest-spread
trotzig 6488f1b
Revert "Stop using object-rest-spread"
trotzig 59c6e3b
Add babel-transform-object-rest-spread
trotzig 510262a
Don't exlude node-modules from being transformed for Jest
trotzig 87211c8
Revert "Don't exlude node-modules from being transformed for Jest"
trotzig 69205b9
Update to jest 18
trotzig e8648eb
Drop support for Node 4 and 5
trotzig 75fbe34
Add .node-version file with 6.9.1
trotzig 46ee6f0
Update pngjs to v3
trotzig a31f2f4
Add `npm run babel` script
trotzig c474999
Remove inner `--silent` from npm scripts
trotzig 96a0245
Remove jest:watch script
trotzig 019abe8
Remove `npm run` from scripts
trotzig 897eb78
Mention geckodriver in README
trotzig 21178c9
Revert "Remove `npm run` from scripts"
trotzig 188c097
Bump version to 4.0.0-beta.2
trotzig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
jest.mock('child_process'); | ||
const childProcess = require('child_process'); | ||
|
||
jest.mock('../config'); | ||
const config = require('../config'); | ||
|
||
const checkBrowserVersion = require('../checkBrowserVersion'); | ||
|
||
beforeEach(() => { | ||
config.driver = 'firefox'; | ||
}); | ||
|
||
describe('when firefox is new enough', () => { | ||
beforeEach(() => { | ||
childProcess.exec = (_, cb) => cb(null, 'Mozilla Firefox 50.0'); | ||
}); | ||
|
||
it('resolves', () => | ||
checkBrowserVersion().then(() => { | ||
expect(true).toBe(true); | ||
})); | ||
}); | ||
|
||
describe('when firefox is too old', () => { | ||
beforeEach(() => { | ||
childProcess.exec = (_, cb) => cb(null, 'Mozilla Firefox 47.0'); | ||
}); | ||
|
||
it('rejects', () => | ||
checkBrowserVersion().catch((error) => { | ||
expect(error.message).toEqual( | ||
'Happo requires Firefox version 50 or later. You are using 47.0'); | ||
})); | ||
}); | ||
|
||
describe('when the version string is unrecognized', () => { | ||
beforeEach(() => { | ||
childProcess.exec = (_, cb) => cb(null, 'Godzilla Firefox 47.0'); | ||
}); | ||
|
||
it('rejects', () => | ||
checkBrowserVersion().catch((error) => { | ||
expect(error.message).toEqual( | ||
'Failed to parse Firefox version string "Godzilla Firefox 47.0"'); | ||
})); | ||
}); | ||
|
||
describe('when using a different driver', () => { | ||
beforeEach(() => { | ||
config.driver = 'chrome'; | ||
|
||
// Just to make sure that we're not falsely succeeding because of normal | ||
// handling, we also mock an old version of Firefox. | ||
childProcess.exec = (_, cb) => cb(null, 'Mozilla Firefox 47.0'); | ||
}); | ||
|
||
it('resolves', () => | ||
checkBrowserVersion().then(() => { | ||
expect(true).toBe(true); | ||
})); | ||
}); |
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,37 @@ | ||
const childProcess = require('child_process'); | ||
|
||
const firefox = require('selenium-webdriver/firefox'); | ||
|
||
const config = require('./config'); | ||
|
||
const MINIMUM_FIREFOX_VERSION = 50.0; | ||
const FIREFOX_VERSION_MATCHER = /Mozilla Firefox ([0-9.]+)/; | ||
|
||
module.exports = function checkBrowserVersion() { | ||
if (config.driver !== 'firefox') { | ||
// Our main browser target is Firefox. If you are using something else, you | ||
// must know what you are doing. :) | ||
return Promise.resolve(); | ||
} | ||
|
||
return new Promise((resolve, reject) => { | ||
new firefox.Binary().locate().then((pathToExecutable) => { | ||
childProcess.exec(`${pathToExecutable} --version`, (error, stdout) => { | ||
if (error) { | ||
reject(new Error(`Failed to check Firefox version: ${error}`)); | ||
return; | ||
} | ||
const match = stdout.match(FIREFOX_VERSION_MATCHER); | ||
if (!match) { | ||
reject(new Error(`Failed to parse Firefox version string "${stdout}"`)); | ||
} else if (parseFloat(match[1]) < MINIMUM_FIREFOX_VERSION) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am currently running Firefox 47.0.1. I think we should probably use something that can compare semver numbers to each other instead of just parseFloat. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can do that when we know we need to, right? For now, this should be enough I think. |
||
reject(new Error( | ||
`Happo requires Firefox version ${MINIMUM_FIREFOX_VERSION} or later. ` + | ||
`You are using ${match[1]}`)); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
}); | ||
}; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some Firefox versions end in
esr
(e.g.45.6.0esr
). It would be nice if the error message we generate includes this detail for maximum clarity.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we do, don't we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I was thinking of this line:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah - of course. yagni?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it is written, people will potentially see a misleading error message, which seems like it should be fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, you could make the error message less useful by not including the current version. That would be a strict improvement over giving potentially incorrect information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made it print the full string instead: e16e311