poku 1.7.0 → 1.8.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 CHANGED
@@ -167,6 +167,25 @@ deno run npm:poku
167
167
 
168
168
  ---
169
169
 
170
+ ## Available Methods
171
+
172
+ ### Essentials
173
+
174
+ - `poku` (_test runner_)
175
+ - `assert` and `assertPromise` (_test assertion_)
176
+
177
+ ### Helpers
178
+
179
+ - `beforeEach` and `afterEach`
180
+ - `test`
181
+ - `describe` and `log`
182
+ - `listFiles`
183
+ - `exit`
184
+
185
+ [**See the complete documentation**](https://poku.io/docs).
186
+
187
+ ---
188
+
170
189
  ## Overview
171
190
 
172
191
  ### `poku`
@@ -5,6 +5,8 @@ export type Control = {
5
5
  };
6
6
  export type EachConfigs = {
7
7
  status: boolean;
8
+ assert?: boolean;
9
+ test?: boolean;
8
10
  cb?: () => unknown | Promise<unknown>;
9
11
  };
10
12
  export declare const each: {
@@ -5,9 +5,13 @@ exports.each = {
5
5
  before: {
6
6
  status: true,
7
7
  cb: undefined,
8
+ assert: true,
9
+ test: true,
8
10
  },
9
11
  after: {
10
12
  status: true,
11
13
  cb: undefined,
14
+ assert: true,
15
+ test: true,
12
16
  },
13
17
  };
@@ -26,7 +26,7 @@ const parseAssertion = (cb, options) => __awaiter(void 0, void 0, void 0, functi
26
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;
27
27
  const FILE = node_process_1.default.env.FILE;
28
28
  try {
29
- if (typeof each_js_1.each.before.cb === 'function') {
29
+ if (typeof each_js_1.each.before.cb === 'function' && each_js_1.each.before.assert) {
30
30
  const beforeResult = each_js_1.each.before.cb();
31
31
  if (beforeResult instanceof Promise)
32
32
  yield beforeResult;
@@ -34,7 +34,7 @@ const parseAssertion = (cb, options) => __awaiter(void 0, void 0, void 0, functi
34
34
  const cbResult = cb();
35
35
  if (cbResult instanceof Promise)
36
36
  yield cbResult;
37
- if (typeof each_js_1.each.after.cb === 'function') {
37
+ if (typeof each_js_1.each.after.cb === 'function' && each_js_1.each.after.assert) {
38
38
  const afterResult = each_js_1.each.after.cb();
39
39
  if (afterResult instanceof Promise)
40
40
  yield afterResult;
package/lib/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export { describe, log } from './modules/describe.js';
5
5
  export { assertPromise } from './modules/assert-promise.js';
6
6
  export { beforeEach, afterEach } from './modules/each.js';
7
7
  export { publicListFiles as listFiles } from './modules/list-files.js';
8
+ export { test } from './modules/test.js';
8
9
  export type { Code } from './@types/code.ts';
9
10
  export type { Configs } from './@types/poku.ts';
10
11
  export type { Configs as ListFilesConfigs } from './@types/list-files.ts';
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listFiles = exports.afterEach = exports.beforeEach = exports.assertPromise = exports.log = exports.describe = exports.assert = exports.exit = exports.poku = void 0;
3
+ exports.test = 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");
@@ -17,3 +17,5 @@ Object.defineProperty(exports, "beforeEach", { enumerable: true, get: function (
17
17
  Object.defineProperty(exports, "afterEach", { enumerable: true, get: function () { return each_js_1.afterEach; } });
18
18
  var list_files_js_1 = require("./modules/list-files.js");
19
19
  Object.defineProperty(exports, "listFiles", { enumerable: true, get: function () { return list_files_js_1.publicListFiles; } });
20
+ var test_js_1 = require("./modules/test.js");
21
+ Object.defineProperty(exports, "test", { enumerable: true, get: function () { return test_js_1.test; } });
@@ -1,6 +1,8 @@
1
1
  import { Control } from '../configs/each.js';
2
2
  type EachOptions = {
3
3
  immediate?: boolean;
4
+ test?: boolean;
5
+ assert?: boolean;
4
6
  };
5
7
  /**
6
8
  * - ✅ Handling **global** and **external** services (_preparing a database, for example_)
@@ -45,5 +47,5 @@ export declare const beforeEach: (callback: () => unknown, options?: EachOptions
45
47
  * after.reset();
46
48
  * ```
47
49
  */
48
- export declare const afterEach: (callback: () => unknown) => Control;
50
+ export declare const afterEach: (callback: () => unknown, options: Omit<EachOptions, 'immediate'>) => Control;
49
51
  export {};
@@ -24,6 +24,9 @@ const each_js_1 = require("../configs/each.js");
24
24
  * ```
25
25
  */
26
26
  const beforeEach = (callback, options) => {
27
+ each_js_1.each.before.test = typeof (options === null || options === void 0 ? void 0 : options.test) === 'boolean' ? options.test : true;
28
+ each_js_1.each.before.assert =
29
+ typeof (options === null || options === void 0 ? void 0 : options.assert) === 'boolean' ? options.assert : true;
27
30
  (options === null || options === void 0 ? void 0 : options.immediate) && callback();
28
31
  each_js_1.each.before.cb = () => {
29
32
  if (each_js_1.each.before.status)
@@ -62,7 +65,10 @@ exports.beforeEach = beforeEach;
62
65
  * after.reset();
63
66
  * ```
64
67
  */
65
- const afterEach = (callback) => {
68
+ const afterEach = (callback, options) => {
69
+ each_js_1.each.after.test = typeof (options === null || options === void 0 ? void 0 : options.test) === 'boolean' ? options.test : true;
70
+ each_js_1.each.after.assert =
71
+ typeof (options === null || options === void 0 ? void 0 : options.assert) === 'boolean' ? options.assert : true;
66
72
  each_js_1.each.after.cb = () => {
67
73
  if (each_js_1.each.after.status)
68
74
  callback();
@@ -0,0 +1,2 @@
1
+ export declare function test(cb: () => Promise<unknown>): Promise<void>;
2
+ export declare function test(cb: () => unknown): void;
@@ -0,0 +1,31 @@
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
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.test = void 0;
13
+ const each_js_1 = require("../configs/each.js");
14
+ function test(cb) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ if (typeof each_js_1.each.before.cb === 'function' && each_js_1.each.before.test) {
17
+ const beforeResult = each_js_1.each.before.cb();
18
+ if (beforeResult instanceof Promise)
19
+ yield beforeResult;
20
+ }
21
+ const resultCb = cb();
22
+ if (resultCb instanceof Promise)
23
+ yield resultCb;
24
+ if (typeof each_js_1.each.after.cb === 'function' && each_js_1.each.after.test) {
25
+ const afterResult = each_js_1.each.after.cb();
26
+ if (afterResult instanceof Promise)
27
+ yield afterResult;
28
+ }
29
+ });
30
+ }
31
+ exports.test = test;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poku",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "🐷 Poku makes testing easy for Node.js, Bun & Deno at the same time.",
5
5
  "main": "./lib/index.js",
6
6
  "scripts": {