Jetpack/Testing: Difference between revisions

Line 19: Line 19:
== cfx test ==
== cfx test ==


<code>cfx test</code> runs the tests implemented for a single SDK "package".
<code>cfx test</code> runs the tests implemented for a single SDK "package". A package is a collection of JavaScript modules, and is defined as such by the presence of a file called "package.json" in its root directory. Among other things, "package.json" includes an string called "tests" which describes where the package's test suites live. If this is not defined, the default is the "tests" or "test" directory under the package root.
 
An add-on is a package, and the SDK's APIs are currently collected into two packages called "addon-kit" and "api-utils" (you can see them under the top-level "packages" directory).
 
A package is defined as such by the presence of a file called "package.json" in the root directory. Among other things, "package.json" includes an string called "tests" which describes where the package test suites live. If this is not defined, the default is the "tests" or "test" directory under the package root.


So if you navigate to a package's root directory (containing a package.json file) and execute <code>cfx test</code>, <code>cfx</code> will:
So if you navigate to a package's root directory (containing a package.json file) and execute <code>cfx test</code>, <code>cfx</code> will:
Line 30: Line 26:
# load every module it finds in the tests directory which starts with "test"
# load every module it finds in the tests directory which starts with "test"
# call each function exported by that module, passing it a [https://addons.mozilla.org/en-US/developers/docs/sdk/latest/packages/api-utils/docs/unit-test.html test] object as an argument.
# call each function exported by that module, passing it a [https://addons.mozilla.org/en-US/developers/docs/sdk/latest/packages/api-utils/docs/unit-test.html test] object as an argument.
An add-on is a package, and the SDK's APIs are currently collected into two packages called "addon-kit" and "api-utils" (you can see them under the top-level "packages" directory).


=== Testing an Add-on ===
=== Testing an Add-on ===
canmove, Confirmed users
737

edits