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.  xpcshell should work too.

___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


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: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 future development?



I'm not sure what you mean by internal JS. We have xpcshell tests, in
which you could load an arbitrary JS file if you wanted, and then run
tests against the functions in that file. Or if it's a JSM, you could
load that and use the result of Cu.import to do internal tests (as that
will produce a BackstagePass which will allow you to interact with
non-exported symbols from that JSM).

~ Gijs


___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


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 using Cu.import if you wanted just for 
testing. You might need to use an unusual import name like 
resource://gre/components/nsSomething.js.


--BDS

___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


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.import() a JS file implementing a 
component and then use the returned backstagepass to inspect unexported 
symbols.

___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform