Skip to content

Commit

Permalink
fix: SkipJsErrors RegExp parsed incorrectly when enclosed in quotes(c…
Browse files Browse the repository at this point in the history
…loses DevExpress#7301)
  • Loading branch information
Artem-Babich committed Oct 4, 2022
1 parent 968ae65 commit 07021b7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/utils/make-reg-exp.js
Expand Up @@ -9,7 +9,7 @@ export function parseRegExpString (regExp) {
const parsedRegExpWithFlags = regExp.match(SPLIT_INPUT_AND_FLAGS_REG_EXP);

if (parsedRegExpWithFlags)
return makeRegExp(parsedRegExpWithFlags[1], parsedRegExpWithFlags[2]);
return RegExp(parsedRegExpWithFlags[1], parsedRegExpWithFlags[2]);

return makeRegExp(regExp);
}
Expand Down
4 changes: 4 additions & 0 deletions test/functional/fixtures/page-js-errors/test.js
Expand Up @@ -102,6 +102,10 @@ const expectFailAttempt = (errors, expectedMessage) => {
return runTests('./testcafe-fixtures/test-controller.js', 'Should skip JS errors with SkipJsErrorsCallbackOptions');
});

it('Should skip JS errors with SkipJsErrorsCallbackOptions containing RegExp enclosed in quotes', async () => {
return runTests('./testcafe-fixtures/test-controller.js', 'Should skip JS errors with SkipJsErrorsCallbackOptions containing RegExp enclosed in quotes');
});

it('Should skip JS errors with callback function returning Promise', async () => {
return runTests('./testcafe-fixtures/test-controller.js', 'Should skip JS errors with callback function returning Promise', { skip: ['ie'] });
});
Expand Down
@@ -1,4 +1,10 @@
const { CLIENT_ERROR_MESSAGE, CLIENT_PAGE_URL, CLIENT_PAGE_URL_REGEXP, SKIP_JS_ERRORS_CALLBACK_OPTIONS } = require('../constants');
const {
CLIENT_ERROR_MESSAGE,
CLIENT_PAGE_URL,
CLIENT_PAGE_URL_REGEXP,
SKIP_JS_ERRORS_CALLBACK_OPTIONS,
CLIENT_ERROR_REGEXP,
} = require('../constants');

fixture`TestController method`
.page('http://localhost:3000/fixtures/page-js-errors/pages/skip-js-errors.html');
Expand All @@ -22,7 +28,7 @@ test('Should skip JS errors with SkipJsErrorsCallbackOptions', async t => {
});

test('Should skip JS errors with callback function returning Promise', async t => {
const asyncFunc = () =>
const asyncFunc = () =>
new Promise(resolve => setTimeout(() => resolve(true), 3000));

await t.skipJsErrors(asyncFunc)
Expand All @@ -33,6 +39,13 @@ test('Should skip JS errors without param', async t => {
await t.skipJsErrors();
});

test('Should skip JS errors with SkipJsErrorsCallbackOptions containing RegExp enclosed in quotes', async t => {
await t.skipJsErrors({
message: `${ CLIENT_ERROR_REGEXP }`,
})
.click('button');
});

test('Should correctly skip JS errors with multiple method calls', async t => {
await t.skipJsErrors(true)
.click('button')
Expand Down

0 comments on commit 07021b7

Please sign in to comment.