Skip to content

Commit

Permalink
fix 'Testcafe wrongly shows "filter" warning' (close DevExpress#6620)
Browse files Browse the repository at this point in the history
  • Loading branch information
miherlosev committed Dec 23, 2021
1 parent 33c9876 commit 07bb793
Show file tree
Hide file tree
Showing 5 changed files with 372 additions and 338 deletions.
8 changes: 6 additions & 2 deletions src/configuration/configuration-base.ts
@@ -1,14 +1,15 @@
import { isAbsolute, extname } from 'path';
import { extname, isAbsolute } from 'path';
import debug from 'debug';
import JSON5 from 'json5';

import {
castArray,
cloneDeep,
isPlainObject,
mergeWith,
} from 'lodash';

import { stat, readFile } from '../utils/promisified-functions';
import { readFile, stat } from '../utils/promisified-functions';
import Option from './option';
import OptionSource from './option-source';
import resolvePathRelativelyCwd from '../utils/resolve-path-relatively-cwd';
Expand Down Expand Up @@ -268,6 +269,9 @@ export default class Configuration {
}

protected _addOverriddenOptionIfNecessary (value1: OptionValue, value2: OptionValue, source: OptionSource, optionName: string): void {
if (source === OptionSource.Default)
return;

if (value1 === void 0 || value2 === void 0 || value1 === value2 || source !== OptionSource.Configuration)
return;

Expand Down
1 change: 1 addition & 0 deletions src/configuration/default-values.ts
Expand Up @@ -20,6 +20,7 @@ export const DEFAULT_RETRY_TEST_PAGES = false;
export const DEFAULT_DISABLE_HTTP2 = false;
export const DEFAULT_PROXYLESS = false;
export const DEFAULT_SCREENSHOT_THUMBNAILS = true;
export const DEFAULT_FILTER_FN = null;

export const DEFAULT_TYPESCRIPT_COMPILER_OPTIONS: Dictionary<boolean | number> = {
experimentalDecorators: true,
Expand Down
1 change: 1 addition & 0 deletions src/configuration/option-source.ts
@@ -1,4 +1,5 @@
enum OptionSource {
Default = 'Default',
Configuration = 'Configuration',
Input = 'Input'
}
Expand Down
21 changes: 12 additions & 9 deletions src/configuration/testcafe-configuration.ts
Expand Up @@ -12,18 +12,20 @@ import resolvePathRelativelyCwd from '../utils/resolve-path-relatively-cwd';
import {
DEFAULT_APP_INIT_DELAY,
DEFAULT_CONCURRENCY_VALUE,
DEFAULT_SPEED_VALUE,
DEFAULT_TIMEOUT,
DEFAULT_SOURCE_DIRECTORIES,
DEFAULT_DEVELOPMENT_MODE,
DEFAULT_RETRY_TEST_PAGES,
DEFAULT_DISABLE_HTTP2,
DEFAULT_FILTER_FN,
DEFAULT_PROXYLESS,
DEFAULT_RETRY_TEST_PAGES,
DEFAULT_SCREENSHOT_THUMBNAILS,
DEFAULT_SOURCE_DIRECTORIES,
DEFAULT_SPEED_VALUE,
DEFAULT_TIMEOUT,
getDefaultCompilerOptions,
} from './default-values';

import OptionSource from './option-source';

import {
Dictionary,
FilterOption,
Expand Down Expand Up @@ -162,8 +164,8 @@ export default class TestCafeConfiguration extends Configuration {
return result;
}

private _prepareFlag (name: string): void {
const option = this._ensureOption(name, void 0, OptionSource.Configuration);
private _prepareFlag (name: string, source = OptionSource.Configuration): void {
const option = this._ensureOption(name, void 0, source);

option.value = !!option.value;
}
Expand All @@ -173,7 +175,7 @@ export default class TestCafeConfiguration extends Configuration {
}

private _prepareInitFlags (): void {
OPTION_INIT_FLAG_NAMES.forEach(name => this._prepareFlag(name));
OPTION_INIT_FLAG_NAMES.forEach(name => this._prepareFlag(name, OptionSource.Default));
}

private async _normalizeOptionsAfterLoad (): Promise<void> {
Expand All @@ -187,7 +189,7 @@ export default class TestCafeConfiguration extends Configuration {
}

private _prepareFilterFn (): void {
const filterOption = this._ensureOption(OPTION_NAMES.filter, null, OptionSource.Configuration);
const filterOption = this._ensureOption(OPTION_NAMES.filter, DEFAULT_FILTER_FN, OptionSource.Default);

if (!filterOption.value)
return;
Expand All @@ -200,7 +202,8 @@ export default class TestCafeConfiguration extends Configuration {
if (filterOptionValue.fixtureGrep)
filterOptionValue.fixtureGrep = getGrepOptions(OPTION_NAMES.filterFixtureGrep, filterOptionValue.fixtureGrep as string);

filterOption.value = getFilterFn(filterOption.value) as Function;
filterOption.value = getFilterFn(filterOption.value) as Function;
filterOption.source = OptionSource.Configuration;
}

private _ensureScreenshotOptions (): void {
Expand Down

0 comments on commit 07bb793

Please sign in to comment.