-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat: allow open option to accept an object #2492
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2492 +/- ##
==========================================
+ Coverage 93.55% 93.57% +0.01%
==========================================
Files 34 34
Lines 1319 1322 +3
Branches 379 380 +1
==========================================
+ Hits 1234 1237 +3
Misses 83 83
Partials 2 2
Continue to review full report at Codecov.
|
Object.assign({}, argv, { | ||
open: { | ||
app: ['Google Chrome', '--incognito'], | ||
}, | ||
}), |
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.
Object.assign({}, argv, { | |
open: { | |
app: ['Google Chrome', '--incognito'], | |
}, | |
}), | |
{ | |
...argv, | |
open: { | |
app: ['Google Chrome', '--incognito'], | |
}, | |
}, |
test/server/utils/runOpen.test.js
Outdated
).then(() => { | ||
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot( | ||
`"Unable to open \\"https://example.com/index.html\\" in browser: \\"{\\"app\\":[\\"Google Chrome\\",\\"--incognito\\"]}\\". If you are running in a headless environment, please do not use the --open flag"` | ||
); |
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.
We need better test 😄
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 think the best way to test it is manually because even if I found a way to test chrome the chrome start name is different in operating systems ex :
from https://www.npmjs.com/package/open
The app name is platform dependent. Don't hard code it in reusable modules.
For example, Chrome is google chrome on macOS, google-chrome on Linux and chrome on Windows.
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.
maybe we can use other flag, not good idea keep errors in tests in that case
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.
@evilebottnawi what about replacing it with:
expect(opn).toBeCalledWith('https://example.com/index.html',{ app: ['Google Chrome', '--incognito'] });
This will assure that the right expected arguments has been passed to open
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.
Good idea 👍
expect(opn).toBeCalledWith('https://example.com/index.html', { | ||
wait: false, | ||
}); | ||
|
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.
Let's return warn check (logMock.warn
)
Object.assign( | ||
{}, |
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.
Don't need these lines.
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.
/cc @hiroppy
CI is failing. |
/cc @EslamHiko can you fix CI? |
@evilebottnawi Yes, I'll do it in another PR |
@EslamHiko we need fix CI problems in that PR 😄 |
It's related to |
/cc @hiroppy @evilebottnawi CI is green now 😅😅 ! |
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.
/cc @hiroppy
This should be documented opening as an issue for the same. |
For Bugs and Features; did you add new tests?
yes
Motivation / Use-Case
complete : #1770
Breaking Changes
no
Additional Info
I've tested it on ubuntu Linux with this config :