Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
[terra-functional-testing] Add useSeleniumStandalonService option (#646)
Browse files Browse the repository at this point in the history
* Add useSeleniumStandalonService option.

* Updated all misspellings of useSeleniumStandaloneService.

* Update packages/terra-functional-testing/src/terra-cli/wdio/index.js

Co-authored-by: Derek Yu <[email protected]>

Co-authored-by: Derek Yu <[email protected]>
  • Loading branch information
benbcai and yuderekyu authored May 6, 2021
1 parent 8f0b990 commit 129028f
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 3 deletions.
3 changes: 3 additions & 0 deletions packages/terra-functional-testing/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
* Fixed
* Update specPath in BaseCompare to replace `node_modules` with `tests/wdio`.

* Added
* Added useSeleniumStandaloneService option for using the standalone-chrome host instead of the selenium docker service when building in Jenkins.

## 1.2.0 - (April 23, 2021)

* Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ const getConfigurationOptions = (options) => {
suite,
theme,
updateScreenshots,
useSeleniumStandaloneService,
} = options;

return {
baseUrl: `http://${externalHost || getIpAddress()}:${externalPort || 8080}`,
capabilities: getCapabilities(browsers, !!gridUrl),
hostname: gridUrl || 'localhost',
hostname: gridUrl || (useSeleniumStandaloneService ? 'standalone-chrome' : 'localhost'),
port: gridUrl ? 80 : 4444,
launcherOptions: {
disableSeleniumService: disableSeleniumService || !!gridUrl,
disableSeleniumService: disableSeleniumService || useSeleniumStandaloneService || !!gridUrl,
formFactor,
gridUrl,
keepAliveSeleniumDockerService,
Expand Down
5 changes: 5 additions & 0 deletions packages/terra-functional-testing/src/terra-cli/wdio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ const cli = {
describe: 'Whether or not to automatically update all reference screenshots with the latest screenshots.',
default: false,
},
useSeleniumStandaloneService: {
type: 'boolean',
describe: 'A flag to use the selenium standalone service instead of the selenium docker service.',
default: process.env.USE_SELENIUM_STANDALONE_SERVICE === 'true',
},
})
),
handler: TestRunner.start,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class TestRunner {
* @param {array} options.suite - Overrides specs and runs only the defined suites.
* @param {string} options.theme - A theme for the test run.
* @param {boolean} options.updateScreenshots - Updates all reference screenshots with the latest screenshots.
* @param {boolean} options.useSeleniumStandaloneService - A flag to use the selenium standalone service instead of the selenium docker service.
* @returns {Promise} A promise that resolves with the test run exit code.
*/
static async run(options) {
Expand Down Expand Up @@ -86,6 +87,7 @@ class TestRunner {
* @param {array} options.suite - Overrides specs and runs only the defined suites.
* @param {string} options.themes - A list of themes for the test run.
* @param {boolean} options.updateScreenshots - Updates all reference screenshots with the latest screenshots.
* @param {boolean} options.useSeleniumStandaloneService - A flag to use the selenium standalone service instead of the selenium docker service.
*/
static async start(options) {
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('getCapabilities', () => {
suite: 'test-suite',
theme: 'terra-default-theme',
updateScreenshots: true,
useSeleniumStandaloneService: false,
};

const defaultWebpackPath = path.resolve(process.cwd(), 'webpack.config.js');
Expand Down Expand Up @@ -53,6 +54,55 @@ describe('getCapabilities', () => {
expect(config).toEqual(expectedConfig);
});

it('should get configuration with useSeleniumStandaloneService', async () => {
const options = {
assetServerPort: 8080,
browsers: ['chrome'],
config: '/path',
disableSeleniumService: false,
externalHost: 'externalHost',
externalPort: 3000,
formFactor: 'small',
keepAliveSeleniumDockerService: true,
locale: 'en',
site: 'build',
spec: '/spec/',
suite: 'test-suite',
theme: 'terra-default-theme',
updateScreenshots: true,
useSeleniumStandaloneService: true,
};

const defaultWebpackPath = path.resolve(process.cwd(), 'webpack.config.js');
const capabilities = getCapabilities(options.browsers, !!options.gridUrl);

const expectedConfig = {
baseUrl: `http://${options.externalHost}:${options.externalPort}`,
capabilities,
hostname: 'standalone-chrome',
port: 4444,
spec: options.spec,
suite: options.suite,
launcherOptions: {
disableSeleniumService: true,
formFactor: options.formFactor,
gridUrl: undefined,
keepAliveSeleniumDockerService: true,
locale: options.locale,
port: options.assetServerPort,
site: options.site,
theme: options.theme,
overrideTheme: options.theme,
updateScreenshots: true,
webpackConfig: defaultWebpackPath,
},
};

const config = getConfigurationOptions(options);

expect(config).toEqual(expectedConfig);
});

it('should get configuration with empty options', async () => {
const defaultWebpackPath = path.resolve(process.cwd(), 'webpack.config.js');
const capabilities = getCapabilities(undefined, !!undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ Options:
-u, --updateScreenshots Whether or not to automatically update
all reference screenshots with the
latest screenshots.
[boolean] [default: false]"
[boolean] [default: false]
--useSeleniumStandaloneService A flag to use the selenium standalone
service instead of the selenium docker
service. [boolean] [default: false]"
`;

exports[`index declares the wdio terra-cli command with proper top level help 1`] = `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ describe('Test Runner', () => {
suite: 'test-suite',
theme: 'terra-default-theme',
updateScreenshots: true,
useSeleniumStandaloneService: true,
};

await TestRunner.run(options);
Expand Down Expand Up @@ -176,6 +177,7 @@ describe('Test Runner', () => {
suite: 'test-suite',
themes: ['terra-default-theme'],
updateScreenshots: true,
useSeleniumStandaloneService: true,
});

expect(TestRunner.run).toHaveBeenCalledWith({
Expand All @@ -194,6 +196,7 @@ describe('Test Runner', () => {
suite: 'test-suite',
theme: 'terra-default-theme',
updateScreenshots: true,
useSeleniumStandaloneService: true,
});
});
});
Expand Down

0 comments on commit 129028f

Please sign in to comment.