Skip to content

Commit

Permalink
Boolean highlightOnAction (#2584)
Browse files Browse the repository at this point in the history
  • Loading branch information
lufton authored May 27, 2022
1 parent 359720d commit 9b59e2e
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
8 changes: 6 additions & 2 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ const defaultConfig = {
highlightOnAction:
process.env.TAIKO_BROWSER_PATH &&
process.env.TAIKO_BROWSER_PATH.toLowerCase().includes('firefox')
? 'false'
: process.env.TAIKO_HIGHLIGHT_ON_ACTION || 'true',
? false
:
(process.env.TAIKO_HIGHLIGHT_ON_ACTION
? (process.env.TAIKO_HIGHLIGHT_ON_ACTION.toLowerCase() === 'true')
: true
),
blockAlignment: 'nearest',
inlineAlignment: 'nearest',
useHostName: false,
Expand Down
2 changes: 1 addition & 1 deletion lib/elements/elementHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { wait } = require('../helper');

const highlightElement = async (element) => {
// Adding a wait as tests fail on newer versions of chrome
if (defaultConfig.highlightOnAction.toLowerCase() !== 'true') {
if (!defaultConfig.highlightOnAction) {
await wait(1000);
return
}
Expand Down
2 changes: 1 addition & 1 deletion lib/taiko.js
Original file line number Diff line number Diff line change
Expand Up @@ -2520,7 +2520,7 @@ module.exports.getConfig = getConfig;
* 'networkIdle', 'firstPaint', 'firstContentfulPaint', 'firstMeaningfulPaint', 'targetNavigated']
* @param {boolean} [options.ignoreSSLErrors = true ] Option to ignore SSL errors encountered by the browser.
* @param {boolean} [options.headful = false ] Option to open browser in headless/headful mode.
* @param {string} [options.highlightOnAction = 'false' ] Option to highlight an element on action.
* @param {boolean} [options.highlightOnAction = false ] Option to highlight an element on action.
*/
module.exports.setConfig = setConfig;

Expand Down
4 changes: 2 additions & 2 deletions test/unit-tests/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Config tests', () => {
it('should update the config', () => {
const newConfig = {
headful: false,
highlightOnAction: 'true',
highlightOnAction: true,
firefox: false,
ignoreSSLErrors: true,
navigationTimeout: 2,
Expand Down Expand Up @@ -238,7 +238,7 @@ describe('Config tests', () => {
};
const expectedConfig = {
headful: true,
highlightOnAction: 'true',
highlightOnAction: true,
ignoreSSLErrors: true,
firefox: false,
navigationTimeout: 30000,
Expand Down
4 changes: 2 additions & 2 deletions test/unit-tests/elements/elementHelper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('elementHelper', () => {
});
actualConsole = console;
elemHelper.__set__('console', { warn: (warning) => (warningMessage = warning) });
setConfig({ highlightOnAction: 'true' });
setConfig({ highlightOnAction: true });
});

afterEach(() => {
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('elementHelper', () => {
});

it('should not highlight when highlightOnAction is false', async () => {
setConfig({ highlightOnAction: 'false' });
setConfig({ highlightOnAction: false });
await elemHelper.highlightElement(createElement(20, true));

expect(getBoxModelCalled).to.be.false;
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests/test-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ module.exports.resetConfig = () => {
waitForNavigation: true,
ignoreSSLErrors: true,
headful: false,
highlightOnAction: 'true',
highlightOnAction: true,
});
};
2 changes: 1 addition & 1 deletion types/taiko/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export interface GlobalConfigurationOptions {
headful?: boolean;
criConnectionRetries?: number;
firefox?: boolean;
highlightOnAction?: 'true' | 'false';
highlightOnAction?: boolean;
local?: boolean;
}

Expand Down
2 changes: 1 addition & 1 deletion types/taiko/test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ setConfig({
waitForNavigation: true,
ignoreSSLErrors: true,
headful: false,
highlightOnAction: 'false',
highlightOnAction: false,
});
setConfig({});
setConfig({ other: true }); // $ExpectError
Expand Down

0 comments on commit 9b59e2e

Please sign in to comment.