Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

launch testem chrome browser with specific extension(s)

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.

like image 986
Huafu Avatar asked Sep 16 '14 11:09

Huafu


People also ask

How do I use extensions in Chrome BrowserStack?

The extension will be visible in the Chrome toolbar. Click on the BrowserStack logo to open the panel. Select the Internet Explorer version, and the current page opens within a BrowserStack session, in a new tab. Note: You have to log into or create a new BrowserStack account to test the webpage.

What is Testem?

Testem is a command line tool that runs on Node. js (what doesn't run on Node. js these days?). It allows you to launch unit tests for practically any framework straight from the command line.


1 Answers

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.

like image 73
Kevin Bullaughey Avatar answered Sep 22 '22 23:09

Kevin Bullaughey