poku 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +118 -85
- package/lib/configs/each.d.ts +13 -0
- package/lib/configs/each.js +13 -0
- package/lib/helpers/find-file.d.ts +1 -0
- package/lib/helpers/find-file.js +27 -0
- package/lib/helpers/format.d.ts +17 -0
- package/lib/helpers/format.js +18 -1
- package/lib/helpers/parseAsssetion.d.ts +1 -1
- package/lib/helpers/parseAsssetion.js +29 -23
- package/lib/index.d.ts +1 -0
- package/lib/index.js +4 -1
- package/lib/modules/assert-promise.d.ts +7 -7
- package/lib/modules/assert-promise.js +125 -253
- package/lib/modules/assert.d.ts +2 -7
- package/lib/modules/assert.js +116 -215
- package/lib/modules/describe.d.ts +28 -0
- package/lib/modules/describe.js +27 -0
- package/lib/modules/each.d.ts +6 -7
- package/lib/modules/each.js +15 -18
- package/package.json +11 -4
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
[ci-url]: https://github.com/wellwelwel/poku/actions/workflows/ci.yml?query=branch%3Amain
|
|
10
10
|
[ci-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci.yml?event=push&style=flat&label=CI&branch=main
|
|
11
11
|
[ql-url]: https://github.com/wellwelwel/poku/actions/workflows/codeql.yml?query=branch%3Amain
|
|
12
|
-
[ql-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/codeql.yml?event=push&style=flat&label=Code%20QL&branch=main
|
|
12
|
+
[ql-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci-codeql.yml?event=push&style=flat&label=Code%20QL&branch=main
|
|
13
13
|
[license-url]: https://github.com/wellwelwel/poku/blob/main/LICENSE
|
|
14
14
|
[license-image]: https://img.shields.io/npm/l/poku.svg?maxAge=2592000&color=9c88ff&label=License
|
|
15
15
|
[downloads-image]: https://img.shields.io/npm/dt/poku.svg?&color=FFC312&label=Downloads
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
|
|
18
18
|
# Poku
|
|
19
19
|
|
|
20
|
-
<img align="right" width="128" height="128" alt="Logo" src=".github/assets/readme/poku.svg">
|
|
20
|
+
<img align="right" width="128" height="128" alt="Logo" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/poku.svg">
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
[**English**](https://poku.io/docs) | [**Português (BR)**](https://poku.io/pt-BR/docs)
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
**Poku** is your Test Runner Pet for [**Node.js**][node-version-url], [**Bun**][bun-version-url] and [**Deno**][deno-version-url].
|
|
25
25
|
|
|
26
26
|
[![Node.js Version][node-version-image]][node-version-url]
|
|
27
27
|
[![Bun Version][bun-version-image]][bun-version-url]
|
|
@@ -32,151 +32,169 @@
|
|
|
32
32
|
[![NPM Downloads][downloads-image]][downloads-url]
|
|
33
33
|
[![License][license-image]][license-url]
|
|
34
34
|
|
|
35
|
+
<!--  -->
|
|
36
|
+
|
|
35
37
|
Enjoying **Poku**? Consider giving him a star ⭐️
|
|
36
38
|
|
|
37
39
|
---
|
|
38
40
|
|
|
39
|
-
🐷 [**Documentation
|
|
41
|
+
🐷 [**Documentation**](https://poku.io) • 🧪 [**Examples**](https://poku.io/docs/category/examples) • 🔬 [**Compare the Most Popular Test Runners**](https://poku.io/docs/comparing)
|
|
40
42
|
|
|
41
43
|
---
|
|
42
44
|
|
|
43
45
|
## Why Poku?
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
By creating **Poku**, my aim is to show that testing can be simpler 🌱
|
|
46
48
|
|
|
49
|
+
- No configurations
|
|
47
50
|
- Supports **ESM** and **CJS**
|
|
51
|
+
- High **isolation** level per file
|
|
52
|
+
- **Poku** is [**100%** documented](https://poku.io/docs)
|
|
53
|
+
- Zero external dependencies
|
|
54
|
+
- **Parallel** and **Sequential** runs
|
|
48
55
|
- Designed to be highly intuitive
|
|
49
56
|
- Compatible with **Coverage** tools
|
|
50
57
|
- [**Node.js**][node-version-url], [**Bun**][bun-version-url] and [**Deno**][deno-version-url] compatibility
|
|
51
|
-
-
|
|
52
|
-
- Allows both **API (_in-code_)** and **CLI** usage
|
|
53
|
-
- Poku adapts to your test, not the other way around
|
|
54
|
-
- You can use **Poku**'s `assert` with every test runner you want
|
|
55
|
-
- [**And much more!**](https://poku.dev)
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
- [](https://packagephobia.com/result?p=poku)
|
|
60
|
-
- **Zero** external dependencies 🌱
|
|
58
|
+
- You don't need to learn it all at once to get started 🧑🏻🎓
|
|
61
59
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
## Documentation
|
|
65
|
-
|
|
66
|
-
- See detailed usage in [**Documentation**](https://poku.dev/docs/category/documentation) section for **Poku**'s **CLI**, **API (_in-code_)** and **assert**, advanced concepts and much more.
|
|
60
|
+
> _Poku adapts to your test, not the other way around._
|
|
67
61
|
|
|
68
62
|
---
|
|
69
63
|
|
|
70
|
-
##
|
|
64
|
+
## Quickstart
|
|
71
65
|
|
|
72
|
-
|
|
66
|
+
### Install 📦
|
|
73
67
|
|
|
74
|
-
|
|
68
|
+
[](https://packagephobia.com/result?p=poku)
|
|
75
69
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
>
|
|
85
|
-
|
|
86
|
-
---
|
|
87
|
-
|
|
88
|
-
### `assert`
|
|
89
|
-
|
|
90
|
-
| Using `poku` | Using `node` |
|
|
91
|
-
| --------------------------------------------------- | --------------------------------------------------- |
|
|
92
|
-
| <img src=".github/assets/readme/assert-poku.png" /> | <img src=".github/assets/readme/assert-node.png" /> |
|
|
93
|
-
|
|
94
|
-
> [**See the complete assert's documentation**](https://poku.dev/docs/documentation/assert).
|
|
95
|
-
|
|
96
|
-
---
|
|
97
|
-
|
|
98
|
-
## Install
|
|
99
|
-
|
|
100
|
-
### **Node.js**
|
|
70
|
+
<table>
|
|
71
|
+
<tr>
|
|
72
|
+
<td><img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/node-js.svg" width="24" /></td>
|
|
73
|
+
<td><img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/node-js.svg" width="24" /> <img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/plus.svg" width="24" /> <img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/typescript.svg" width="24" /></td>
|
|
74
|
+
<td><img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/bun.svg" width="24" /></td>
|
|
75
|
+
<td><img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/deno.svg" width="24" /></td>
|
|
76
|
+
</tr>
|
|
77
|
+
<tr>
|
|
78
|
+
<td width="400">
|
|
101
79
|
|
|
102
80
|
```bash
|
|
103
81
|
npm i -D poku
|
|
104
82
|
```
|
|
105
83
|
|
|
106
|
-
|
|
84
|
+
</td>
|
|
85
|
+
<td width="400">
|
|
107
86
|
|
|
108
87
|
```bash
|
|
109
88
|
npm i -D poku tsx
|
|
110
89
|
```
|
|
111
90
|
|
|
112
|
-
|
|
91
|
+
</td>
|
|
92
|
+
<td width="400">
|
|
113
93
|
|
|
114
94
|
```bash
|
|
115
95
|
bun add -d poku
|
|
116
96
|
```
|
|
117
97
|
|
|
118
|
-
|
|
98
|
+
</td>
|
|
99
|
+
<td width="400">
|
|
119
100
|
|
|
120
101
|
```ts
|
|
121
102
|
import { poku } from 'npm:poku';
|
|
122
103
|
```
|
|
123
104
|
|
|
124
|
-
|
|
105
|
+
</td>
|
|
106
|
+
</tr>
|
|
107
|
+
</table>
|
|
125
108
|
|
|
126
|
-
|
|
109
|
+
### Test it 🔬
|
|
127
110
|
|
|
128
|
-
|
|
111
|
+
<table>
|
|
112
|
+
<tr>
|
|
113
|
+
<td>
|
|
114
|
+
<em><code>test/file.test.js</code></em>
|
|
115
|
+
</td>
|
|
116
|
+
</tr>
|
|
117
|
+
<tr>
|
|
118
|
+
<td width="1200">
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
import { assert } from 'poku';
|
|
122
|
+
|
|
123
|
+
assert(true, 'Poku will describe it 🐷');
|
|
124
|
+
```
|
|
129
125
|
|
|
130
|
-
|
|
126
|
+
</td>
|
|
127
|
+
</tr>
|
|
128
|
+
</table>
|
|
131
129
|
|
|
132
|
-
|
|
130
|
+
### Run it 🚀
|
|
133
131
|
|
|
134
|
-
>
|
|
132
|
+
<table>
|
|
133
|
+
<tr>
|
|
134
|
+
<td><img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/node-js.svg" width="24" /></td>
|
|
135
|
+
<td><img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/bun.svg" width="24" /></td>
|
|
136
|
+
<td><img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/deno.svg" width="24" /></td>
|
|
137
|
+
</tr>
|
|
138
|
+
<tr>
|
|
139
|
+
<td width="400">
|
|
135
140
|
|
|
136
141
|
```bash
|
|
137
|
-
npx poku
|
|
138
|
-
npx poku targetPathA,targetPathB
|
|
142
|
+
npx poku
|
|
139
143
|
```
|
|
140
144
|
|
|
141
|
-
>
|
|
145
|
+
</td>
|
|
146
|
+
<td width="400">
|
|
142
147
|
|
|
143
148
|
```bash
|
|
144
|
-
bun poku
|
|
145
|
-
bun poku targetPathA,targetPathB
|
|
149
|
+
bun poku
|
|
146
150
|
```
|
|
147
151
|
|
|
148
|
-
>
|
|
152
|
+
</td>
|
|
153
|
+
<td width="400">
|
|
149
154
|
|
|
150
155
|
```bash
|
|
151
|
-
deno run npm:poku
|
|
152
|
-
deno run npm:poku targetPathA,targetPathB
|
|
156
|
+
deno run npm:poku
|
|
153
157
|
```
|
|
154
158
|
|
|
155
|
-
|
|
159
|
+
</td>
|
|
160
|
+
</tr>
|
|
161
|
+
</table>
|
|
156
162
|
|
|
157
|
-
|
|
163
|
+
### That's it 🎉
|
|
158
164
|
|
|
159
|
-
|
|
160
|
-
|
|
165
|
+
- [**See the complete `assert`'s documentation**](https://poku.io/docs/documentation/assert).
|
|
166
|
+
- [**See the complete `poku`'s documentation**](https://poku.io/docs/category/poku).
|
|
161
167
|
|
|
162
|
-
|
|
163
|
-
```
|
|
168
|
+
---
|
|
164
169
|
|
|
165
|
-
|
|
170
|
+
## Overview
|
|
166
171
|
|
|
167
|
-
|
|
168
|
-
import { poku } from 'npm:poku';
|
|
172
|
+
### `poku`
|
|
169
173
|
|
|
170
|
-
|
|
171
|
-
|
|
174
|
+
| Sequential | Concurrent |
|
|
175
|
+
| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
|
|
176
|
+
| <img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/sequential.png" /> | <img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/parallel.png" /> |
|
|
177
|
+
|
|
178
|
+
> [**See the complete `poku`'s documentation**](https://poku.io/docs/category/poku).
|
|
179
|
+
|
|
180
|
+
---
|
|
172
181
|
|
|
173
182
|
### `assert`
|
|
174
183
|
|
|
175
|
-
Use it exactly as it's for **Node.js**
|
|
184
|
+
- 💚 Use it exactly as it's for **Node.js**
|
|
185
|
+
- 🐷 **Node.js**, **Bun** and **Deno** compatibility
|
|
186
|
+
|
|
187
|
+
| Using `poku` | Using `node` |
|
|
188
|
+
| ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
189
|
+
| <img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/assert-poku.png" /> | <img src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/assert-node.png" /> |
|
|
190
|
+
|
|
191
|
+
> [**See the complete `assert`'s documentation**](https://poku.io/docs/documentation/assert).
|
|
176
192
|
|
|
177
193
|
---
|
|
178
194
|
|
|
179
|
-
|
|
195
|
+
## Documentation and Examples
|
|
196
|
+
|
|
197
|
+
To see the detailed documentation, please visit the [**Documentation**](https://poku.io/docs/category/documentation) and [**Examples**](https://poku.io/docs/category/examples) sections in the [**Poku**'s website](https://poku.io).
|
|
180
198
|
|
|
181
199
|
---
|
|
182
200
|
|
|
@@ -186,24 +204,39 @@ I'm continuously working to improve **Poku**. If you've got something interestin
|
|
|
186
204
|
|
|
187
205
|
---
|
|
188
206
|
|
|
189
|
-
##
|
|
207
|
+
## Contributing
|
|
190
208
|
|
|
191
|
-
|
|
209
|
+
Please check the [**CONTRIBUTING.md**](./CONTRIBUTING.md) for instructions 🚀
|
|
192
210
|
|
|
193
211
|
---
|
|
194
212
|
|
|
195
|
-
##
|
|
213
|
+
## Philosophy
|
|
196
214
|
|
|
197
|
-
Please check the [**
|
|
215
|
+
Please check the [**Philosophy**](https://poku.io/docs/philosophy) section from Documentation.
|
|
198
216
|
|
|
199
217
|
---
|
|
200
218
|
|
|
201
219
|
## License
|
|
202
220
|
|
|
203
|
-
Poku is under the [**MIT
|
|
221
|
+
Poku is under the [**MIT License**](./LICENSE).
|
|
204
222
|
|
|
205
223
|
---
|
|
206
224
|
|
|
207
225
|
## Security Policy
|
|
208
226
|
|
|
209
|
-
Please check the [**SECURITY.md**](./SECURITY.md) and the section [**Is Poku Safe?**](https://poku.
|
|
227
|
+
Please check the [**SECURITY.md**](./SECURITY.md) and the section [**Is Poku Safe?**](https://poku.io/docs/security) from Documentation.
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Acknowledgements
|
|
232
|
+
|
|
233
|
+
[](https://github.com/wellwelwel/poku/graphs/contributors)
|
|
234
|
+
|
|
235
|
+
[](https://github.com/wellwelwel/poku/graphs/contributors)
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Author
|
|
240
|
+
|
|
241
|
+
| [<br><sub>@wellwelwel</sub>](https://github.com/wellwelwel) |
|
|
242
|
+
| :--------------------------------------------------------------------------------------------------------------------------------------: |
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type Control = {
|
|
2
|
+
pause: () => void;
|
|
3
|
+
continue: () => void;
|
|
4
|
+
reset: () => void;
|
|
5
|
+
};
|
|
6
|
+
export type EachConfigs = {
|
|
7
|
+
status: boolean;
|
|
8
|
+
cb?: () => unknown | Promise<unknown>;
|
|
9
|
+
};
|
|
10
|
+
export declare const each: {
|
|
11
|
+
before: EachConfigs;
|
|
12
|
+
after: EachConfigs;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const findFile: (error: Error) => string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findFile = void 0;
|
|
4
|
+
const node_os_1 = require("os");
|
|
5
|
+
const findFile = (error) => {
|
|
6
|
+
var _a;
|
|
7
|
+
const stackLines = ((_a = error.stack) === null || _a === void 0 ? void 0 : _a.split(node_os_1.EOL)) || [];
|
|
8
|
+
let file = '';
|
|
9
|
+
const basePath = 'poku/lib/';
|
|
10
|
+
for (const line of stackLines) {
|
|
11
|
+
if (!line.includes(basePath)) {
|
|
12
|
+
const match = line.match(/at\s(\/.+|file:.+)|^(\s+)at\smodule\scode\s\((\/.+|file:.+)\)/i);
|
|
13
|
+
// Node and Deno
|
|
14
|
+
if (match && match[1]) {
|
|
15
|
+
file = match[1];
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
// Bun
|
|
19
|
+
if (match && match[3]) {
|
|
20
|
+
file = match[3];
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return file;
|
|
26
|
+
};
|
|
27
|
+
exports.findFile = findFile;
|
package/lib/helpers/format.d.ts
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
export declare const backgroundColor: {
|
|
2
|
+
readonly white: 7;
|
|
3
|
+
readonly black: 40;
|
|
4
|
+
readonly grey: 100;
|
|
5
|
+
readonly red: 41;
|
|
6
|
+
readonly green: 42;
|
|
7
|
+
readonly yellow: 43;
|
|
8
|
+
readonly blue: 44;
|
|
9
|
+
readonly magenta: 45;
|
|
10
|
+
readonly cyan: 46;
|
|
11
|
+
readonly brightRed: 101;
|
|
12
|
+
readonly brightGreen: 102;
|
|
13
|
+
readonly brightYellow: 103;
|
|
14
|
+
readonly brightBlue: 104;
|
|
15
|
+
readonly brightMagenta: 105;
|
|
16
|
+
readonly brightCyan: 106;
|
|
17
|
+
};
|
|
1
18
|
export declare const format: {
|
|
2
19
|
counter: (current: number, total: number, pad?: string) => string;
|
|
3
20
|
dim: (value: string) => string;
|
package/lib/helpers/format.js
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLargestStringLength = exports.format = void 0;
|
|
3
|
+
exports.getLargestStringLength = exports.format = exports.backgroundColor = void 0;
|
|
4
4
|
const pad_js_1 = require("./pad.js");
|
|
5
|
+
exports.backgroundColor = {
|
|
6
|
+
white: 7,
|
|
7
|
+
black: 40,
|
|
8
|
+
grey: 100,
|
|
9
|
+
red: 41,
|
|
10
|
+
green: 42,
|
|
11
|
+
yellow: 43,
|
|
12
|
+
blue: 44,
|
|
13
|
+
magenta: 45,
|
|
14
|
+
cyan: 46,
|
|
15
|
+
brightRed: 101,
|
|
16
|
+
brightGreen: 102,
|
|
17
|
+
brightYellow: 103,
|
|
18
|
+
brightBlue: 104,
|
|
19
|
+
brightMagenta: 105,
|
|
20
|
+
brightCyan: 106,
|
|
21
|
+
};
|
|
5
22
|
exports.format = {
|
|
6
23
|
counter: (current, total, pad = '0') => {
|
|
7
24
|
const totalDigits = String(total).length;
|
|
@@ -6,4 +6,4 @@ export type ParseAssertionOptions = {
|
|
|
6
6
|
throw?: boolean;
|
|
7
7
|
hideDiff?: boolean;
|
|
8
8
|
};
|
|
9
|
-
export declare const parseAssertion: (cb: () => void
|
|
9
|
+
export declare const parseAssertion: (cb: () => void | Promise<void>, options: ParseAssertionOptions) => Promise<void>;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -10,29 +19,26 @@ const node_assert_1 = __importDefault(require("assert"));
|
|
|
10
19
|
const node_os_1 = require("os");
|
|
11
20
|
const format_js_1 = require("./format.js");
|
|
12
21
|
const hr_js_1 = require("./hr.js");
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
let file = '';
|
|
17
|
-
const basePath = 'poku/lib/';
|
|
18
|
-
for (const line of stackLines) {
|
|
19
|
-
if (!line.includes(basePath)) {
|
|
20
|
-
const match = line.match(/at\s(\/.+|file:\/\/\/.+)/i);
|
|
21
|
-
if (match && match[1]) {
|
|
22
|
-
file = match[1];
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return file;
|
|
28
|
-
};
|
|
29
|
-
const formatFail = (str) => format_js_1.format.bold(format_js_1.format.fail(`✘ ${str}`));
|
|
30
|
-
const parseAssertion = (cb, options) => {
|
|
22
|
+
const find_file_js_1 = require("./find-file.js");
|
|
23
|
+
const each_js_1 = require("../configs/each.js");
|
|
24
|
+
const parseAssertion = (cb, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
25
|
var _a, _b;
|
|
32
26
|
const isPoku = typeof ((_a = node_process_1.default.env) === null || _a === void 0 ? void 0 : _a.FILE) === 'string' && ((_b = node_process_1.default.env) === null || _b === void 0 ? void 0 : _b.FILE.length) > 0;
|
|
33
27
|
const FILE = node_process_1.default.env.FILE;
|
|
34
28
|
try {
|
|
35
|
-
cb
|
|
29
|
+
if (typeof each_js_1.each.before.cb === 'function') {
|
|
30
|
+
const beforeResult = each_js_1.each.before.cb();
|
|
31
|
+
if (beforeResult instanceof Promise)
|
|
32
|
+
yield beforeResult;
|
|
33
|
+
}
|
|
34
|
+
const cbResult = cb();
|
|
35
|
+
if (cbResult instanceof Promise)
|
|
36
|
+
yield cbResult;
|
|
37
|
+
if (typeof each_js_1.each.after.cb === 'function') {
|
|
38
|
+
const afterResult = each_js_1.each.after.cb();
|
|
39
|
+
if (afterResult instanceof Promise)
|
|
40
|
+
yield afterResult;
|
|
41
|
+
}
|
|
36
42
|
if (typeof options.message === 'string') {
|
|
37
43
|
const message = isPoku
|
|
38
44
|
? `${format_js_1.format.bold(format_js_1.format.success(`✔ ${options.message}`))} ${format_js_1.format.dim(format_js_1.format.success(`› ${FILE}`))}`
|
|
@@ -43,7 +49,7 @@ const parseAssertion = (cb, options) => {
|
|
|
43
49
|
catch (error) {
|
|
44
50
|
if (error instanceof node_assert_1.default.AssertionError) {
|
|
45
51
|
const { code, actual, expected, operator } = error;
|
|
46
|
-
const absoultePath = findFile(error);
|
|
52
|
+
const absoultePath = (0, find_file_js_1.findFile)(error).replace(/file:(\/\/)?/, '');
|
|
47
53
|
const file = node_path_1.default.relative(node_path_1.default.resolve(node_process_1.default.cwd()), absoultePath);
|
|
48
54
|
let message = '';
|
|
49
55
|
if (typeof options.message === 'string')
|
|
@@ -53,8 +59,8 @@ const parseAssertion = (cb, options) => {
|
|
|
53
59
|
else if (typeof options.defaultMessage === 'string')
|
|
54
60
|
message = options.defaultMessage;
|
|
55
61
|
const finalMessage = (message === null || message === void 0 ? void 0 : message.trim().length) > 0
|
|
56
|
-
?
|
|
57
|
-
:
|
|
62
|
+
? format_js_1.format.bold(format_js_1.format.fail(`✘ ${message}`))
|
|
63
|
+
: format_js_1.format.bold(format_js_1.format.fail('✘ No Message'));
|
|
58
64
|
console.log(isPoku
|
|
59
65
|
? `${finalMessage} ${format_js_1.format.dim(format_js_1.format.fail(`› ${FILE}`))}`
|
|
60
66
|
: finalMessage);
|
|
@@ -80,5 +86,5 @@ const parseAssertion = (cb, options) => {
|
|
|
80
86
|
// Non-assertion errors
|
|
81
87
|
throw error;
|
|
82
88
|
}
|
|
83
|
-
};
|
|
89
|
+
});
|
|
84
90
|
exports.parseAssertion = parseAssertion;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { poku } from './modules/poku.js';
|
|
2
2
|
export { exit } from './modules/exit.js';
|
|
3
3
|
export { assert } from './modules/assert.js';
|
|
4
|
+
export { describe, log } from './modules/describe.js';
|
|
4
5
|
export { assertPromise } from './modules/assert-promise.js';
|
|
5
6
|
export { beforeEach, afterEach } from './modules/each.js';
|
|
6
7
|
export { publicListFiles as listFiles } from './modules/list-files.js';
|
package/lib/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.listFiles = exports.afterEach = exports.beforeEach = exports.assertPromise = exports.assert = exports.exit = exports.poku = void 0;
|
|
3
|
+
exports.listFiles = exports.afterEach = exports.beforeEach = exports.assertPromise = exports.log = exports.describe = exports.assert = exports.exit = exports.poku = void 0;
|
|
4
4
|
var poku_js_1 = require("./modules/poku.js");
|
|
5
5
|
Object.defineProperty(exports, "poku", { enumerable: true, get: function () { return poku_js_1.poku; } });
|
|
6
6
|
var exit_js_1 = require("./modules/exit.js");
|
|
7
7
|
Object.defineProperty(exports, "exit", { enumerable: true, get: function () { return exit_js_1.exit; } });
|
|
8
8
|
var assert_js_1 = require("./modules/assert.js");
|
|
9
9
|
Object.defineProperty(exports, "assert", { enumerable: true, get: function () { return assert_js_1.assert; } });
|
|
10
|
+
var describe_js_1 = require("./modules/describe.js");
|
|
11
|
+
Object.defineProperty(exports, "describe", { enumerable: true, get: function () { return describe_js_1.describe; } });
|
|
12
|
+
Object.defineProperty(exports, "log", { enumerable: true, get: function () { return describe_js_1.log; } });
|
|
10
13
|
var assert_promise_js_1 = require("./modules/assert-promise.js");
|
|
11
14
|
Object.defineProperty(exports, "assertPromise", { enumerable: true, get: function () { return assert_promise_js_1.assertPromise; } });
|
|
12
15
|
var each_js_1 = require("./modules/each.js");
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as nodeAssert from 'node:assert';
|
|
3
3
|
import { ParseAssertionOptions } from '../helpers/parseAsssetion.js';
|
|
4
|
-
declare function
|
|
5
|
-
declare function
|
|
6
|
-
declare function
|
|
7
|
-
declare function
|
|
8
|
-
declare function throws(block: () => unknown, message?: ParseAssertionOptions['message']): void;
|
|
9
|
-
declare function throws(block: () => unknown, error: nodeAssert.AssertPredicate, message?: ParseAssertionOptions['message']): void;
|
|
4
|
+
declare function doesNotThrow(block: () => unknown, message?: string | ParseAssertionOptions['message']): Promise<void>;
|
|
5
|
+
declare function doesNotThrow(block: () => unknown, error: nodeAssert.AssertPredicate, message?: ParseAssertionOptions['message']): Promise<void>;
|
|
6
|
+
declare function throws(block: () => unknown, message?: ParseAssertionOptions['message']): Promise<void>;
|
|
7
|
+
declare function throws(block: () => unknown, error: nodeAssert.AssertPredicate, message?: ParseAssertionOptions['message']): Promise<void>;
|
|
10
8
|
declare function rejects(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
|
|
11
9
|
declare function rejects(block: (() => Promise<unknown>) | Promise<unknown>, error: nodeAssert.AssertPredicate, message?: string | Error): Promise<void>;
|
|
10
|
+
declare function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
|
|
11
|
+
declare function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, error: nodeAssert.AssertPredicate, message?: string | Error): Promise<void>;
|
|
12
12
|
export declare const assertPromise: ((value: unknown, message?: ParseAssertionOptions['message']) => Promise<void>) & {
|
|
13
13
|
ok: (value: unknown, message?: ParseAssertionOptions['message']) => Promise<void>;
|
|
14
14
|
equal: (actual: unknown, expected: unknown, message?: ParseAssertionOptions['message']) => Promise<void>;
|
|
@@ -25,7 +25,7 @@ export declare const assertPromise: ((value: unknown, message?: ParseAssertionOp
|
|
|
25
25
|
notDeepStrictEqual: (actual: unknown, expected: unknown, message?: ParseAssertionOptions['message']) => Promise<void>;
|
|
26
26
|
match: (value: string, regExp: RegExp, message?: ParseAssertionOptions['message']) => Promise<void>;
|
|
27
27
|
ifError: (value: unknown) => Promise<void>;
|
|
28
|
-
fail: (message?: ParseAssertionOptions['message']) => void
|
|
28
|
+
fail: (message?: ParseAssertionOptions['message']) => Promise<void>;
|
|
29
29
|
rejects: typeof rejects;
|
|
30
30
|
};
|
|
31
31
|
export {};
|