@nestia/e2e 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Jeongho Nam
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # Nestia E2E Helper
2
+ [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/samchon/nestia/blob/master/LICENSE)
3
+ [![npm version](https://img.shields.io/npm/v/@nestia/e2e.svg)](https://www.npmjs.com/package/@nestia/e2e)
4
+ [![Downloads](https://img.shields.io/npm/dm/@nestia/e2e.svg)](https://www.npmjs.com/package/@nestia/e2e)
5
+ [![Build Status](https://github.com/samchon/typia/workflows/build/badge.svg)](https://github.com/samchon/nestia/actions?query=workflow%3Abuild)
6
+ [![Guide Documents](https://img.shields.io/badge/wiki-documentation-forestgreen)](https://github.com/samchon/nestia/wiki)
7
+
8
+ Helper library for E2E testing in NestJS.
9
+
10
+ With `@nestia/e2e`, you can easily validate your NestJS server through E2E testing.
11
+
12
+ ```typescript
13
+ import typia from "typia";
14
+ import {
15
+ ArrayUtil,
16
+ GaffComparator,
17
+ RandomGenerator,
18
+ TestValidator
19
+ } from "@nestia/e2e";
20
+
21
+ import api from "@samchon/bbs-api/lib/index";
22
+ import { IBbsArticle } from "@samchon/bbs-api/lib/structures/bbs/IBbsArticle";
23
+
24
+ export async function test_api_bbs_article_index_sort(
25
+ connection: api.IConnection,
26
+ ): Promise<void> {
27
+ // GENERATE 100 ARTICLES
28
+ const section: string = "general";
29
+ const articles: IBbsArticle[] = await ArrayUtil.asyncRepeat(100, () =>
30
+ api.functional.bbs.articles.store(connection, section, {
31
+ writer: RandomGenerator.name(),
32
+ title: RandomGenerator.paragraph(),
33
+ body: RandomGenerator.content(),
34
+ format: "txt",
35
+ files: [],
36
+ password: RandomGenerator.alphabets(8),
37
+ }),
38
+ );
39
+ typia.assertEquals(articles);
40
+
41
+ // PREPARE VALIDATOR
42
+ const validator = validate_index_sort("BbsArticleProvider.idex()")(
43
+ (input: IBbsArticle.IRequest) =>
44
+ api.functional.bbs.articles.index(connection, section, input),
45
+ );
46
+
47
+ // DO VALIDATE
48
+ const components = [
49
+ validator("created_at")(GaffComparator.dates((x) => x.created_at)),
50
+ validator("updated_at")(GaffComparator.dates((x) => x.updated_at)),
51
+ validator("title")(GaffComparator.strings((x) => x.title)),
52
+ validator("writer")(GaffComparator.strings((x) => x.writer)),
53
+ validator(
54
+ "writer",
55
+ "title",
56
+ )(GaffComparator.strings((x) => [x.writer, x.title])),
57
+ ];
58
+ for (const comp of components) {
59
+ await comp("+");
60
+ await comp("-");
61
+ }
62
+ }
63
+ ```
64
+
65
+
66
+
67
+
68
+ ## Setup
69
+ ```bash
70
+ npm install --save-dev @nestia/e2e
71
+ ```
72
+
73
+ Just setup with npm command, that's all.
74
+
75
+ For referece, due to test program would not be published, I rcommend to install as `dev` mode.
76
+
77
+
78
+
79
+
80
+ ## Features
81
+ About supported features, read descriptive comments of below:
82
+
83
+ - [`ArrayUtil`](https://github.com/samchon/nestia/tree/master/packages/e2e/src/ArrayUtil.ts)
84
+ - [`GaffComparator`](https://github.com/samchon/nestia/tree/master/packages/e2e/src/GaffComparator.ts)
85
+ - [`RandomGenerator`](https://github.com/samchon/nestia/tree/master/packages/e2e/src/RandomGenerator.ts)
86
+ - [`StopWatch`](https://github.com/samchon/nestia/tree/master/packages/e2e/src/StopWatch.ts)
87
+ - [`TestValidator`](https://github.com/samchon/nestia/tree/master/packages/e2e/src/TestValidator.ts)
@@ -0,0 +1,11 @@
1
+ export declare namespace ArrayUtil {
2
+ function at<T>(array: T[], index: number): T;
3
+ function asyncFilter<Input>(elements: readonly Input[], pred: (elem: Input, index: number, array: readonly Input[]) => Promise<boolean>): Promise<Input[]>;
4
+ function asyncForEach<Input>(elements: readonly Input[], closure: (elem: Input, index: number, array: readonly Input[]) => Promise<any>): Promise<void>;
5
+ function asyncMap<Input, Output>(elements: readonly Input[], closure: (elem: Input, index: number, array: readonly Input[]) => Promise<Output>): Promise<Output[]>;
6
+ function asyncRepeat<T>(count: number, closure: (index: number) => Promise<T>): Promise<T[]>;
7
+ function has<T>(elements: readonly T[], pred: (elem: T) => boolean): boolean;
8
+ function repeat<T>(count: number, closure: (index: number) => T): T[];
9
+ function last<T>(array: T[]): T;
10
+ function flat<T>(matrix: T[][]): T[];
11
+ }
@@ -0,0 +1,216 @@
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
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __values = (this && this.__values) || function(o) {
39
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
40
+ if (m) return m.call(o);
41
+ if (o && typeof o.length === "number") return {
42
+ next: function () {
43
+ if (o && i >= o.length) o = void 0;
44
+ return { value: o && o[i++], done: !o };
45
+ }
46
+ };
47
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
48
+ };
49
+ var __read = (this && this.__read) || function (o, n) {
50
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
51
+ if (!m) return o;
52
+ var i = m.call(o), r, ar = [], e;
53
+ try {
54
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
55
+ }
56
+ catch (error) { e = { error: error }; }
57
+ finally {
58
+ try {
59
+ if (r && !r.done && (m = i["return"])) m.call(i);
60
+ }
61
+ finally { if (e) throw e.error; }
62
+ }
63
+ return ar;
64
+ };
65
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
66
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
67
+ if (ar || !(i in from)) {
68
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
69
+ ar[i] = from[i];
70
+ }
71
+ }
72
+ return to.concat(ar || Array.prototype.slice.call(from));
73
+ };
74
+ Object.defineProperty(exports, "__esModule", { value: true });
75
+ exports.ArrayUtil = void 0;
76
+ var ArrayUtil;
77
+ (function (ArrayUtil) {
78
+ function at(array, index) {
79
+ return array[index < 0 ? array.length + index : index];
80
+ }
81
+ ArrayUtil.at = at;
82
+ function asyncFilter(elements, pred) {
83
+ return __awaiter(this, void 0, void 0, function () {
84
+ var ret;
85
+ var _this = this;
86
+ return __generator(this, function (_a) {
87
+ switch (_a.label) {
88
+ case 0:
89
+ ret = [];
90
+ return [4 /*yield*/, asyncForEach(elements, function (elem, index, array) { return __awaiter(_this, void 0, void 0, function () {
91
+ var flag;
92
+ return __generator(this, function (_a) {
93
+ switch (_a.label) {
94
+ case 0: return [4 /*yield*/, pred(elem, index, array)];
95
+ case 1:
96
+ flag = _a.sent();
97
+ if (flag === true)
98
+ ret.push(elem);
99
+ return [2 /*return*/];
100
+ }
101
+ });
102
+ }); })];
103
+ case 1:
104
+ _a.sent();
105
+ return [2 /*return*/, ret];
106
+ }
107
+ });
108
+ });
109
+ }
110
+ ArrayUtil.asyncFilter = asyncFilter;
111
+ function asyncForEach(elements, closure) {
112
+ return __awaiter(this, void 0, void 0, function () {
113
+ return __generator(this, function (_a) {
114
+ switch (_a.label) {
115
+ case 0: return [4 /*yield*/, asyncRepeat(elements.length, function (index) {
116
+ return closure(elements[index], index, elements);
117
+ })];
118
+ case 1:
119
+ _a.sent();
120
+ return [2 /*return*/];
121
+ }
122
+ });
123
+ });
124
+ }
125
+ ArrayUtil.asyncForEach = asyncForEach;
126
+ function asyncMap(elements, closure) {
127
+ return __awaiter(this, void 0, void 0, function () {
128
+ var ret;
129
+ var _this = this;
130
+ return __generator(this, function (_a) {
131
+ switch (_a.label) {
132
+ case 0:
133
+ ret = [];
134
+ return [4 /*yield*/, asyncForEach(elements, function (elem, index, array) { return __awaiter(_this, void 0, void 0, function () {
135
+ var output;
136
+ return __generator(this, function (_a) {
137
+ switch (_a.label) {
138
+ case 0: return [4 /*yield*/, closure(elem, index, array)];
139
+ case 1:
140
+ output = _a.sent();
141
+ ret.push(output);
142
+ return [2 /*return*/];
143
+ }
144
+ });
145
+ }); })];
146
+ case 1:
147
+ _a.sent();
148
+ return [2 /*return*/, ret];
149
+ }
150
+ });
151
+ });
152
+ }
153
+ ArrayUtil.asyncMap = asyncMap;
154
+ function asyncRepeat(count, closure) {
155
+ return __awaiter(this, void 0, void 0, function () {
156
+ var indexes, output, indexes_1, indexes_1_1, index, _a, _b, e_1_1;
157
+ var e_1, _c;
158
+ return __generator(this, function (_d) {
159
+ switch (_d.label) {
160
+ case 0:
161
+ indexes = new Array(count)
162
+ .fill(1)
163
+ .map(function (_, index) { return index; });
164
+ output = [];
165
+ _d.label = 1;
166
+ case 1:
167
+ _d.trys.push([1, 6, 7, 8]);
168
+ indexes_1 = __values(indexes), indexes_1_1 = indexes_1.next();
169
+ _d.label = 2;
170
+ case 2:
171
+ if (!!indexes_1_1.done) return [3 /*break*/, 5];
172
+ index = indexes_1_1.value;
173
+ _b = (_a = output).push;
174
+ return [4 /*yield*/, closure(index)];
175
+ case 3:
176
+ _b.apply(_a, [_d.sent()]);
177
+ _d.label = 4;
178
+ case 4:
179
+ indexes_1_1 = indexes_1.next();
180
+ return [3 /*break*/, 2];
181
+ case 5: return [3 /*break*/, 8];
182
+ case 6:
183
+ e_1_1 = _d.sent();
184
+ e_1 = { error: e_1_1 };
185
+ return [3 /*break*/, 8];
186
+ case 7:
187
+ try {
188
+ if (indexes_1_1 && !indexes_1_1.done && (_c = indexes_1.return)) _c.call(indexes_1);
189
+ }
190
+ finally { if (e_1) throw e_1.error; }
191
+ return [7 /*endfinally*/];
192
+ case 8: return [2 /*return*/, output];
193
+ }
194
+ });
195
+ });
196
+ }
197
+ ArrayUtil.asyncRepeat = asyncRepeat;
198
+ function has(elements, pred) {
199
+ return elements.find(pred) !== undefined;
200
+ }
201
+ ArrayUtil.has = has;
202
+ function repeat(count, closure) {
203
+ return new Array(count).fill("").map(function (_, index) { return closure(index); });
204
+ }
205
+ ArrayUtil.repeat = repeat;
206
+ function last(array) {
207
+ return array[array.length - 1];
208
+ }
209
+ ArrayUtil.last = last;
210
+ function flat(matrix) {
211
+ var _a;
212
+ return (_a = []).concat.apply(_a, __spreadArray([], __read(matrix), false));
213
+ }
214
+ ArrayUtil.flat = flat;
215
+ })(ArrayUtil = exports.ArrayUtil || (exports.ArrayUtil = {}));
216
+ //# sourceMappingURL=ArrayUtil.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArrayUtil.js","sourceRoot":"","sources":["../src/ArrayUtil.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAiB,SAAS,CAqFzB;AArFD,WAAiB,SAAS;IACtB,SAAgB,EAAE,CAAI,KAA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AAM,oCAAI,MAAM,WAAE;IACzC,CAAC;IAFe,cAAI,OAEnB,CAAA;AACL,CAAC,EArFgB,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAqFzB"}
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Dynamic Executor running prefixed functions.
3
+ *
4
+ * `DynamicExecutor` runs every prefixed functions in a specific directory.
5
+ * However, if you want to run only specific functions, you can use
6
+ * `--include` or `--exclude` option in the CLI (Command Line Interface) level.
7
+ *
8
+ * When you want to see example utilization cases, see the below example links.
9
+ *
10
+ * @example https://github.com/samchon/backend/blob/master/src/test/index.ts
11
+ * @example https://github.com/samchon/nestia-template/blob/master/src/test/index.ts
12
+ * @author Jeongho Nam - https://github.com/samchon
13
+ */
14
+ export declare namespace DynamicExecutor {
15
+ /**
16
+ * Function type of a prefixed.
17
+ *
18
+ * @template Arguments Type of parameters
19
+ * @template Ret Type of return value
20
+ */
21
+ interface Closure<Arguments extends any[], Ret = any> {
22
+ (...args: Arguments): Promise<Ret>;
23
+ }
24
+ /**
25
+ * Options for dynamic executor.
26
+ */
27
+ interface IOptions<Parameters extends any[], Ret = any> {
28
+ /**
29
+ * Prefix of function name.
30
+ *
31
+ * Every prefixed function will be executed.
32
+ *
33
+ * In other words, if a function name doesn't start with the prefix, then it would never be executed.
34
+ */
35
+ prefix: string;
36
+ /**
37
+ * Get parameters of a function.
38
+ *
39
+ * @param name Function name
40
+ * @returns Parameters
41
+ */
42
+ parameters: (name: string) => Parameters;
43
+ /**
44
+ * Wrapper of test function.
45
+ *
46
+ * If you specify this `wrapper` property, every dynamic functions
47
+ * loaded and called by this `DynamicExecutor` would be wrapped by
48
+ * the `wrapper` function.
49
+ *
50
+ * @param name Function name
51
+ * @param closure Function to be executed
52
+ * @returns Wrapper function
53
+ */
54
+ wrapper?: (name: string, closure: Closure<Parameters, Ret>) => Promise<any>;
55
+ /**
56
+ * Whether to show elapsed time on `console` or not.
57
+ *
58
+ * @default true
59
+ */
60
+ showElapsedTime?: boolean;
61
+ }
62
+ /**
63
+ * Report, result of dynamic execution.
64
+ */
65
+ interface IReport {
66
+ /**
67
+ * Location path of dynamic functions.
68
+ */
69
+ location: string;
70
+ /**
71
+ * Execution results of dynamic functions.
72
+ */
73
+ executions: IReport.IExecution[];
74
+ /**
75
+ * Total elapsed time.
76
+ */
77
+ time: number;
78
+ }
79
+ namespace IReport {
80
+ /**
81
+ * Execution result of a dynamic function.
82
+ */
83
+ interface IExecution {
84
+ /**
85
+ * Name of function.
86
+ */
87
+ name: string;
88
+ /**
89
+ * Location path of the function.
90
+ */
91
+ location: string;
92
+ /**
93
+ * Error when occured.
94
+ */
95
+ error: Error | null;
96
+ /**
97
+ * Elapsed time.
98
+ */
99
+ time: number;
100
+ }
101
+ }
102
+ /**
103
+ * Prepare dynamic executor in strict mode.
104
+ *
105
+ * In strict mode, if any error occurs, the program will be terminated directly.
106
+ * Otherwise, {@link validate} mode does not terminate when error occurs, but
107
+ * just archive the error log.
108
+ *
109
+ * @param options Options of dynamic executor
110
+ * @returns Runner of dynamic functions with specific location
111
+ */
112
+ const assert: <Arguments extends any[]>(options: IOptions<Arguments, any>) => (path: string) => Promise<IReport>;
113
+ /**
114
+ * Prepare dynamic executor in loose mode.
115
+ *
116
+ * In loose mode, the program would not be terminated even when error occurs.
117
+ * Instead, the error would be archived and returns as a list. Otherwise,
118
+ * {@link assert} mode terminates the program directly when error occurs.
119
+ *
120
+ * @param options Options of dynamic executor
121
+ * @returns Runner of dynamic functions with specific location
122
+ */
123
+ const validate: <Arguments extends any[]>(options: IOptions<Arguments, any>) => (path: string) => Promise<IReport>;
124
+ }