开发者

Calling addon functionality from a unit test

开发者 https://www.devze.com 2023-04-09 01:56 出处:网络
I\'ve made a firefox addon using the the addon-sdk and I\'m trying to write unit tests for it now. How can I access the addon functionality from the test? From what i see, they are separated, and I c

I've made a firefox addon using the the addon-sdk and I'm trying to write unit tests for it now.

How can I access the addon functionality from the test? From what i see, they are separated, and I cannot simply access the addon f开发者_如何学运维unctions and variables of my addon.


You simply import the modules of your add-on. For example, if you have a module lib/foo.js in your add-on you do:

var foo = require("foo");

Note that you will only be able to access the methods and variables that the module exports (essentially properties of its global exports object).

The reading-data example in the Add-on SDK uses that approach to load the add-on's main module and to call the exported method main().

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号