Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow calling setPath('userData', path) before app.start() #202

Closed
DutchKevv opened this issue May 30, 2017 · 2 comments
Closed

Allow calling setPath('userData', path) before app.start() #202

DutchKevv opened this issue May 30, 2017 · 2 comments

Comments

@DutchKevv
Copy link

Maybe its impossible cause of the structure off Electron,

But when I run tests, I want to use a 'temp' userData folder, instead of the 'official' one, so that data from tests does not mix with installed application data.

Is this possible?

Right now its only possible to call app.electron.remote.app.setPath('userData', path); after app.start, cause otherwise app.electron is not defined, and thus to late.

Thanks!

@vanessayuenn
Copy link
Contributor

Hi @DutchKevv, you're correct that app.electron isn't available until after app.start is called. However, you can pass in environment variables as you bootstrap the app with Spectron, e.g.:

const app = new Application({
  path: '<electron app path here>',
  env: {
    SPECTRON_TEMP_DIR: tempPath
  }
})

You can then modify your electron app code to override the userData path based on the environment variable being passed in.

@lukehaas
Copy link

If anyone else has this same issue, it can actually be solved by using chromeDriverArgs like this:

const app = new Application({
  path: '<electron app path here>',
  chromeDriverArgs: ['user-data-dir=/your path']
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants