-
Notifications
You must be signed in to change notification settings - Fork 338
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
fix: Support FIREFOX_BINARY again for web-ext run
#523
Conversation
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.
This should use a unit test not a functional test
@@ -218,7 +218,7 @@ Example: $0 --help run. | |||
}) | |||
.command('run', 'Run the web extension', commands.run, { | |||
'firefox': { | |||
alias: 'f', | |||
alias: ['f', 'firefox-binary'], |
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.
looks good
@@ -47,3 +47,44 @@ describe('web-ext run', () => { | |||
}); | |||
})); | |||
}); | |||
|
|||
describe('web-ext run', () => { |
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.
Functional tests are very expensive because they take a lot longer than unit tests. Anytime we add a functional test we have to ask, can this be tested just as well in a unit test? For this case I think the answer is yes. You can make a test that passes in a stub version of the run
function and asserts --firefox-binary
is passed to the function like run({firefox: '/the/path/'})
. You can model it after this test: https://github.com/mozilla/web-ext/blob/master/tests/unit/test.program.js#L283-L294
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.
Doesn't this test do exactly that?
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.
No, that test does other things:
- It invokes the
cmd.run()
function directly so it doesn't cover any command line option parsing - It is making sure that the
firefoxApp
object (which represents the Firefox application process) is getting called correctly which is something separate
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.
The test needs some changes
@@ -307,6 +307,19 @@ describe('program.main', () => { | |||
process.cwd() + path.sep); | |||
}); | |||
}); | |||
it('passes the path of a firefox binary when specified', () => { |
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.
nit: this line should have one line of whitespace above it to show that it()
is a new function separate from the function above it
{commands: fakeCommands}) | ||
.then(() => { | ||
assert.equal(fakeCommands.run.called, true); | ||
assert.equal(fakeCommands.run.firstCall.args[0].firefoxBinary, |
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.
you should assert that the call to run()
passes firefox
, not firefoxBinary
because firefox is the variable used by the command.
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.
this test needs to make sure that --firefox-binary
gets treated just like --firefox
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.
Great, thanks
Fixes #512
firefox-binary