-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #17: guide/advanced_test section
- Loading branch information
1 parent
9d73254
commit 23fc51c
Showing
1 changed file
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
--- | ||
layout: guide | ||
section: guide | ||
role: page | ||
order: 60 | ||
toc: true | ||
title: Advanced Tests | ||
label: Advanced Tests | ||
description: | | ||
Advanced Tests | ||
--- | ||
|
||
{:.toc} | ||
## Advanced Tests | ||
|
||
{:.toc} | ||
## Test Execution Options | ||
|
||
{% highlight TypeScript linenos %} | ||
import { suite, test, retries, slow, timeout } from '@testdeck/mocha'; | ||
|
||
@suite | ||
class Suite { | ||
|
||
@test(retries(5)) | ||
@timeout(1500) | ||
retried(done) { | ||
|
||
setTimeout(done, 1800); | ||
} | ||
|
||
@test(slow(1000), timeout(2000)) | ||
slow(done) { | ||
|
||
setTimeout(done, 1500); | ||
} | ||
} | ||
{% endhighlight %} | ||
|
||
|
||
{:.toc} | ||
### retries {% include support-mocha.html %} | ||
|
||
`retries` can be used as either a decorator or passed as a parameter to the `@test` decorator. | ||
|
||
{% highlight TypeScript linenos %} | ||
import { suite, test, retries } from '@testdeck/mocha'; | ||
|
||
@suite | ||
class Suite { | ||
|
||
@test(retries(2)) | ||
@retries(2) | ||
retried() { | ||
|
||
throw new Error('failed'); | ||
} | ||
} | ||
{% endhighlight %} | ||
|
||
|
||
{:.toc} | ||
### slow {% include support-mocha.html %} | ||
|
||
`slow` can be used as either a decorator or passed as a parameter to the `@test` decorator. | ||
|
||
{% highlight TypeScript linenos %} | ||
import { suite, test, slow } from '@testdeck/mocha'; | ||
|
||
@suite | ||
class Suite { | ||
|
||
@test(slow(2000)) | ||
@slow(2000) | ||
slow(done) { | ||
|
||
setTimeout(done, 2100); | ||
} | ||
} | ||
{% endhighlight %} | ||
|
||
|
||
{:.toc} | ||
### timeout {% include support-all.html %} | ||
|
||
`timeout` can be used as either a decorator or passed as a parameter to the `@test` decorator. | ||
|
||
{% highlight TypeScript linenos %} | ||
import { suite, test, timeout } from '@testdeck/mocha'; | ||
|
||
@suite | ||
class Suite { | ||
|
||
@test(timeout(3000)) | ||
@timeout(3000) | ||
timeout(done) { | ||
|
||
setTimeout(done, 3500); | ||
} | ||
} | ||
{% endhighlight %} | ||
|
||
|
||
{:.toc} | ||
## Test Naming {% include support-all.html %} | ||
|
||
{% highlight TypeScript linenos %} | ||
import { suite, test } from '@testdeck/mocha'; | ||
|
||
@suite | ||
class Suite { | ||
|
||
@test('a custom name for the test') | ||
test() { | ||
} | ||
|
||
@test 'alternate naming'() { | ||
} | ||
} | ||
{% endhighlight %} | ||
|
||
|
||
{:.toc} | ||
## Pending Tests {% include support-all.html %} | ||
|
||
{% highlight TypeScript linenos %} | ||
import { suite, test, pending } from '@testdeck/mocha'; | ||
|
||
@suite | ||
class Suite { | ||
|
||
@test.pending | ||
pending() { | ||
} | ||
|
||
@test | ||
@pending | ||
alsoPending() { | ||
} | ||
} | ||
{% endhighlight %} | ||
|
||
|
||
{:.toc} | ||
## Skipping Tests {% include support-all.html %} | ||
|
||
{% highlight TypeScript linenos %} | ||
import { suite, test, skip } from '@testdeck/mocha'; | ||
|
||
@suite | ||
class Suite { | ||
|
||
@test.skip | ||
skipped() { | ||
} | ||
|
||
@test | ||
@skip | ||
alsoSkipped() { | ||
} | ||
} | ||
{% endhighlight %} | ||
|
||
|
||
{:.toc} | ||
## Focused Tests {% include support-all.html %} | ||
|
||
{% highlight TypeScript linenos %} | ||
import { suite, test, only } from '@testdeck/mocha'; | ||
|
||
@suite | ||
class Suite { | ||
|
||
@test.only | ||
focused() { | ||
} | ||
|
||
@test | ||
@only | ||
alsoFocused() { | ||
} | ||
} | ||
{% endhighlight %} |