Socket
Socket
Sign inDemoInstall

@nestia/e2e

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestia/e2e - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

7

lib/DynamicExecutor.d.ts

@@ -44,2 +44,9 @@ /**

/**
* Filter function whether to run or not.
*
* @param name Function name
* @returns Whether to run or not
*/
filter?: (name: string) => boolean;
/**
* Wrapper of test function.

@@ -46,0 +53,0 @@ *

212

lib/DynamicExecutor.js

@@ -103,3 +103,2 @@ "use strict";

var chalk_1 = __importDefault(require("chalk"));
var cli_1 = __importDefault(require("cli"));
var fs_1 = __importDefault(require("fs"));

@@ -168,7 +167,6 @@ var path_1 = __importDefault(require("path"));

return function (path) { return __awaiter(_this, void 0, void 0, function () {
var command, report, executor, iterator;
var report, executor, iterator;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
command = cli_1.default.parse();
report = {

@@ -179,3 +177,3 @@ location: path,

};
executor = execute(options)(command)(report)(assert);
executor = execute(options)(report)(assert);
iterator = iterate(executor);

@@ -251,107 +249,103 @@ return [4 /*yield*/, iterator(path)];

var execute = function (options) {
return function (command) {
return function (report) {
return function (assert) {
return function (location, modulo) { return __awaiter(_this, void 0, void 0, function () {
var _loop_1, _a, _b, _c, _i, key, state_1;
var _this = this;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
_loop_1 = function (key) {
var closure, func, label, result, _e, exp_1;
return __generator(this, function (_f) {
switch (_f.label) {
case 0:
if (command.exclude && key.indexOf(command.exclude) !== -1)
return [2 /*return*/, "continue"];
else if (command.include && key.indexOf(command.include) === -1)
return [2 /*return*/, "continue"];
else if (key.substring(0, options.prefix.length) !== options.prefix)
return [2 /*return*/, "continue"];
else if (!(modulo[key] instanceof Function))
return [2 /*return*/, "continue"];
closure = modulo[key];
func = function () { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(options.wrapper !== undefined)) return [3 /*break*/, 2];
return [4 /*yield*/, options.wrapper(key, closure)];
case 1:
_a.sent();
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, closure.apply(void 0, __spreadArray([], __read(options.parameters(key)), false))];
case 3:
_a.sent();
_a.label = 4;
case 4: return [2 /*return*/];
}
});
}); };
label = chalk_1.default.greenBright(key);
result = {
name: key,
location: location,
error: null,
time: Date.now(),
};
report.executions.push(result);
_f.label = 1;
case 1:
_f.trys.push([1, 6, , 7]);
if (!(options.showElapsedTime === false)) return [3 /*break*/, 3];
return [4 /*yield*/, func()];
case 2:
_f.sent();
result.time = Date.now() - result.time;
console.log(" - ".concat(label));
return [3 /*break*/, 5];
case 3:
_e = result;
return [4 /*yield*/, StopWatch_1.StopWatch.measure(func)];
case 4:
_e.time = _f.sent();
console.log(" - ".concat(label, ": ").concat(chalk_1.default.yellowBright(result.time.toLocaleString()), " ms"));
_f.label = 5;
case 5: return [3 /*break*/, 7];
case 6:
exp_1 = _f.sent();
if (!(exp_1 instanceof Error))
return [2 /*return*/, { value: void 0 }];
result.time = Date.now() - result.time;
result.error = exp_1;
console.log(" - ".concat(label, " -> ").concat(chalk_1.default.redBright(exp_1.name)));
if (assert === true)
throw exp_1;
return [3 /*break*/, 7];
case 7: return [2 /*return*/];
}
});
};
_a = modulo;
_b = [];
for (_c in _a)
_b.push(_c);
_i = 0;
_d.label = 1;
case 1:
if (!(_i < _b.length)) return [3 /*break*/, 4];
_c = _b[_i];
if (!(_c in _a)) return [3 /*break*/, 3];
key = _c;
return [5 /*yield**/, _loop_1(key)];
case 2:
state_1 = _d.sent();
if (typeof state_1 === "object")
return [2 /*return*/, state_1.value];
_d.label = 3;
case 3:
_i++;
return [3 /*break*/, 1];
case 4: return [2 /*return*/];
}
});
}); };
};
return function (report) {
return function (assert) {
return function (location, modulo) { return __awaiter(_this, void 0, void 0, function () {
var _loop_1, _a, _b, _c, _i, key, state_1;
var _this = this;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
_loop_1 = function (key) {
var closure, func, label, result, _e, exp_1;
return __generator(this, function (_f) {
switch (_f.label) {
case 0:
if (key.substring(0, options.prefix.length) !== options.prefix)
return [2 /*return*/, "continue"];
else if (!(modulo[key] instanceof Function))
return [2 /*return*/, "continue"];
else if (options.filter && options.filter(key) === false)
return [2 /*return*/, "continue"];
closure = modulo[key];
func = function () { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(options.wrapper !== undefined)) return [3 /*break*/, 2];
return [4 /*yield*/, options.wrapper(key, closure)];
case 1:
_a.sent();
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, closure.apply(void 0, __spreadArray([], __read(options.parameters(key)), false))];
case 3:
_a.sent();
_a.label = 4;
case 4: return [2 /*return*/];
}
});
}); };
label = chalk_1.default.greenBright(key);
result = {
name: key,
location: location,
error: null,
time: Date.now(),
};
report.executions.push(result);
_f.label = 1;
case 1:
_f.trys.push([1, 6, , 7]);
if (!(options.showElapsedTime === false)) return [3 /*break*/, 3];
return [4 /*yield*/, func()];
case 2:
_f.sent();
result.time = Date.now() - result.time;
console.log(" - ".concat(label));
return [3 /*break*/, 5];
case 3:
_e = result;
return [4 /*yield*/, StopWatch_1.StopWatch.measure(func)];
case 4:
_e.time = _f.sent();
console.log(" - ".concat(label, ": ").concat(chalk_1.default.yellowBright(result.time.toLocaleString()), " ms"));
_f.label = 5;
case 5: return [3 /*break*/, 7];
case 6:
exp_1 = _f.sent();
if (!(exp_1 instanceof Error))
return [2 /*return*/, { value: void 0 }];
result.time = Date.now() - result.time;
result.error = exp_1;
console.log(" - ".concat(label, " -> ").concat(chalk_1.default.redBright(exp_1.name)));
if (assert === true)
throw exp_1;
return [3 /*break*/, 7];
case 7: return [2 /*return*/];
}
});
};
_a = modulo;
_b = [];
for (_c in _a)
_b.push(_c);
_i = 0;
_d.label = 1;
case 1:
if (!(_i < _b.length)) return [3 /*break*/, 4];
_c = _b[_i];
if (!(_c in _a)) return [3 /*break*/, 3];
key = _c;
return [5 /*yield**/, _loop_1(key)];
case 2:
state_1 = _d.sent();
if (typeof state_1 === "object")
return [2 /*return*/, state_1.value];
_d.label = 3;
case 3:
_i++;
return [3 /*break*/, 1];
case 4: return [2 /*return*/];
}
});
}); };
};

@@ -358,0 +352,0 @@ };

{
"name": "@nestia/e2e",
"version": "0.1.1",
"version": "0.1.2",
"description": "E2E test utilify functions",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -0,0 +0,0 @@ /**

import chalk from "chalk";
import cli from "cli";
import fs from "fs";

@@ -54,2 +53,10 @@ import NodePath from "path";

/**
* Filter function whether to run or not.
*
* @param name Function name
* @returns Whether to run or not
*/
filter?: (name: string) => boolean;
/**
* Wrapper of test function.

@@ -169,3 +176,2 @@ *

async (path: string) => {
const command: ICommand = cli.parse();
const report: IReport = {

@@ -177,3 +183,3 @@ location: path,

const executor = execute(options)(command)(report)(assert);
const executor = execute(options)(report)(assert);
const iterator = iterate(executor);

@@ -209,3 +215,2 @@ await iterator(path);

<Arguments extends any[]>(options: IOptions<Arguments>) =>
(command: ICommand) =>
(report: IReport) =>

@@ -215,11 +220,7 @@ (assert: boolean) =>

for (const key in modulo) {
if (command.exclude && key.indexOf(command.exclude) !== -1)
if (key.substring(0, options.prefix.length) !== options.prefix)
continue;
else if (command.include && key.indexOf(command.include) === -1)
else if (!(modulo[key] instanceof Function)) continue;
else if (options.filter && options.filter(key) === false)
continue;
else if (
key.substring(0, options.prefix.length) !== options.prefix
)
continue;
else if (!(modulo[key] instanceof Function)) continue;

@@ -267,6 +268,2 @@ const closure: Closure<Arguments> = modulo[key];

interface ICommand {
include?: string;
exclude?: string;
}
interface Module<Arguments extends any[]> {

@@ -273,0 +270,0 @@ [key: string]: Closure<Arguments>;

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ import * as e2e from "./module";

@@ -0,0 +0,0 @@ export * from "./ArrayUtil";

@@ -0,0 +0,0 @@ import { back_inserter, randint } from "tstl";

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ import { is_sorted } from "tstl/ranges";

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc