Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test e2e google chrome extension with karma?

I've found fantastic unit/e2e test tools karma. And I wrote simple chrome extension with angular. I want to write automated tests for it, but not only unit tests, end-to-end tests too. I wrote something like this (will open my angular extension-options page):

 it('Go to options page', function() {
   browser().navigateTo('chrome-extension://aopgehikihpnclbfeohobanjecpiefho/html/application.html#/options');
 });

I removed '--user-data-dir' and '--disable-default-apps' for karma-chrome-launcher, (because I want that my extension stays in chrome during "karma tests")

but I've got next error message "Sandbox Error: Application document not accessible.":

    browser navigate to 'chrome-extension://aopgehikihpnclbfeohobanjecpiefho/html/application.html#/options'
    http://localhost:9876/base/tests/e2e/scenario.js?1372429335000:9:5: 

    Sandbox Error: Application document not accessible.

    Chrome 27.0 (Windows): Executed 2 of 2 (2 FAILED) (0.254 secs / 0.139 secs)

Chrome option --no-sandbox deprecated long time ago.

I'm sure I'm not wrong, the options page opens ok, but from chrome "omnibox".

chrome-extension://aopgehikihpnclbfeohobanjecpiefho/html/application.html#/options

Sandbox Error means no way for end-to-end tests for google chrome extensions via karma? Can I set chrome to special "non-secure" mode just for tests?

Thanks,

like image 540
IL55 Avatar asked Jun 28 '13 16:06

IL55


People also ask

What is Karma test runner?

Karma is a test runner for JavaScript that runs on Node. js. It is very well suited to testing AngularJS or any other JavaScript projects. Using Karma to run tests using one of many popular JavaScript testing suites (Jasmine, Mocha, QUnit, etc.)

What is Karma Unit testing?

Karma is a node-based test tool that allows you to test your JavaScript codes across multiple real browsers. A node-based tool is any tool that needs the Nodejs engine installed for it to run and can be accessed (installed) through the node package manager (npm).

How does Karma js work?

Karma is essentially a tool which spawns a web server that executes source code against test code for each of the browsers connected. The results of each test against each browser are examined and displayed via the command line to the developer such that they can see which browsers and tests passed or failed.


1 Answers

i don't think karma scenario runner is capable to do that. You can try Protractor, it uses WebDriver and karma scenario runner will be replaced with it.

like image 146
ozan.turksever Avatar answered Oct 22 '22 01:10

ozan.turksever