Permalink
Browse files

Update extension docs

  • Loading branch information...
Christian Johansen
Christian Johansen committed Feb 14, 2012
1 parent 12f28ac commit b6eccd97d9886a1e8010e96079123af0028d353e
Showing with 69 additions and 6 deletions.
  1. +69 −6 site/docs/extensions.html
View
@@ -26,7 +26,7 @@ <h3 id="jstestdriver">buster-jstestdriver</h3>
cases.
</p>
<h4>Install</h4>
-<p><code>npm install -g buster-jstestdriver</code></p>
+<p><code>npm install buster-jstestdriver</code></p>
<h4>Usage</h4>
<p>Load in your configuration file:</p>
<pre><code>var config = module.exports;
@@ -35,14 +35,14 @@ <h4>Usage</h4>
rootPath: "../",
sources: ["src/**/*.js"]
tests: ["test/**/*.js"],
- extensions: ["buster-jstestdriver"]
+ extensions: [require("buster-jstestdriver")]
};</code></pre>
<h3 id="amd">buster-amd</h3>
<p>
Use an AMD loader to test asynchronous modules.
</p>
<h4>Install</h4>
-<p><code>npm install -g buster-amd</code></p>
+<p><code>npm install buster-amd</code></p>
<h4>Usage</h4>
<p>Load in your configuration file:</p>
<pre><code>var config = module.exports;
@@ -51,7 +51,7 @@ <h4>Usage</h4>
rootPath: "../",
sources: ["src/**/*.js"]
tests: ["test/**/*.js"],
- extensions: ["buster-amd"]
+ extensions: [require("buster-amd")]
};</code></pre>
<h4>Configure</h4>
<p>
@@ -68,13 +68,70 @@ <h4>Configure</h4>
rootPath: "../",
sources: ["src/**/*.js"]
tests: ["test/**/*.js"],
- extensions: ["buster-amd"],
+ extensions: [require("buster-amd")],
"buster-amd": {
pathMapper: function (path) {
return "plugin!" + path.replace(/^\//, "").replace(/\.js$/, "");
}
}
};</code></pre>
+<h3 id="lint">buster-lint</h3>
+<p>
+ Incorporate linting (JsLint or JsHint) in your test runs. Optionally fail test
+ runs if lint is found.
+</p>
+<h4>Install</h4>
+<p><code>npm install buster-lint</code></p>
+<h4>Usage</h4>
+<p>Load in your configuration file:</p>
+<pre><code>var config = module.exports;
+
+config["Browser tests"] = {
+ rootPath: "../",
+ sources: ["src/**/*.js"]
+ tests: ["test/**/*.js"],
+ extensions: [require("buster-lint")]
+};</code></pre>
+<h4>Configure</h4>
+<p>
+ Configuration options are those supported by the wonderful
+ <a href="https://github.com/magnars/autolint">autolint</a> tool by Magnar
+ Sveen. In fact, if you're already using autolint, you can integrate it with
+ Buster by simply requiring your existing configuration (assuming you're not
+ still using pre-1.0 json config files):
+</p>
+<pre><code>var config = module.exports;
+
+config["Browser tests"] = {
+ rootPath: "../",
+ sources: ["src/**/*.js"]
+ tests: ["test/**/*.js"],
+ extensions: [require("buster-lint")],
+ "buster-lint": require("./autolint")
+};</code></pre>
+<p>
+ If you don't already have an autolint configuration, here's to get you
+ started. All options are documented here.
+</p>
+<pre><code>var config = module.exports;
+
+config["Browser tests"] = {
+ rootPath: "../",
+ sources: ["src/**/*.js"]
+ tests: ["test/**/*.js"],
+ extensions: [require("buster-lint")],
+ "buster-lint": {
+ linterOptions: {
+ node: true
+ },
+
+ excludes: [
+ "jquery",
+ "underscore",
+ "raphael"
+ ]
+ }
+};</code></pre>
<h2 id="building">Building extensions</h2>
<p>
A Buster.JS extension is an object that optionally exposes
@@ -89,9 +146,15 @@ <h3 id="create"><code>var instance = ext.create([options]);</code></h3>
the property named after the extension in the configuration file, e.g.:
</p>
<pre><code>module.exports["Some tests"] = {
- extensions: ["my-extension"],
+ extensions: [require("my-extension")],
"my-extension": whatever
};</code></pre>
+<p>
+ In order for this to work, the extension must export a <code>name</code>
+ property, i.e. <code>module.exports = { name: "my-extension", ... }</code>
+ in the case above. Although you don't explicitly have to, it's good practice
+ to name the extension after it's package name.
+</p>
<p>
The <code>create</code> method is not required. If it's not provided, the
extension will not receive its custom configuration.

0 comments on commit b6eccd9

Please sign in to comment.