Skip to content

Commit

Permalink
introduce profileDirectory option in wdio-firefox-profile-servi… (#4250)
Browse files Browse the repository at this point in the history
  • Loading branch information
Unichron authored and christian-bromann committed Jul 25, 2019
1 parent b85a064 commit 3111840
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/wdio-firefox-profile-service/src/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ export default class FirefoxProfileLauncher {
return
}

this.profile = new Profile()
if(this.config.firefoxProfile.profileDirectory) {
this.profile = await promisify(Profile.copy)(this.config.firefoxProfile.profileDirectory)
} else {
this.profile = new Profile()
}

// Set preferences and proxy
this._setPreferences()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default jest.fn(() => ({
const FirefoxProfile = jest.fn(() => ({
setPreference : jest.fn(),
setProxy : jest.fn(),
updatePreferences : jest.fn(),
Expand All @@ -9,3 +9,9 @@ export default jest.fn(() => ({
cb(null, 'foobar')
}),
}))

FirefoxProfile.copy = jest.fn((profileDirectory, cb) => {
cb(null, new FirefoxProfile())
})

export default FirefoxProfile
17 changes: 17 additions & 0 deletions packages/wdio-firefox-profile-service/tests/launcher.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Launcher from '../src/launcher'
import FirefoxProfile from 'firefox-profile'

describe('Firefox profile service', () => {
describe('onPrepare', () => {
Expand Down Expand Up @@ -186,5 +187,21 @@ describe('Firefox profile service', () => {
expect(service.profile.setPreference).toHaveBeenCalledWith('browser.startup.homepage', 'https://webdriver.io')
expect(service.profile.updatePreferences).toHaveBeenCalled()
})

test('should load from directory if profileDirectory is set', async () => {
const config = {
firefoxProfile : {
profileDirectory: '/tmp/firefox-profile',
}
}
const capabilities = [{
browserName : 'firefox',
}]

const service = new Launcher()
await service.onPrepare(config, capabilities)

expect(FirefoxProfile.copy).toHaveBeenCalledWith(config.firefoxProfile.profileDirectory, expect.any(Function))
})
})
})

0 comments on commit 3111840

Please sign in to comment.