-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: improve documentation, example, and tutorials (#518)
- Loading branch information
1 parent
77d406c
commit 1b21d25
Showing
14 changed files
with
657 additions
and
452 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
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
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
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 |
---|---|---|
@@ -1,7 +1,3 @@ | ||
--- | ||
sidebar_position: 4 | ||
--- | ||
|
||
import Tabs from '@theme/Tabs'; | ||
import TabItem from '@theme/TabItem'; | ||
|
||
|
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,135 @@ | ||
--- | ||
title: Promises | ||
tags: [examples, promise, beforeAll, afterAll, tutorial, roadmap] | ||
sidebar_position: 0 | ||
--- | ||
|
||
import Tabs from '@theme/Tabs'; | ||
import TabItem from '@theme/TabItem'; | ||
import MidLevel from '@site/static/img/mid-level.svg'; | ||
|
||
# Promises | ||
|
||
The use of native **JavaScript** syntax in tests is one of the major differences between Poku and other test runners, which is what makes it possible to use it on multiple platforms. | ||
|
||
Here are some examples of sequential and concurrent tests in the same file plus how to perform an action after all the tests have been completed: | ||
|
||
### Running async tests in the same file in parallel | ||
|
||
```js | ||
import { test, assert, sleep } from 'poku'; | ||
|
||
test(async () => { | ||
const actual = 1; | ||
const expected = 1; | ||
|
||
await sleep(2000); | ||
|
||
assert.strictEqual(actual, expected); | ||
}); | ||
|
||
test(async () => { | ||
const actual = 2; | ||
const expected = 2; | ||
|
||
await sleep(1000); | ||
|
||
assert.strictEqual(actual, expected); | ||
}); | ||
``` | ||
|
||
<hr /> | ||
|
||
### Running async tests in the same file sequentially (await top-level) | ||
|
||
```js | ||
import { test, assert, sleep } from 'poku'; | ||
|
||
await test(async () => { | ||
const actual = 1; | ||
const expected = 1; | ||
|
||
await sleep(2000); | ||
|
||
assert.strictEqual(actual, expected); | ||
}); | ||
|
||
await test(async () => { | ||
const actual = 2; | ||
const expected = 2; | ||
|
||
await sleep(1000); | ||
|
||
assert.strictEqual(actual, expected); | ||
}); | ||
``` | ||
|
||
<hr /> | ||
|
||
### Running async tests in the same file sequentially | ||
|
||
```js | ||
import { test, it, assert, sleep } from 'poku'; | ||
|
||
test(async () => { | ||
await it(async () => { | ||
const actual = 1; | ||
const expected = 1; | ||
|
||
await sleep(2000); | ||
|
||
assert.strictEqual(actual, expected); | ||
}); | ||
|
||
await it(async () => { | ||
const actual = 2; | ||
const expected = 2; | ||
|
||
await sleep(1000); | ||
|
||
assert.strictEqual(actual, expected); | ||
}); | ||
}); | ||
``` | ||
|
||
<hr /> | ||
|
||
## Waiting for all the tests to run a post step | ||
|
||
```js | ||
import { test, assert, sleep } from 'poku'; | ||
|
||
console.log('Printing it before all tests 🏃🏻♀️'); | ||
|
||
await Promise.all([ | ||
test(async () => { | ||
const actual = 1; | ||
const expected = 1; | ||
|
||
await sleep(2000); | ||
|
||
assert.strictEqual(actual, expected); | ||
}), | ||
|
||
test(async () => { | ||
const actual = 2; | ||
const expected = 2; | ||
|
||
await sleep(1000); | ||
|
||
assert.strictEqual(actual, expected); | ||
}), | ||
]); | ||
|
||
console.log('Printing it after all tests 😴'); | ||
``` | ||
|
||
:::tip | ||
The same goes for `describe` and `it`. | ||
::: | ||
|
||
<hr /> | ||
|
||
:::note | ||
If you find any typos, feel free to open a **Pull Request** correcting them. | ||
::: |
Oops, something went wrong.