diff --git a/CHANGELOG.md b/CHANGELOG.md index d9be028..19468dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [0.2.2](https://github.com/pimlie/tib/compare/v0.2.1...v0.2.2) (2019-03-20) + + +### Bug Fixes + +* **browserstack:** only set default os when not set ([3fa0322](https://github.com/pimlie/tib/commit/3fa0322)) + + + ## [0.2.1](https://github.com/pimlie/tib/compare/v0.2.0...v0.2.1) (2019-03-20) diff --git a/README.md b/README.md index b90e03c..ff130ea 100644 --- a/README.md +++ b/README.md @@ -35,12 +35,13 @@ also check [our e2e tests](./test/e2e) for more information ```js import { browser, commands: { Xvfb, BrowserStackLocal } } from 'tib' -describe('e2e', () => { +describe('my e2e test', () => { let myBrowser + beforeAll(async () => { - myBrowser = browser('windows 10/chrome 71/browserstack/local/1920x1080', { - xvfb: false, // if true then Xvfb is automatically started before the browser - // and the displayNum=99 added to the process.env + myBrowser = await browser('windows 10/chrome 71/browserstack/local/1920x1080', { + xvfb: false, // if true or undefined then Xvfb is automatically started before + // the browser and the displayNum=99 added to the process.env BrowserStackLocal: { start: true, // default, if false then call 'const pid = await BrowserStackLocal.start()' stop: true, // default, if false then call 'await BrowserStackLocal.stop(pid)' @@ -63,10 +64,6 @@ describe('e2e', () => { // IMPORTANT: if you use an (arrow) function then use // a block'ed body due to an upstream issue await page.runAsyncScript((path) => { - // this function is executed within the page context - // if you use features like Promises and are testing on - // older browsers make sure you have a polyfill already - // loaded return new Promise(resolve => { myRouter.on('navigationFinished', resolve) window.myRouter.navigate(path) @@ -75,11 +72,13 @@ describe('e2e', () => { } } } - }) + }, true) // autoStart, default True. If false you have to call browser.start() }) afterAll(() => { - await myBrowser.close() + if (myBrowser) { + await myBrowser.close() + } }) test('router', async () => { diff --git a/package.json b/package.json index df8eb17..dbf3aeb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tib", - "version": "0.2.1", + "version": "0.2.2", "description": "Easy e2e browser testing in Node", "main": "lib/index.js", "module": "src/index.js", diff --git a/src/browserstack/index.js b/src/browserstack/index.js index e94eae2..5b88fc8 100644 --- a/src/browserstack/index.js +++ b/src/browserstack/index.js @@ -12,7 +12,10 @@ export default class BrowserStackBrowser extends SeleniumLogging(SeleniumBrowser builder.usingServer('https://hub-cloud.browserstack.com/wd/hub') }) - this.setOS('windows', 10) + // set default os if user hasnt set anything + if (!config.browserConfig || !config.browserConfig.os) { + this.setOS('windows', 10) + } } getConfigProperty(property, capabilities = {}, defaulValue) { diff --git a/src/webpage.js b/src/webpage.js index 63bc272..cc72147 100644 --- a/src/webpage.js +++ b/src/webpage.js @@ -82,7 +82,7 @@ export default class Webpage { return this.runScript( /* istanbul ignore next */ - (selector, fn, args) => new (Function.bind.apply(Function, fn))().apply(null, [document.querySelector(selector)].concat(args)), + (selector, fn, args) => (new (Function.bind.apply(Function, fn))()).apply(null, [document.querySelector(selector)].concat(args)), selector, [null, ...parsedFn.args, parsedFn.body], args @@ -94,7 +94,7 @@ export default class Webpage { return this.runScript( /* istanbul ignore next */ - (selector, fn, args) => new (Function.bind.apply(Function, fn))().apply(null, [Array.prototype.slice.call(document.querySelectorAll(selector))].concat(args)), + (selector, fn, args) => (new (Function.bind.apply(Function, fn))()).apply(null, [Array.prototype.slice.call(document.querySelectorAll(selector))].concat(args)), selector, [null, ...parsedFn.args, parsedFn.body], args