acvetkov / sinon-chrome

Testing chrome extensions with Node.js
ISC License
439 stars 48 forks source link

Examples not clean #72

Open sookinoby opened 6 years ago

sookinoby commented 6 years ago

Hi, I am unable to understand run the examples in wiki page at it uses jsdom.env function, which is not supported by jsdom any more. Also, the wiki page example looks different from usage example, in readme. Also how to test a plugin developed using https://github.com/HaNdTriX/webextension-toolbox ? Can you please provide some suggestion ?

acvetkov commented 6 years ago
  1. About jsdom: I think this doc is not actual, I should modify (remove) it.
  2. Can you provide more info? What difficulty with this tool?
sookinoby commented 6 years ago

Regarding 2 const chrome = require('sinon-chrome'); // or const chrome = require('sinon-chrome/extensions'); // This does work, what is the difference using sinon-chrome and the extensions? Also, can you provide an example to over ride browser.extension.onConnect.addListener in background.js.

By test code : describe('background page', function () {

beforeEach(function () { global.browser = browser; let back = fs.readFileSync(path.join(__dirname, '../../app/scripts/background.js'), 'utf-8');

const dom = new JSDOM(`<body><script$back</script></body>`, {runScripts: "dangerously", includeNodeLocations: true });

})

afterEach(function () { browser.reset(); window.close(); });

it('should attach listeners on startup', function () { const options = { resources: 'usable', runScripts: 'dangerously', }; console.log("here") this_is_candice = " My name is candice"; console.log(this_is_candice) console.log(browser.extension.onConnect); assert.ok(browser.extension.onConnect, 'browser.extension.onConnect'); }).timeout(5000); });