Re: Unit testing internal JS

2014-07-07 Thread Martin Thomson
On 07/07/14 09:25, gkee...@mozilla.com wrote: We have no unit test framework for internal JS, does anyone have any > interesting ideas on how to accomplish this with our existing testing > frameworks? I've successfully used mochitest with specialpowers to access the internal interfaces. xpcsh

Re: Unit testing internal JS

2014-07-07 Thread Gijs Kruitbosch
On 07/07/2014 17:25, gkee...@mozilla.com wrote: We have no unit test framework for internal JS, does anyone have any interesting ideas on how to accomplish this with our existing testing frameworks? Should I just leave unit testing functions in the JS file, so they can be run manually during

Re: Unit testing internal JS

2014-07-07 Thread Josh Matthews
Garvan is referring to JS files that implement XPCOM interfaces. It's impossible to test internal details of the components without exposing them via an interface, which can end up convoluting the code in some cases. Cheers, Josh On 07/07/2014 12:32 PM, Gijs Kruitbosch wrote: On 07/07/2014 17

Re: Unit testing internal JS

2014-07-07 Thread Benjamin Smedberg
On 7/7/2014 1:53 PM, Josh Matthews wrote: Garvan is referring to JS files that implement XPCOM interfaces. It's impossible to test internal details of the components without exposing them via an interface, which can end up convoluting the code in some cases. I expect you can import them usin

Re: Unit testing internal JS

2014-07-07 Thread Gregory Szorc
On 7/7/14, 10:53 AM, Josh Matthews wrote: Garvan is referring to JS files that implement XPCOM interfaces. It's impossible to test internal details of the components without exposing them via an interface, which can end up convoluting the code in some cases. Really? I thought you could Cu.impor

Re: Unit testing internal JS

2014-07-07 Thread Philipp Kewisch
What about wrappedJSObject? If the test is geared towards internal details of the implementation anyway, it should be possible to do something like this: xpcom component: function MyXPCOMComponent() { this.wrappedJSObject = this; } MyXPCOMComponent.prototype = { _internalMethod: function(a

Re: Unit testing internal JS

2014-07-07 Thread Gijs Kruitbosch
I'm sorry, I don't seem to understand what you're saying. You seem to be saying: "JS files that implement XPCOM interfaces [which you can't test] without exposing them via an interface". Which prompts me to ask: Does the code, without taking testing into account, need to implement an interface