The Javascript ecosystem is filled with testing frameworks to choose from. Distilled knows all the buzz words, so of course it's asynchronous-first and totally compatible with modern programming paradigms like Promises. It is smart and sexy and may even someday be compatible with the cool tools like Grunt.

Every ``test`` call returns a new parent for you to test on.```jsvarsetup=suite.test('Parent',Promise.resolve());//Passesvarchild=setup.test('child',function(){returnPromise.reject('error');});//Fails once the parent has finishedvarsubchild=setup.test('sub-child',function(){returnPromise.resolve();});//Is never run```

<br>Distilled can afford to offer this flexibility because it truly is asynchronous-first, down to its very core. In practice, this all-encompassing idea of Promise-like test chaining allows for a high degree of flexibility in deciding how your tests are structured and reported.

- Empty parent tests can be used as descriptive groups.- If a parent test fails (say, connecting to a database) you don't need to waste time waiting for its children to fail.- If you're building a harness runner, you can conditionally fetch new tests on the fly, reducing the necessary overhead to start running your tests.

<br>My recommendation is to set up tests descriptively by treating them like promises. However, if you're not a really a "Promise" kind of coder, and you prefer building pyramids of code, _of course_ Distilled still has you covered.

<br>Don't be afraid! Wrapping your brain around and embracing the possibilities of infinitely nested tests is the key to adapting Distilled into the perfect workflow for you. With just a little imagination, you'll be building your own opinionated frameworks, spectacular assertion libraries, and innovative test runners in no time at all.<br>

When starting out with Distilled, feel free to stick with just the style you're immediately comfortable with. If you do though, keep in mind that the API you're using will be the same no matter what context you're in or what you're trying to do with the library.

-``this`` will always refer to your current testing context, no matter where you are. - You'll always have that testing context available as a parameter. - And you'll always be able to launch a new test off of that context.Those three principles are _never_ false, no matter where you are or what you're doing.

```bashnpm install--save-dev distilled-distilled```Make a new file for your tests:```jsvarDistilled=require('distilled-distilled');varassert=require('assert');varlibrary=require('../my-library');varsuite=newDistilled();varmodule=suite.test('My Library Test');module.test('Methods: ',function(test){test.test('`add` adds two numbers together',function(){assert.deepEqual(library.add(2,3),5);});test.test('`subtract` subtracts two numbers',function(){assert.deepEqual(library.subtract(3,2),1,'normal usage');assert.deepEqual(library.subtract(2,3),-1,'less than zero');});});```Open up your ``package.json`` and add a test runner:```json{"scripts":{"test":"node tests/libraryTest.js"}}```And you're done! In your command line, run ``npm test`` and check out the results. You now know everything you need to know to get started building great, readable, and maintainable unit tests.

Okay, if you're still around, I'll admit it - I wasn't quite honest. See, if you want to get _really_ advanced with Distilled, you're going to have to learn one more method. That's like double the work!

{label:'My Test',//the label you passed in when creating the teststatus:'failed',//passed, failederror:Error(),//Error object (if one exists)parent:Parent,//Reference to the parent testing contextchildren:[]//Reference to any child testing contexts}```

### the callbackWhen 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!```jsvar 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.

Want to go a bit deeper? Remember that the context getting passed into both the ``test`` method and your callback is the exact same.This means that you can use it to communicate between tests and your reporter.```jsvarskip=function(){this.skip=true;returnfalse;}varsuite=newDistilled(function(){if(this.skip){//don't log or report this test, even if it shows up as a failure.}});suite.test('ignore test',skip).test('my ignored test'//.... ```