-
Notifications
You must be signed in to change notification settings - Fork 15
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: support browser args #278
Open
NullVoxPopuli
wants to merge
1
commit into
CrowdStrike:main
Choose a base branch
from
NullVoxPopuli:allow-browser-args-forward
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ const { | |
} = require('./cp'); | ||
require('@faltest/utils/src/require-before-webdriverio'); | ||
const { remote } = require('webdriverio'); | ||
const path = require('path'); | ||
const psList = require('ps-list'); | ||
const fkill = require('fkill'); | ||
const getPort = require('get-port'); | ||
|
@@ -19,6 +20,9 @@ const { defaults } = require('@faltest/utils'); | |
// We aren't using `@wdio/cli` (wdio testrunner) | ||
process.env.SUPPRESS_NO_CONFIG_WARNING = 'true'; | ||
|
||
let configDir = process.env.FALTEST_CONFIG_DIR || process.cwd(); | ||
|
||
|
||
let port; | ||
|
||
const webDriverRegex = /^(chromedriver(?:\.exe)?|geckodriver)$/; | ||
|
@@ -163,7 +167,7 @@ async function spawnWebDriver(name, args) { | |
if (process.platform === 'win32') { | ||
let { emit } = webDriver; | ||
|
||
webDriver.emit = function(eventName, exitCode) { | ||
webDriver.emit = function (eventName, exitCode) { | ||
if (eventName === 'exit' && exitCode === 1) { | ||
return true; | ||
} | ||
|
@@ -179,6 +183,18 @@ async function spawnWebDriver(name, args) { | |
return webDriver; | ||
} | ||
|
||
function loadConfig() { | ||
try { | ||
return require(path.resolve(configDir, '.faltestrc.js')); | ||
} catch (err) { | ||
if (err.code !== 'MODULE_NOT_FOUND') { | ||
throw err; | ||
} | ||
|
||
return {}; | ||
} | ||
} | ||
|
||
function startWebDriver(options = {}) { | ||
return log(async () => { | ||
if (!yn(process.env.WEBDRIVER_DISABLE_CLEANUP)) { | ||
|
@@ -232,12 +248,20 @@ function stopWebDriver(webDriver) { | |
}); | ||
} | ||
|
||
async function getCapabilities({ | ||
customizeCapabilities = (browserName, capabilities) => capabilities, | ||
overrides: { | ||
browser: _browser = getDefaults().browser, | ||
} = {}, | ||
}) { | ||
async function getCapabilities(options) { | ||
NullVoxPopuli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let { | ||
browserArgs = [], | ||
NullVoxPopuli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
customizeCapabilities = (browserName, capabilities) => capabilities, | ||
overrides: { | ||
browser: _browser = getDefaults().browser, | ||
} = {}, | ||
} = options; | ||
|
||
let faltestConfig = loadConfig(); | ||
|
||
let argsFromConfig = (((faltestConfig.options || {}).browsers || {})[_browser] || {}).args || []; | ||
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. this is what my 'use strict';
module.exports = {
options: {
targets: {
default: 'default',
list: ['default', 'local', 'ember', 'pull-request'],
},
browsers: {
firefox: {
args: [
// TODO
],
},
chrome: {
args: [
'--window-size=1280,720', // 720p
'--ignore-certificate-errors'
].filter(Boolean)
}
}
},
globs: ['tests/**/*-test.js'],
}; |
||
|
||
|
||
let capabilities = { | ||
browserName: _browser, | ||
}; | ||
|
@@ -248,7 +272,7 @@ async function getCapabilities({ | |
|
||
switch (_browser) { | ||
case 'chrome': { | ||
let args = []; | ||
let args = [...browserArgs, ...argsFromConfig]; | ||
if (headless) { | ||
args.push('--headless'); | ||
} | ||
|
@@ -259,7 +283,7 @@ async function getCapabilities({ | |
break; | ||
} | ||
case 'firefox': { | ||
let args = []; | ||
let args = [...browserArgs, ...argsFromConfig]; | ||
if (headless) { | ||
args.push('-headless'); | ||
} | ||
|
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.
if interested, I could do another PR for adding prettier
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 wouldn't want this project to have a custom solution. I'd want everything to be in it's own package like https://github.com/CrowdStrike/eslint-config-crowdstrike, then appllied here and in other repos.