Skip to content

Instantly share code, notes, and snippets.

@arantius
Last active January 8, 2018 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arantius/33d318f57ced2f1b7ef5c49740b00e01 to your computer and use it in GitHub Desktop.
Save arantius/33d318f57ced2f1b7ef5c49740b00e01 to your computer and use it in GitHub Desktop.

Check out this repository/download this ZIP. Run:

$ npm i --save-dev
$ npm test

> sinon-chrome-webext-test@0.0.1 test /.../sinon-chrome-webext-test
> karma start karma.conf.js

Firefox 57.0.0 (Ubuntu 0.0.0) ERROR
  ReferenceError: browser is not defined
  at test.js:1


npm ERR! Test failed.  See above for more details.

I expect this to run without error.

module.exports = function(config) {
config.set({
files: [
'./test.js',
],
frameworks: ['sinon-chrome'],
port: 7328,
colors: true,
logLevel: config.LOG_WARN,
autoWatch: true,
browsers: ['FirefoxHeadless'],
// https://github.com/karma-runner/karma-firefox-launcher/issues/76
customLaunchers: {
FirefoxHeadless: {
base: 'Firefox',
flags: [ '-headless' ],
},
},
singleRun: true,
concurrency: Infinity
})
}
{
"name": "sinon-chrome-webext-test",
"version": "0.0.1",
"scripts": {
"test": "karma start karma.conf.js"
},
"devDependencies": {
"chai": "^4.1.2",
"karma": "^1.3.0",
"karma-firefox-launcher": "^1.0.0",
"karma-chai": "^0.1.0",
"karma-sinon-chrome": "git+https://github.com/arantius/karma-sinon-chrome.git#02ac98c75f795e62d9168d9cc8cefcc76b310116",
"sinon-chrome": "^2.1.2"
}
}
browser.runtime.getManifest.returns({'version': 1});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment