Commit 5c436296 authored by Daniel Shumway's avatar Daniel Shumway

docs: minor documentation update

Not as detailed as it could be, but that's because a website is incoming
parent 4ffbf5e8
Pipeline #10253870 passed with stage
in 1 minute and 31 seconds
......@@ -37,7 +37,7 @@ suite.test('test label', function () {
});
```
Distilled is so simple and so conceptually elegant that its entire, unminified source is less than 200 lines long. In fact, I'd bet a savvy coder like you could easily learn Distilled's entire API in less than 10 minutes.
A radical approach to simplicity makes Distilled easy to learn and work with. Even beginning coders who are unfamiliar with testing can get started quickly and easily.
Distilled achieves enlightenment by liberally culling any unneeded and unnecessary features. Distilled is proud to ship _without_ the following features:
......@@ -229,21 +229,27 @@ Also, there might be some extra properties floating around that you can use to b
<br>
### the callback
### the ``then`` method
When you're initializing a new suite, you have the option to pass in a callback. This method will get called whenever _any_ test inside the suite finishes executing, regardless of whether it passed or failed.
Every suite can have callbacks attached by calling ``then``. These will fire off when a given test (and all of its children) have finished running.
In keeping with the theme of consistency, you'll be able to access the test within that method - either through a parameter or the ``this`` keyword.
Just like tests, ``then`` calls are chainable. But unlike ``test``, ``then`` resolves to the same suite you called it on.
```js
var suite = new Distilled(function (test) {
(this === test); //just like above!
var suite = new Distilled();
suite.test('a', true)
.test('b', true);
suite.then(function (test) { //Called when all children have finished
(this === test); //just like above
});
```
You'll notice that in keeping with the theme of consistency, you can access a test within its callback, similarly to how ``test`` works - either through a parameter or the ``this`` keyword.
<br>
Why would you want to do this? Because it turns out that the tests being passed in have a number of interesting properties attached to them:
Why would you want to do this? Because it turns out that after completing, tests have a number of interesting properties attached to them:
```js
{
......@@ -260,6 +266,19 @@ Why would you want to do this? Because it turns out that the tests being passed
If short, tests have all of the information you would need attached to them to determine both how they ran and where they sit in the overall hierarchy of tests.
### the callback
When you're initializing a new suite, you have the option to pass in a callback. This method will get called whenever _any_ test inside the suite finishes executing, regardless of whether it passed or failed.
In short, the callback is a way to specify a default ``then`` for each test inside your suite, which is an extremely handy place to put a custom test reporter!
```js
var suite = new Distilled(function (test) {
console.log(test.label, ': ', test.status);
});
```
And in fact, when you passed in that function, you just overrode Distilled's built in test reporter. This callback offers you all the tools you need to build your own test reporter that spits out whatever format you'd like. Or, you could take advantage of someone else's existing test reporter.
```js
......@@ -297,11 +316,3 @@ I told you adding back any other features you wanted would be simple and easy!
With the combined power of two whole methods, you'll be able to sculpt Distilled into any configuration or setup you can imagine.
<br>
## Super secret no one has scrolled down this far advanced usage
Distilled's constructor can take a second parameter, ``options``.
``options.timeout`` will allow you to specify how long a suite should wait before auto-rejecting a promise.
Scandalous! Too many options!! Such feature creep!!!
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment