Skip to content

Commit 5caafff

Browse files
authored
Merge pull request #469 from angrykoala/dev
2.13.2
2 parents 252e5a5 + a10ca7f commit 5caafff

File tree

11 files changed

+50
-35
lines changed

11 files changed

+50
-35
lines changed

.github/workflows/npm-publish.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@ on:
88
types: [published]
99

1010
jobs:
11-
build:
12-
runs-on: ubuntu-latest
13-
steps:
14-
- uses: actions/checkout@v2
15-
- uses: actions/setup-node@v1
16-
with:
17-
node-version: 12
18-
- run: npm ci
19-
- run: npm test
20-
2111
publish-npm:
2212
needs: build
2313
runs-on: ubuntu-latest
@@ -27,8 +17,13 @@ jobs:
2717
with:
2818
node-version: 12
2919
registry-url: https://registry.npmjs.org/
30-
- run: npm ci
31-
- run: npm publish
20+
- run: npm install
21+
- name: publish
22+
run: |
23+
sudo apt-get update
24+
sudo apt-get install -y libgbm-dev
25+
npm run lint
26+
npm publish
3227
env:
3328
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
3429

@@ -41,7 +36,12 @@ jobs:
4136
with:
4237
node-version: 12
4338
registry-url: https://npm.pkg.github.com/
44-
- run: npm ci
45-
- run: npm publish
39+
- run: npm install
40+
- name: publish
41+
run: |
42+
sudo apt-get update
43+
sudo apt-get install -y libgbm-dev
44+
npm run lint
45+
npm publish
4646
env:
4747
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2.13.2 / 2020-10-24
2+
===================
3+
4+
* Minor fix in Dockerfile
5+
* Puppeteer updated to 5.3.1
6+
* RegExp parameters checks fixed when using vm
7+
* Dependencies updated
8+
19
2.13.1 / 2020-08-08
210
===================
311

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,4 @@ RUN apt-get update && apt-get install -y -q --no-install-recommends\
4444
&& rm -rf /var/lib/apt/lists/*
4545

4646
ENV NO_SANDBOX=true
47-
ENV PUPPETEER_SKIP_DOWNLOAD=true
4847
RUN npm install wendigo && npm cache clean --force

lib/browser/mixins/browser_wait.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import isRegExp from 'lodash.isregexp';
12
import BrowserNavigation from './browser_navigation';
23
import DomElement from '../../models/dom_element';
34
import { TimeoutError, WendigoError, QueryError } from '../../models/errors';
@@ -62,7 +63,7 @@ export default abstract class BrowserWait extends BrowserNavigation {
6263
timeout = this._getTimeout(timeout);
6364
if (!url) return Promise.reject(new WendigoError("waitForUrl", `Invalid parameter url.`));
6465
let parsedUrl: string | RegExp | { source: string, flags: string } = url;
65-
if (url instanceof RegExp) {
66+
if (isRegExp(url)) {
6667
parsedUrl = {
6768
source: url.source,
6869
flags: url.flags

lib/modules/requests/request_filter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import isRegExp from 'lodash.isregexp';
12
import { Request, ResourceType } from '../../puppeteer_wrapper/puppeteer_types';
23
import { matchText } from '../../utils/utils';
34
import { ExpectedHeaders } from './types';
45

56
function processBody(body: string | RegExp | object): string | RegExp {
6-
if (typeof body === 'object' && !(body instanceof RegExp)) {
7+
if (typeof body === 'object' && !isRegExp(body)) {
78
return JSON.stringify(body);
89
} else return body;
910
}

lib/modules/requests/request_mock.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { EventEmitter } from 'events';
2+
import isRegExp from 'lodash.isregexp';
23
import { URL } from 'url';
34
import { Request } from '../../puppeteer_wrapper/puppeteer_types';
45

@@ -178,7 +179,7 @@ export default class RequestMock implements RequestMockInterface {
178179
}
179180

180181
private _parseUrlQueryString(url: string | RegExp): { [s: string]: string; } | undefined {
181-
if (url instanceof RegExp) return undefined;
182+
if (isRegExp(url)) return undefined;
182183
else {
183184
const parsedUrl = new URL(url);
184185
if (parsedUrl.search) {
@@ -188,7 +189,7 @@ export default class RequestMock implements RequestMockInterface {
188189
}
189190

190191
private _parseUrl(url: string | RegExp): string | RegExp {
191-
if (url instanceof RegExp) {
192+
if (isRegExp(url)) {
192193
return url;
193194
} else {
194195
const parsedUrl = new URL(url);

lib/modules/requests/request_mocker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import isRegExp from 'lodash.isregexp';
12
import { URL } from 'url';
23
import { parseQueryString, compareObjects, matchText } from '../../utils/utils';
34
import RequestMock from './request_mock';
@@ -91,7 +92,7 @@ export default class RequestMocker {
9192
if (existsPriority !== null) return existsPriority;
9293
const methodPriority = this._checkElementPriority(m1.method, m2.method);
9394
if (methodPriority !== null) return methodPriority;
94-
const urlPriority = this._checkElementPriority(!(m1.url instanceof RegExp), !(m2.url instanceof RegExp));
95+
const urlPriority = this._checkElementPriority(!isRegExp(m1.url), !isRegExp(m2.url));
9596
if (urlPriority !== null) return urlPriority;
9697
return Boolean(this._checkElementPriority(m1.queryString, m2.queryString));
9798
}

lib/puppeteer_wrapper/puppeteer_utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export async function stringifyLogText(log: ConsoleMessage): Promise<string> {
1111

1212
function stringifyLogArg(arg: JSHandle): Promise<string> {
1313
return arg.executionContext().evaluate(element => {
14-
if (typeof element === 'object' && !(element instanceof RegExp)) {
14+
if (typeof element === 'object' && !(element instanceof RegExp)) { // Executed inside context, lodash not available
1515
try {
1616
element = JSON.stringify(element);
1717
} catch (err) {

lib/utils/utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import isRegExp from 'lodash.isregexp';
12
import querystring from 'querystring';
23
import { URL } from 'url';
34

@@ -19,7 +20,7 @@ export function isXPathQuery(s: string): boolean {
1920
}
2021

2122
export function stringify(element: any): string {
22-
if (typeof element === 'object' && !(element instanceof RegExp)) {
23+
if (typeof element === 'object' && !isRegExp(element)) {
2324
element = JSON.stringify(element);
2425
}
2526
return String(element);
@@ -46,10 +47,10 @@ export function promiseOr(promises: Array<Promise<any>>): Promise<any> {
4647

4748
export function matchText(text: string | null | undefined, expected: string | RegExp): boolean {
4849
if (text === undefined || text === null) return false;
49-
if (expected instanceof RegExp) {
50+
if (isRegExp(expected)) {
5051
return expected.test(text);
5152
} else {
52-
return text === expected;
53+
return text === expected;
5354
}
5455
}
5556

package.json

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wendigo",
3-
"version": "2.13.1",
3+
"version": "2.13.2",
44
"description": "A proper monster for front-end automated testing",
55
"engines": {
66
"node": ">=8.0.0"
@@ -43,19 +43,21 @@
4343
"dependencies": {
4444
"compositer": "^1.3.6",
4545
"is-class": "0.0.9",
46-
"puppeteer": "~5.2.1"
46+
"lodash.isregexp": "^4.0.1",
47+
"puppeteer": "~5.4.0"
4748
},
4849
"devDependencies": {
49-
"@types/mocha": "^8.0.1",
50-
"@types/node": "^14.0.27",
51-
"@types/puppeteer": "~3.0.1",
50+
"@types/lodash.isregexp": "^4.0.6",
51+
"@types/mocha": "^8.0.3",
52+
"@types/node": "^14.14.2",
53+
"@types/puppeteer": "~3.0.2",
5254
"basic-auth": "^2.0.1",
53-
"eslint": "^7.6.0",
55+
"eslint": "^7.12.0",
5456
"express": "^4.17.1",
55-
"markdownlint-cli": "^0.23.2",
56-
"mocha": "^8.1.1",
57-
"sinon": "^9.0.2",
57+
"markdownlint-cli": "^0.24.0",
58+
"mocha": "^8.2.0",
59+
"sinon": "^9.2.0",
5860
"tslint": "^6.1.3",
59-
"typescript": "^3.9.7"
61+
"typescript": "^4.0.3"
6062
}
6163
}

tests/browser/evaluate.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"use strict";
22

3+
const isRegExp = require('lodash.isregexp');
34
const Wendigo = require('../..');
45
const DomElement = require('../../dist/lib/models/dom_element').default;
56
const assert = require('assert');
@@ -54,7 +55,7 @@ describe("Evaluate", function() {
5455
const result = await browser.evaluate(() => {
5556
return /aba/g;
5657
});
57-
assert.ok(result instanceof RegExp);
58+
assert.ok(isRegExp(result));
5859
assert.strictEqual(result.source, "aba");
5960
assert.strictEqual(result.flags, "g");
6061
});

0 commit comments

Comments
 (0)