Skip to content

Commit

Permalink
Add convenience functions canary.Group and canary.Series
Browse files Browse the repository at this point in the history
  • Loading branch information
pineapplemachine committed Apr 13, 2018
1 parent 9e279c1 commit 55da30b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
17 changes: 14 additions & 3 deletions canary.js
Original file line number Diff line number Diff line change
Expand Up @@ -1108,9 +1108,9 @@ class CanaryTest{
async doReport(options = undefined){
let report = undefined;
const log = message => {
if(!options.silent){
return this.getLogFunction()(message);
}
if(!options.silent){
return this.getLogFunction()(message);
}
};
try{
// Set a default empty options object when none was specified.
Expand Down Expand Up @@ -1258,6 +1258,17 @@ canary.Callback = CanaryTestCallback;
canary.Error = CanaryTestError;
canary.Test = CanaryTest;

canary.Group = function(...args){
const group = new CanaryTest(...args);
group.isGroup = true;
};

canary.Series = function(...args){
const series = new CanaryTest(...args);
series.isGroup = true;
series.isSeries = true;
};

CanaryTest.currentlyExpandingGroup = undefined;

module.exports = canary;
14 changes: 13 additions & 1 deletion docs/api-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,24 @@ const canary = require("canary-test");

# The Test Class

The [**CanaryTest**](api-introduction.md) class can be referred to via [**canary.Test**](api-introduction.md). Although most of the work done with Canary will be using the methods of instances of this class, it should rarely if ever be necessary to instantiate a [**CanaryTest**](api-introduction.md) yourself.
The [**CanaryTest**](api-introduction.md) class can be referred to via [**canary.Test**](api-introduction.md). Although most of the work done with Canary will be using the methods of instances of this class, it should not normally be necessary to instantiate a [**CanaryTest**](api-introduction.md) yourself.

``` js
assert(canary instanceof canary.Test);
```

There are also functions available for creating disconnected test groups and series in this same way:

``` js
const someGroup = canary.Group("Some group");
assert(someGroup.isGroup);
```

``` js
const someSeries = canary.Series("Some series");
assert(someSeries.isSeries);
```

The library also utilizes [**CanaryTestCallback**](api-callback-class.md) and [**CanaryTestError**](api-error-class.md) classes. These classes can be referred to with [**canary.Callback**](api-callback-class.md) and [**canary.Error**](api-error-class.md), respectively. These classes are mainly for internal use and, normally, it will not be necessary to work with them directly.

# List of Attributes
Expand Down

0 comments on commit 55da30b

Please sign in to comment.