-
-
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.
feat(test): support for Node.js familiar API usage (#352)
* feat: support for Node.js `test` familiar API usage * refactor: better organize types and configs * docs: include all `test` approaches * ci: use imports from modules
- Loading branch information
1 parent
6e7def5
commit 1c425e1
Showing
29 changed files
with
192 additions
and
88 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { test, assert } from 'poku'; | ||
import { sum } from '../../src/sum.js'; | ||
|
||
test(() => { | ||
assert.equal(sum(4, 4), 4, 'should add 4 + 4'); | ||
test('should add 4 + 4', () => { | ||
assert.equal(sum(4, 4), 4); | ||
}); |
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,6 +1,6 @@ | ||
import { test, assert } from 'poku'; | ||
import { sum } from '../../src/sum.js'; | ||
|
||
test(() => { | ||
assert.equal(sum(2, 2), 4, 'should add 2 + 2'); | ||
test('should add 2 + 2', () => { | ||
assert.equal(sum(2, 2), 4); | ||
}); |
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,18 @@ | ||
/* c8 ignore start */ | ||
|
||
import { type backgroundColor } from '../helpers/format.js'; | ||
|
||
export type DescribeOptions = { | ||
background?: keyof typeof backgroundColor | boolean; | ||
/** | ||
* @default "☰" | ||
*/ | ||
icon?: string; | ||
/** @deprecated */ | ||
pad?: boolean; | ||
/** | ||
* @default "grey" | ||
*/ | ||
}; | ||
|
||
/* c8 ignore stop */ |
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 |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
export const indentation = { | ||
test: ' ', | ||
stdio: ' ', | ||
describeCounter: 0, | ||
testCounter: 0, | ||
}; | ||
|
||
/* c8 ignore stop */ |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* c8 ignore start */ | ||
|
||
import { write } from '../helpers/logs.js'; | ||
|
||
/** | ||
* By default **Poku** only shows outputs generated from itself. | ||
* This helper allows you to use an alternative to `console.log` with **Poku**. | ||
* | ||
* Need to debug? Just use the [`debug`](https://poku.io/docs/documentation/poku/options/debug) option from `poku`. | ||
*/ | ||
export const log = (message: string) => write(`\x1b[0m${message}\x1b[0m`); | ||
|
||
/* c8 ignore stop */ |
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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// import { describe } from '../../../src/modules/describe.js'; | ||
// import { test } from '../../../src/modules/test.js'; |
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,11 +1,31 @@ | ||
import { test } from '../../../src/index.js'; | ||
import { describe } from '../../../src/modules/describe.js'; | ||
import { test } from '../../../src/modules/test.js'; | ||
|
||
(async () => { | ||
describe('Testing "test" method', { | ||
icon: '🔬', | ||
}); | ||
|
||
test(async () => { | ||
test(() => {}); | ||
test(() => true); | ||
test(() => false); | ||
test(() => undefined); | ||
test(() => new Promise((resolve) => resolve(undefined))); | ||
test(async () => await new Promise((resolve) => resolve(undefined))); | ||
|
||
await test(() => new Promise((resolve) => resolve(undefined))); | ||
await test(async () => await new Promise((resolve) => resolve(undefined))); | ||
})(); | ||
}); | ||
|
||
test(async () => { | ||
test('', () => {}); | ||
test('', () => true); | ||
test('', () => false); | ||
test('', () => undefined); | ||
test('', () => new Promise((resolve) => resolve(undefined))); | ||
test('', async () => await new Promise((resolve) => resolve(undefined))); | ||
|
||
await test('', () => new Promise((resolve) => resolve(undefined))); | ||
await test('', async () => | ||
await new Promise((resolve) => resolve(undefined))); | ||
}); |
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
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 |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
"link": { | ||
"type": "generated-index" | ||
}, | ||
"position": 2 | ||
"position": 3 | ||
} |
Oops, something went wrong.