Skip to content

Commit

Permalink
fixed multiremote in wdio runner
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Jan 24, 2016
1 parent 4d26f45 commit bbbac44
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 8 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"it": true,
"should": true,
"browser": true,
"browserA": true,
"mock": true
}
}
15 changes: 11 additions & 4 deletions lib/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ class Launcher {
* if it is an object run multiremote test
*/
if (this.isMultiremote()) {
return this.startInstance(this.configParser.getSpecs(), caps)
let exitCode = await new Promise((resolve) => {
this.resolve = resolve
this.startInstance(this.configParser.getSpecs(), 0)
})

return exitCode
}

/**
Expand All @@ -143,7 +148,7 @@ class Launcher {
*/
process.stdin.resume()

let exitCode = await new Promise((resolve, reject) => {
let exitCode = await new Promise((resolve) => {
this.resolve = resolve
this.runSpecs()
})
Expand Down Expand Up @@ -243,8 +248,10 @@ class Launcher {
this.exitCode = this.exitCode || childProcessExitCode

// Update schedule now this process has ended
this.schedule[cid].availableInstances++
this.schedule[cid].runningInstances--
if (!this.isMultiremote()) {
this.schedule[cid].availableInstances++
this.schedule[cid].runningInstances--
}

if (!this.isMultiremote() && !this.runSpecs()) {
return
Expand Down
9 changes: 5 additions & 4 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,14 @@ class Runner {
return remote(config)
}

let options = capabilities
for (let browserName of Object.keys(options)) {
options[browserName] = merge(config, options[browserName])
let options = {}
for (let browserName of Object.keys(capabilities)) {
options[browserName] = merge(config, capabilities[browserName])
options[browserName].desiredCapabilities = capabilities[browserName]
}

let browser = multiremote(options)
for (let browserName of Object.keys(options)) {
for (let browserName of Object.keys(capabilities)) {
global[browserName] = browser.select(browserName)
}
return browser
Expand Down
28 changes: 28 additions & 0 deletions test/fixtures/multiremote.wdio.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var chai = require('chai')
var chaiString = require('chai-string')
var chaiAsPromised = require('chai-as-promised')

exports.config = {
baseUrl: 'http://127.0.0.1:8080',
capabilities: {
browserA: {
browserName: 'phantomjs'
},
browserB: {
browserName: 'phantomjs'
}
},
framework: 'mocha',
specs: [__dirname + '/specs/multiremote.spec.js'],
mochaOpts: {
compilers: ['js:babel/register'],
timeout: 60000
},
before: function () {
chai.should()
chai.use(chaiString)
chai.use(chaiAsPromised)
global.assert = chai.assert
global.expect = chai.expect
}
}
12 changes: 12 additions & 0 deletions test/fixtures/specs/multiremote.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import conf from '../../conf/index'

describe('multiremote', () => {
it('should grab different titles', () => {
browser.url('/')
browserA.url('/two.html')

let title = browser.sync().getTitle()
expect(title.browserA).to.be.equal('two')
expect(title.browserB).to.be.equal(conf.testPage.title)
})
})
11 changes: 11 additions & 0 deletions test/spec/wdio/multiremote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import path from 'path'
import Launcher from '../../../build/lib/launcher'

const FIXTURE_ROOT = path.join(__dirname, '..', '..', 'fixtures')

describe('wdio multiremote', () => {
it('should be able to run multiremote tests', async function () {
let launcher = new Launcher(path.join(FIXTURE_ROOT, 'multiremote.wdio.conf'), {})
expect(await launcher.run()).to.be.equal(0, 'wdio command failed unexpected')
})
})

0 comments on commit bbbac44

Please sign in to comment.