Skip to content

Commit

Permalink
Merge pull request #221 from angrykoala/dev
Browse files Browse the repository at this point in the history
1.4.1
  • Loading branch information
angrykoala authored Oct 13, 2018
2 parents c137a51 + a72be43 commit bc80e35
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 103 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ env:
- NO_SANDBOX=true

script:
# - travis_retry npm test
- npm test
- travis_retry npm test
- npm run lint

cache:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
1.4.1 / 2018-10-13
==================

* After Open hook

1.4.0 / 2018-10-09
==================

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,11 @@ class MyPlugin {
// close, keep in mind that this will only be called on browser.close and
// not on any page loading
}

_afterOpen() { // This hook will be called after the page is opened and _loaded
// You can use this hook to start performing actions with evaluate or
// adding custom scripts with this._browser.page.addScriptTag
}
}


Expand Down
27 changes: 16 additions & 11 deletions lib/browser_core.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"use strict";

const path = require('path');
const {FatalError} = require('./errors');
const {
FatalError
} = require('./errors');
const WendigoConfig = require('../config');
const DomElement = require('./models/dom_element');
const utils = require('./utils');
Expand All @@ -21,7 +23,7 @@ const defaultOpenOptions = {
function pageLog(log) {
utils.stringifyLogText(log).then(text => {
log._text = text;
console[log._type](log._text); // eslint-disable-line
console[log._type](log._text); // eslint-disable-line
});
}

Expand Down Expand Up @@ -93,10 +95,7 @@ module.exports = class BrowserCore {
}

_beforeClose() {
return Promise.all(this._components.map((c) => {
if (typeof this[c]._beforeClose === 'function')
return this[c]._beforeClose();
}));
return this._callComponentsMethod("_beforeClose");
}

_beforeOpen(options) {
Expand All @@ -106,10 +105,7 @@ module.exports = class BrowserCore {
}
return p.then(() => {
return this.setViewport(options.viewport).then(() => {
return Promise.all(this._components.map((c) => {
if (typeof this[c]._beforeOpen === 'function')
return this[c]._beforeOpen(options);
}));
return this._callComponentsMethod("_beforeOpen", options);
});
});
}
Expand All @@ -124,7 +120,9 @@ module.exports = class BrowserCore {
return this.page.content().then((content) => {
this._originalHtml = content;
return this._addJsScripts().then(() => {
this._loaded = true;
return this._callComponentsMethod("_afterOpen").then(() => {
this._loaded = true;
});
});
});
}
Expand All @@ -147,4 +145,11 @@ module.exports = class BrowserCore {
});
return Promise.all(promises);
}

_callComponentsMethod(method, options) {
return Promise.all(this._components.map((c) => {
if (typeof this[c][method] === 'function')
return this[c][method](options);
}));
}
};
4 changes: 3 additions & 1 deletion lib/models/request_mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ module.exports = class RequestMock {

onRequest(request) {
this._requestsReceived.push(request);
this._events.emit("on-request");
setTimeout(() => {
this._events.emit("on-request");
}, 1);
if (this.auto && this.immediate) {
return request.respond(this.response);
} else if (this.auto) {
Expand Down
138 changes: 53 additions & 85 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wendigo",
"version": "1.4.0",
"version": "1.4.1",
"description": "A proper monster for front-end automated testing",
"engines": {
"node": ">=8.0.0"
Expand Down Expand Up @@ -42,8 +42,8 @@
"puppeteer": "~1.9.0"
},
"devDependencies": {
"eslint": "^5.6.1",
"express": "^4.16.3",
"eslint": "^5.7.0",
"express": "^4.16.4",
"mocha": "^5.2.0"
}
}
Loading

0 comments on commit bc80e35

Please sign in to comment.