Skip to content

Commit

Permalink
Merge pull request #407 from angrykoala/dev
Browse files Browse the repository at this point in the history
2.5.1
  • Loading branch information
angrykoala authored Jul 27, 2019
2 parents a90413f + b79212a commit d4fc8cf
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 30 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ script:
- npm run tslint
- npm run markdown-lint
- travis_retry npm test

cache:
directories:
- node_modules
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2.5.1 / 2019-07-27
==================

* Puppeteer types updated
* TravisCI modules cache removed

2.5.0 / 2019-07-24
==================

Expand Down
26 changes: 13 additions & 13 deletions lib/browser/browser_core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export default abstract class BrowserCore {

protected _page: PuppeteerPage;
protected _context: PuppeteerContext;
protected originalHtml?: string;
protected settings: FinalBrowserSettings;
protected _originalHtml?: string;
protected _settings: FinalBrowserSettings;

private _loaded: boolean;
private _disabled: boolean;
Expand All @@ -51,13 +51,13 @@ export default abstract class BrowserCore {
constructor(context: PuppeteerContext, page: PuppeteerPage, settings: FinalBrowserSettings, components: Array<string> = []) {
this._page = page;
this._context = context;
this.settings = settings;
this._settings = settings;
this._loaded = false;
this.initialResponse = null;
this._disabled = false;
this._cache = settings.cache !== undefined ? settings.cache : true;
this._components = components;
if (this.settings.log) {
if (this._settings.log) {
this._page.on("console", pageLog);
}

Expand All @@ -67,8 +67,8 @@ export default abstract class BrowserCore {
const puppeteerPage = new PuppeteerPage(createdPage);
try {
await puppeteerPage.setBypassCSP(true);
if (this.settings.userAgent)
await puppeteerPage.setUserAgent(this.settings.userAgent);
if (this._settings.userAgent)
await puppeteerPage.setUserAgent(this._settings.userAgent);
} catch (err) {
// Will fail if browser is closed before finishing
}
Expand Down Expand Up @@ -99,7 +99,7 @@ export default abstract class BrowserCore {
}

public get incognito(): boolean {
return Boolean(this.settings.incognito);
return Boolean(this._settings.incognito);
}

public get cacheEnabled(): boolean {
Expand Down Expand Up @@ -143,7 +143,7 @@ export default abstract class BrowserCore {
this._disabled = true;
this._loaded = false;
this.initialResponse = null;
this.originalHtml = undefined;
this._originalHtml = undefined;
try {
await p;
await this._page.browser().close();
Expand Down Expand Up @@ -227,16 +227,16 @@ export default abstract class BrowserCore {
}

protected async _beforeClose(): Promise<void> {
this.settings.__onClose(this);
this._settings.__onClose(this);
if (!this._loaded) return Promise.resolve();
await this._callComponentsMethod("_beforeClose");
}

protected async _beforeOpen(options: OpenSettings): Promise<void> {
if (this.settings.userAgent) {
await this._page.setUserAgent(this.settings.userAgent);
if (this._settings.userAgent) {
await this._page.setUserAgent(this._settings.userAgent);
}
if (this.settings.bypassCSP) {
if (this._settings.bypassCSP) {
await this._page.setBypassCSP(true);
}
await this.setViewport(options.viewport);
Expand All @@ -246,7 +246,7 @@ export default abstract class BrowserCore {
protected async _afterPageLoad(): Promise<void> {
try {
const content = await this._page.content();
this.originalHtml = content;
this._originalHtml = content;
await this._addJsScripts();
} catch (err) {
if (err.message === "Evaluation failed: Event") {
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/mixins/browser_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default abstract class BrowserInfo extends BrowserClick {

@FailIfNotLoaded
public html(): string {
return this.originalHtml || "";
return this._originalHtml || "";
}

@FailIfNotLoaded
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/mixins/browser_wait.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default abstract class BrowserWait extends BrowserNavigation {
}

@FailIfNotLoaded
public async waitFor(selector: string | EvaluateFn, timeout = 500, ...args: Array<any>): Promise<void> {
public async waitFor(selector: EvaluateFn, timeout = 500, ...args: Array<any>): Promise<void> {
args = args.map((e) => {
if (e instanceof DomElement) return e.element;
else return e;
Expand Down
4 changes: 2 additions & 2 deletions lib/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export class AssertionError extends NativeAssertionError {
}

export class WendigoError extends Error {
protected fnName: string;
// protected _fnName: string;
public extraMessage: string;

constructor(fn: string, message: string) {
super(`[${fn}] ${message}`);
this.fnName = fn;
// this._fnName = fn;
this.extraMessage = message;
}

Expand Down
1 change: 1 addition & 0 deletions lib/modules/console/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ConsoleMessage, ConsoleMessageType } from '../../puppeteer_wrapper/pupp
export default class Log {
public message: ConsoleMessage;
public readonly text: string;

constructor(consoleMessage: ConsoleMessage, text?: string) {
this.message = consoleMessage;
this.text = text || consoleMessage.text();
Expand Down
1 change: 1 addition & 0 deletions lib/modules/requests/request_assertions_filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type PromiseExecutor<T> = (resolve: (value?: T | PromiseLike<T>) => void, reject

export default class RequestAssertionsFilter extends Promise<RequestAssertionsFilter> {
private _requestFilter: RequestFilter;

constructor(executor: PromiseExecutor<RequestAssertionsFilter>, requestFilter: RequestFilter) {
super((resolve, reject) => {
return executor(resolve, reject);
Expand Down
1 change: 1 addition & 0 deletions lib/modules/webworkers/webworker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Worker } from '../../puppeteer_wrapper/puppeteer_types';

export default class WebWoker {
public readonly worker: Worker;

constructor(ww: Worker) {
this.worker = ww;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/puppeteer_wrapper/puppeteer_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class PuppeteerPage {
this.page.off(eventName, cb);
}

public evaluateHandle(cb: EvaluateFn, ...args: Array<SerializableOrJSHandle>): Promise<JSHandle> {
public evaluateHandle(cb: ((...args: any[]) => any), ...args: Array<SerializableOrJSHandle>): Promise<JSHandle> {
return this.page.evaluateHandle(cb, ...args);
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wendigo",
"version": "2.5.0",
"version": "2.5.1",
"description": "A proper monster for front-end automated testing",
"engines": {
"node": ">=8.0.0"
Expand Down Expand Up @@ -47,7 +47,7 @@
"devDependencies": {
"@types/mocha": "^5.2.7",
"@types/node": "^12.6.8",
"@types/puppeteer": "^1.12.4",
"@types/puppeteer": "~1.19.0",
"basic-auth": "^2.0.1",
"eslint": "^6.1.0",
"express": "^4.17.1",
Expand Down
4 changes: 2 additions & 2 deletions tests/browser/incognito.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("Incognito", function() {
const browser = await Wendigo.createBrowser({incognito: true});
await browser.open(configUrls.simple);
await browser.assert.text("p", "html_test");
assert.strictEqual(browser.settings.incognito, true);
assert.strictEqual(browser._settings.incognito, true);
assert.strictEqual(browser.incognito, true);
await browser.close();
});
Expand All @@ -21,7 +21,7 @@ describe("Incognito", function() {
const browser = await Wendigo.createBrowser();
await browser.open(configUrls.simple);
await browser.assert.text("p", "html_test");
assert.strictEqual(browser.settings.incognito, false);
assert.strictEqual(browser._settings.incognito, false);
assert.strictEqual(browser.incognito, false);
await browser.close();
});
Expand Down
4 changes: 2 additions & 2 deletions tests/browser/open.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ describe("Open", function() {
assert.strictEqual(browser2.loaded, false);
await browser2.open(configUrls.index);
assert.strictEqual(browser2.loaded, true);
assert(browser2.originalHtml);
assert(browser2._originalHtml);
await browser2.close();
assert.strictEqual(browser2.loaded, false);
assert.strictEqual(browser2.originalHtml, undefined);
assert.strictEqual(browser2._originalHtml, undefined);
});

it("Open Fails CSP", async() => {
Expand Down
4 changes: 2 additions & 2 deletions tests/browser/wendigo_main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ describe("Wendigo Main", function() {

it("Change Browser Settings", async() => {
const browser1 = await Wendigo.createBrowser();
assert.strictEqual(browser1.settings.slowMo, 0);
assert.strictEqual(browser1._settings.slowMo, 0);
await browser1.close();
const browser2 = await Wendigo.createBrowser({slowMo: 1});
assert.strictEqual(browser2.settings.slowMo, 1);
assert.strictEqual(browser2._settings.slowMo, 1);
await browser2.close();
});

Expand Down

0 comments on commit d4fc8cf

Please sign in to comment.