8

I am trying to have Testem launching my tests into Chrome browser with specific extension(s) loaded, but by default it's a blank Chrome profile which is started, and which doesn't persist extensions from one run to another.

My goal is for example having Testem to launch the Chrome browser pre-loaded with the Ember Inspector so that I can debug tests using that tool.

I wanted to know if that is possible, and if so, how.

Huafu
  • 2,375
  • 1
  • 18
  • 25

1 Answers1

3

Unfortunately there doesn't seem to be a built-in way that I can find.

If you want a quick and dirty solution, I recommend the following:

The available browsers in testem are defined in testem/lib/browser_launcher.js If you want to modify the file that ember-cli uses, this will be the full path:

<your-app-dir>/node_modules/ember-cli/node_modules/testem/lib/browser_launcher.js

This file has a function called browsersForPlatform(). Find your platform and the entry for Chrome. For Darwin the relevant entry is as follows:

      {
        name: "Chrome", 
        exe: "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome", 
        args: ["--user-data-dir=" + tempDir + "/testem.chrome", "--no-default-browser-check", "--no-first-run", "--ignore-certificate-errors"],
        setup: function(config, done){
          rimraf(tempDir + '/testem.chrome', done)
        },
        supported: browserExeExists
      },

You'll want to change the args so it gets called as you like. My guess is the problem is that --user-data-dir points to a tmp directory. Perhaps simply removing this will solve the problem.

Ideally, testem would offer a way in the testem.json file to override browser options. This would probably be a reasonably straightforward contribution to the testem project if you're interested and there is interest among the maintainers.

If you go the route of changing browser_launcher.js just remember that it will get clobbered every time the node package gets updated. I assume there is a way you can install a forked version and then keep your copy up to date as you see fit.

Kevin Bullaughey
  • 2,456
  • 20
  • 35
  • You can use npm-shrinkwrap.json to force ember-cli to use a forked version of testem. Chrome arguments are now in [lib/utils/known-browsers.js](https://github.com/testem/testem/blob/v1.9.1/lib/utils/known-browsers.js#L22-L33) – vine77 Jul 15 '16 at 19:09