Comparing version 10.2.1 to 10.2.2
@@ -21,3 +21,3 @@ "use strict"; | ||
if (useFileCache && !filename) { | ||
throw `[${this.constructor.name}] when 'useFileCache' is set to 'true', 'filename' must be defined`; | ||
throw new Error(`[${this.constructor.name}] when 'useFileCache' is set to 'true', 'filename' must be defined`); | ||
} | ||
@@ -35,5 +35,4 @@ this._internalMap = (useFileCache) ? new file_system_map_1.FileSystemMap(filename) : new Map(); | ||
const keys = Array.from(this._internalMap.keys()); | ||
for (var i = 0; i < keys.length; i++) { | ||
let key = keys[i]; | ||
let val = this.get(key); | ||
for (const key of keys) { | ||
const val = this.get(key); | ||
valMap.set(key, val); | ||
@@ -78,5 +77,4 @@ } | ||
const keys = Array.from(this._internalMap.keys()); | ||
for (var i = 0; i < keys.length; i++) { | ||
let key = keys[i]; | ||
let val = this.get(key); | ||
for (const key of keys) { | ||
const val = this.get(key); | ||
entriesMap.set(key, val); | ||
@@ -90,7 +88,6 @@ } | ||
values() { | ||
let values = []; | ||
const values = []; | ||
const keys = Array.from(this._internalMap.keys()); | ||
for (var i = 0; i < keys.length; i++) { | ||
let key = keys[i]; | ||
let val = this.get(key); | ||
for (const key of keys) { | ||
const val = this.get(key); | ||
values.push(val); | ||
@@ -103,5 +100,4 @@ } | ||
const keys = Array.from(this._internalMap.keys()); | ||
for (var i = 0; i < keys.length; i++) { | ||
let key = keys[i]; | ||
let val = this.get(key); | ||
for (const key of keys) { | ||
const val = this.get(key); | ||
entriesMap.set(key, val); | ||
@@ -114,5 +110,4 @@ } | ||
const keys = Array.from(this._internalMap.keys()); | ||
for (var i = 0; i < keys.length; i++) { | ||
let key = keys[i]; | ||
let val = this.get(key); | ||
for (const key of keys) { | ||
const val = this.get(key); | ||
entriesMap.set(key, val); | ||
@@ -124,4 +119,4 @@ } | ||
if (cacheObject) { | ||
let validUntil = cacheObject.validUntil || 0; | ||
let now = Date.now(); | ||
const validUntil = cacheObject.validUntil || 0; | ||
const now = Date.now(); | ||
if (now <= validUntil) { | ||
@@ -128,0 +123,0 @@ return true; |
@@ -68,4 +68,3 @@ "use strict"; | ||
if (input) { | ||
for (var i = 0; i < options.length; i++) { | ||
let o = options[i]; | ||
for (const o of options) { | ||
output = output.replace(o.exclude, o.replaceWith); | ||
@@ -72,0 +71,0 @@ } |
@@ -8,7 +8,7 @@ "use strict"; | ||
case 'beginning': | ||
let shortenedStr = original.substring((original.length - finalLength) + ellipsis.length); | ||
const shortenedStr = original.substring((original.length - finalLength) + ellipsis.length); | ||
return `${ellipsis}${shortenedStr}`; | ||
case 'middle': | ||
let beginningStr = original.substring(0, original.length / 2); | ||
let endStr = original.substring(original.length / 2); | ||
const beginningStr = original.substring(0, original.length / 2); | ||
const endStr = original.substring(original.length / 2); | ||
let shortenedBeginningStr = (0, exports.ellide)(beginningStr, (finalLength / 2) - (ellipsis.length / 2), 'end', ''); | ||
@@ -27,7 +27,7 @@ let shortenedEndStr = (0, exports.ellide)(endStr, (finalLength / 2) - (ellipsis.length / 2), 'beginning', ''); | ||
} | ||
let finalStr = `${shortenedBeginningStr}${ellipsis}${shortenedEndStr}`; | ||
const finalStr = `${shortenedBeginningStr}${ellipsis}${shortenedEndStr}`; | ||
return finalStr; | ||
case 'end': | ||
default: | ||
var shortStr = original.substring(0, (finalLength - ellipsis.length)); | ||
const shortStr = original.substring(0, (finalLength - ellipsis.length)); | ||
return `${shortStr}${ellipsis}`; | ||
@@ -34,0 +34,0 @@ } |
@@ -118,4 +118,4 @@ "use strict"; | ||
const stackLines = (stack === null || stack === void 0 ? void 0 : stack.split('\n')) || []; | ||
for (var i = 1; i < stackLines.length; i++) { | ||
let line = stackLines[i]; | ||
for (let i = 1; i < stackLines.length; i++) { | ||
const line = stackLines[i]; | ||
if (line.match(/.*(err).(ts|js)/gi) == null) { | ||
@@ -180,3 +180,3 @@ resultStackLines.push(line); | ||
if (opts.logger) { | ||
opts.logger[opts === null || opts === void 0 ? void 0 : opts.errLevel](e.toString()); | ||
opts.logger[opts === null || opts === void 0 ? void 0 : opts.errLevel](err.toString()); | ||
} | ||
@@ -187,3 +187,3 @@ else { | ||
level: opts.errLevel, | ||
message: e.toString() | ||
message: err.toString() | ||
}); | ||
@@ -190,0 +190,0 @@ } |
@@ -13,3 +13,3 @@ import { AftConfig } from "../configuration/aft-config"; | ||
private _rep; | ||
private _testName; | ||
private readonly _testName; | ||
readonly startTime: number; | ||
@@ -16,0 +16,0 @@ constructor(scope: any, aftCfg?: AftConfig); |
@@ -129,5 +129,4 @@ "use strict"; | ||
} | ||
let results = yield this._generateResults(status, message, ...this.testCases); | ||
for (var i = 0; i < results.length; i++) { | ||
let result = results[i]; | ||
const results = yield this._generateResults(status, message, ...this.testCases); | ||
for (const result of results) { | ||
try { | ||
@@ -168,7 +167,6 @@ yield this.reporter.submitResult(result); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let results = []; | ||
const results = []; | ||
if (testIds.length > 0) { | ||
for (var i = 0; i < testIds.length; i++) { | ||
let testId = testIds[i]; | ||
let result = yield this._generateTestResult(status, logMessage, testId); | ||
for (const testId of testIds) { | ||
const result = yield this._generateTestResult(status, logMessage, testId); | ||
results.push(result); | ||
@@ -178,3 +176,3 @@ } | ||
else { | ||
let result = yield this._generateTestResult(status, logMessage); | ||
const result = yield this._generateTestResult(status, logMessage); | ||
results.push(result); | ||
@@ -181,0 +179,0 @@ } |
@@ -20,4 +20,3 @@ "use strict"; | ||
const allMatches = [...input.matchAll(regex)]; | ||
for (var i = 0; i < allMatches.length; i++) { | ||
let matches = allMatches[i]; | ||
for (const matches of allMatches) { | ||
matches === null || matches === void 0 ? void 0 : matches.forEach((match, groupIndex) => { | ||
@@ -24,0 +23,0 @@ if (groupIndex > 0) { |
@@ -60,7 +60,7 @@ "use strict"; | ||
log(data) { | ||
if ((data === null || data === void 0 ? void 0 : data.level) != 'none' && log_level_1.LogLevel.toValue(data === null || data === void 0 ? void 0 : data.level) >= log_level_1.LogLevel.toValue(this.logLevel)) { | ||
if (data === null || data === void 0 ? void 0 : data.message) { | ||
const out = this.format(data); | ||
this.toConsole(data.level, out); | ||
} | ||
if ((data === null || data === void 0 ? void 0 : data.level) !== 'none' | ||
&& log_level_1.LogLevel.toValue(data === null || data === void 0 ? void 0 : data.level) >= log_level_1.LogLevel.toValue(this.logLevel) | ||
&& (data === null || data === void 0 ? void 0 : data.message)) { | ||
const out = this.format(data); | ||
this.toConsole(data.level, out); | ||
} | ||
@@ -80,4 +80,4 @@ } | ||
(_c = data.level) !== null && _c !== void 0 ? _c : (data.level = 'none'); | ||
let d = new Date().toLocaleTimeString(); | ||
let out = `${d} - [${data.name}] - ${(0, ellide_1.ellide)(data.level.toUpperCase(), 5, 'end', '')} - ${data.message}`; | ||
const d = new Date().toLocaleTimeString(); | ||
const out = `${d} - [${data.name}] - ${(0, ellide_1.ellide)(data.level.toUpperCase(), 5, 'end', '')} - ${data.message}`; | ||
return out; | ||
@@ -84,0 +84,0 @@ } |
@@ -62,5 +62,5 @@ "use strict"; | ||
} | ||
let mi = machine_info_1.machineInfo.data; | ||
let username = convert_1.convert.toSafeString(mi.user, this._safeStrOpt); | ||
let machine = convert_1.convert.toSafeString(mi.hostname, this._safeStrOpt); | ||
const mi = machine_info_1.machineInfo.data; | ||
const username = convert_1.convert.toSafeString(mi.user, this._safeStrOpt); | ||
const machine = convert_1.convert.toSafeString(mi.hostname, this._safeStrOpt); | ||
return `${username.toLocaleUpperCase()}_${machine.toLocaleUpperCase()}`; | ||
@@ -91,3 +91,3 @@ }); | ||
let d = new Date(); | ||
let month = d.getUTCMonth() + 1; | ||
const month = d.getUTCMonth() + 1; | ||
let monthStr = month.toString(); | ||
@@ -97,3 +97,3 @@ if (month < 10) { | ||
} | ||
let day = d.getUTCDate(); | ||
const day = d.getUTCDate(); | ||
let dayStr = day.toString(); | ||
@@ -103,3 +103,3 @@ if (day < 10) { | ||
} | ||
let now = convert_1.convert.toSafeString(`${d.getUTCFullYear()}${monthStr}${dayStr}`, this._safeStrOpt); | ||
const now = convert_1.convert.toSafeString(`${d.getUTCFullYear()}${monthStr}${dayStr}`, this._safeStrOpt); | ||
return now; | ||
@@ -106,0 +106,0 @@ }); |
@@ -50,2 +50,7 @@ import { ReportingPlugin } from "./reporting-plugin"; | ||
/** | ||
* creates a filtered array by checking all plugins' `enabled` property | ||
* and handling any exceptions as a `false` enabled state | ||
*/ | ||
get enabledPlugins(): ReportingPlugin[]; | ||
/** | ||
* calls the `log` function with a `LogLevel` of `trace` | ||
@@ -52,0 +57,0 @@ * @param message the message to be logged |
@@ -61,2 +61,10 @@ "use strict"; | ||
/** | ||
* creates a filtered array by checking all plugins' `enabled` property | ||
* and handling any exceptions as a `false` enabled state | ||
*/ | ||
get enabledPlugins() { | ||
var _a, _b; | ||
return (_b = (_a = this.plugins) === null || _a === void 0 ? void 0 : _a.filter(p => err_1.Err.handle(() => p === null || p === void 0 ? void 0 : p.enabled))) !== null && _b !== void 0 ? _b : []; | ||
} | ||
/** | ||
* calls the `log` function with a `LogLevel` of `trace` | ||
@@ -94,3 +102,4 @@ * @param message the message to be logged | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.log('step', ++this._stepCount + ': ' + message, ...data); | ||
this._stepCount += 1; | ||
yield this.log('step', `${this._stepCount}: ${message}`, ...data); | ||
}); | ||
@@ -149,11 +158,4 @@ } | ||
}); | ||
for (var plugin of this.plugins.filter(p => { | ||
for (const plugin of this.enabledPlugins) { | ||
try { | ||
return p === null || p === void 0 ? void 0 : p.enabled; | ||
} | ||
catch (e) { | ||
/* ignore */ | ||
} | ||
})) { | ||
try { | ||
yield (plugin === null || plugin === void 0 ? void 0 : plugin.log(this.reporterName, level, message, ...data)); | ||
@@ -179,3 +181,3 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
for (var plugin of this.plugins.filter(p => err_1.Err.handle(() => p === null || p === void 0 ? void 0 : p.enabled))) { | ||
for (const plugin of this.enabledPlugins) { | ||
try { | ||
@@ -202,11 +204,4 @@ yield (plugin === null || plugin === void 0 ? void 0 : plugin.submitResult(this.reporterName, (0, lodash_1.cloneDeep)(result))); | ||
const name = this.reporterName; | ||
for (var plugin of this.plugins.filter(p => { | ||
for (const plugin of this.enabledPlugins) { | ||
try { | ||
return p === null || p === void 0 ? void 0 : p.enabled; | ||
} | ||
catch (_a) { | ||
/* ignore */ | ||
} | ||
})) { | ||
try { | ||
yield (plugin === null || plugin === void 0 ? void 0 : plugin.finalise(name)); | ||
@@ -213,0 +208,0 @@ } |
@@ -35,3 +35,3 @@ "use strict"; | ||
get enabled() { | ||
return this.logLevel != 'none'; | ||
return this.logLevel !== 'none'; | ||
} | ||
@@ -38,0 +38,0 @@ /** |
@@ -94,7 +94,7 @@ "use strict"; | ||
_compareObjects(actual, expected, depth = 1) { | ||
let equivalent = true; | ||
let equiv = true; | ||
const expectedKeys = Object.keys(expected); | ||
for (let prop of expectedKeys) { | ||
for (const prop of expectedKeys) { | ||
if (actual[prop] == null && expected[prop] != null) { | ||
equivalent = false; | ||
equiv = false; | ||
this._failure = `'actual.${prop}' unset while 'expected.${prop}' had a value`; | ||
@@ -104,3 +104,3 @@ break; | ||
if (typeof actual[prop] !== typeof expected[prop]) { | ||
equivalent = false; | ||
equiv = false; | ||
this._failure = `typeof actual.${prop}: '${typeof actual[prop]}' not equal to '${typeof expected[prop]}'`; | ||
@@ -114,4 +114,4 @@ break; | ||
if (depth < this._maxDepth) { | ||
equivalent = this._compareObjects(actual[prop], expected[prop], depth + 1); | ||
if (!equivalent) { | ||
equiv = this._compareObjects(actual[prop], expected[prop], depth + 1); | ||
if (!equiv) { | ||
break; | ||
@@ -122,3 +122,3 @@ } | ||
else if (actual[prop] != expected[prop]) { | ||
equivalent = false; | ||
equiv = false; | ||
this._failure = `actual.${prop}: '${actual[prop]}' != '${expected[prop]}'`; | ||
@@ -128,3 +128,3 @@ break; | ||
} | ||
return equivalent; | ||
return equiv; | ||
} | ||
@@ -286,7 +286,7 @@ } | ||
_compareObjects(actual, expected, depth = 1) { | ||
let equivalent = true; | ||
let equiv = true; | ||
const expectedKeys = Object.keys(expected); | ||
for (let prop of expectedKeys) { | ||
for (const prop of expectedKeys) { | ||
if (actual[prop] == null && expected[prop] != null) { | ||
equivalent = false; | ||
equiv = false; | ||
this._failure = `'actual.${prop}' unset or non-existing while 'expected.${prop}' exists`; | ||
@@ -296,16 +296,15 @@ break; | ||
if (typeof actual[prop] !== typeof expected[prop]) { | ||
equivalent = false; | ||
equiv = false; | ||
this._failure = `typeof actual.${prop}: '${typeof actual[prop]}' not equal to '${typeof expected[prop]}'`; | ||
break; | ||
} | ||
if (typeof expected[prop] === 'object') { | ||
if (depth < this._maxDepth) { | ||
equivalent = this._compareObjects(actual[prop], expected[prop], depth + 1); | ||
if (!equivalent) { | ||
break; | ||
} | ||
if (typeof expected[prop] === 'object' | ||
&& depth < this._maxDepth) { | ||
equiv = this._compareObjects(actual[prop], expected[prop], depth + 1); | ||
if (!equiv) { | ||
break; | ||
} | ||
} | ||
} | ||
return equivalent; | ||
return equiv; | ||
} | ||
@@ -312,0 +311,0 @@ } |
@@ -138,8 +138,8 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let result = yield Promise.resolve(this._assertion(this)); | ||
if (this._matcher !== undefined) { | ||
if (!this._matcher.setActual(result).compare()) { | ||
return Promise.reject(`${this._matcher.failureString()}`); | ||
} | ||
const result = yield Promise.resolve(this._assertion(this)); | ||
if (this._matcher !== undefined | ||
&& !this._matcher.setActual(result).compare()) { | ||
return Promise.reject(`${this._matcher.failureString()}`); | ||
} | ||
return Promise.resolve(); | ||
}); | ||
@@ -205,4 +205,4 @@ } | ||
if (testIds === null || testIds === void 0 ? void 0 : testIds.length) { | ||
for (var i = 0; i < testIds.length; i++) { | ||
this._testIds.add(testIds[i]); | ||
for (const id of testIds) { | ||
this._testIds.add(id); | ||
} | ||
@@ -291,14 +291,9 @@ } | ||
const shouldRunTests = new Array(); | ||
const shouldNotRunTests = new Array(); | ||
const testIds = Array.from(this._testIds.keys()); | ||
if (testIds === null || testIds === void 0 ? void 0 : testIds.length) { | ||
for (var i = 0; i < testIds.length; i++) { | ||
let testId = testIds[i]; | ||
let result = yield this.policyEngMgr.shouldRun(testId); | ||
for (const testId of testIds) { | ||
const result = yield this.policyEngMgr.shouldRun(testId); | ||
if (result.result === true) { | ||
shouldRunTests.push(testId); | ||
} | ||
else { | ||
shouldNotRunTests.push(testId); | ||
} | ||
} | ||
@@ -337,5 +332,4 @@ if (shouldRunTests.length === 0) { | ||
} | ||
let results = yield this._generateTestResults(status, message, ...Array.from(this._testIds.values())); | ||
for (var i = 0; i < results.length; i++) { | ||
let result = results[i]; | ||
const results = yield this._generateTestResults(status, message, ...Array.from(this._testIds.values())); | ||
for (const result of results) { | ||
try { | ||
@@ -376,7 +370,6 @@ yield this.reporter.submitResult(result); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let results = []; | ||
const results = []; | ||
if (testIds.length > 0) { | ||
for (var i = 0; i < testIds.length; i++) { | ||
let testId = testIds[i]; | ||
let result = yield this._generateTestResult(status, logMessage, testId); | ||
for (const testId of testIds) { | ||
const result = yield this._generateTestResult(status, logMessage, testId); | ||
results.push(result); | ||
@@ -386,3 +379,3 @@ } | ||
else { | ||
let result = yield this._generateTestResult(status, logMessage); | ||
const result = yield this._generateTestResult(status, logMessage); | ||
results.push(result); | ||
@@ -395,3 +388,3 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let result = { | ||
const result = { | ||
testName: this.reporter.reporterName, | ||
@@ -398,0 +391,0 @@ testId: testId, |
{ | ||
"name": "aft-core", | ||
"version": "10.2.1", | ||
"version": "10.2.2", | ||
"description": "Automation Framework for Testing (AFT) package supporting JavaScript unit, integration and functional testing", | ||
@@ -51,3 +51,3 @@ "repository": { | ||
}, | ||
"gitHead": "41c157fc5c96357608a6df58a187157b19290b16" | ||
"gitHead": "19feb690f258fe10c7e8b43425ff22e91650602a" | ||
} |
@@ -282,2 +282,2 @@ import * as fs from 'fs'; | ||
export const aftConfig: AftConfig = new AftConfig(); | ||
export const aftConfig: AftConfig = new AftConfig(); |
@@ -23,3 +23,3 @@ import { JsonKey, JsonValue, CacheObject } from "./custom-types"; | ||
if (useFileCache && !filename) { | ||
throw `[${this.constructor.name}] when 'useFileCache' is set to 'true', 'filename' must be defined`; | ||
throw new Error(`[${this.constructor.name}] when 'useFileCache' is set to 'true', 'filename' must be defined`); | ||
} | ||
@@ -38,5 +38,4 @@ this._internalMap = (useFileCache) ? new FileSystemMap<K, CacheObject>(filename) : new Map<K, CacheObject>(); | ||
const keys: K[] = Array.from(this._internalMap.keys()); | ||
for (var i=0; i<keys.length; i++) { | ||
let key = keys[i]; | ||
let val = this.get(key); | ||
for (const key of keys) { | ||
const val = this.get(key); | ||
valMap.set(key, val); | ||
@@ -78,5 +77,4 @@ } | ||
const keys: K[] = Array.from(this._internalMap.keys()); | ||
for (var i=0; i<keys.length; i++) { | ||
let key = keys[i]; | ||
let val = this.get(key); | ||
for (const key of keys) { | ||
const val = this.get(key); | ||
entriesMap.set(key, val); | ||
@@ -90,7 +88,6 @@ } | ||
values(): IterableIterator<V> { | ||
let values: V[] = []; | ||
const values: V[] = []; | ||
const keys: K[] = Array.from(this._internalMap.keys()); | ||
for (var i=0; i<keys.length; i++) { | ||
let key = keys[i]; | ||
let val = this.get(key); | ||
for (const key of keys) { | ||
const val = this.get(key); | ||
values.push(val); | ||
@@ -103,5 +100,4 @@ } | ||
const keys: K[] = Array.from(this._internalMap.keys()); | ||
for (var i=0; i<keys.length; i++) { | ||
let key = keys[i]; | ||
let val = this.get(key); | ||
for (const key of keys) { | ||
const val = this.get(key); | ||
entriesMap.set(key, val); | ||
@@ -114,5 +110,4 @@ } | ||
const keys: K[] = Array.from(this._internalMap.keys()); | ||
for (var i=0; i<keys.length; i++) { | ||
let key = keys[i]; | ||
let val = this.get(key); | ||
for (const key of keys) { | ||
const val = this.get(key); | ||
entriesMap.set(key, val); | ||
@@ -125,4 +120,4 @@ } | ||
if (cacheObject) { | ||
let validUntil: number = cacheObject.validUntil || 0; | ||
let now: number = Date.now(); | ||
const validUntil: number = cacheObject.validUntil || 0; | ||
const now: number = Date.now(); | ||
if (now <= validUntil) { | ||
@@ -134,2 +129,2 @@ return true; | ||
} | ||
} | ||
} |
@@ -86,4 +86,3 @@ import { JsonObject } from "./custom-types"; | ||
if (input) { | ||
for (var i=0; i<options.length; i++) { | ||
let o: SafeStringOption = options[i]; | ||
for (const o of options) { | ||
output = output.replace(o.exclude, o.replaceWith); | ||
@@ -199,2 +198,2 @@ } | ||
*/ | ||
export const convert = new Convert(); | ||
export const convert = new Convert(); |
@@ -116,2 +116,2 @@ /** | ||
*/ | ||
export type RetryBackOffType = 'constant' | 'linear' | 'exponential'; | ||
export type RetryBackOffType = 'constant' | 'linear' | 'exponential'; |
@@ -7,10 +7,10 @@ export type EllipsisLocation = 'beginning' | 'middle' | 'end'; | ||
case 'beginning': | ||
let shortenedStr: string = original.substring((original.length - finalLength) + ellipsis.length); | ||
const shortenedStr: string = original.substring((original.length - finalLength) + ellipsis.length); | ||
return `${ellipsis}${shortenedStr}`; | ||
case 'middle': | ||
let beginningStr: string = original.substring(0, original.length / 2); | ||
let endStr: string = original.substring(original.length / 2); | ||
const beginningStr: string = original.substring(0, original.length / 2); | ||
const endStr: string = original.substring(original.length / 2); | ||
let shortenedBeginningStr: string = ellide(beginningStr, (finalLength / 2) - (ellipsis.length / 2), 'end', ''); | ||
let shortenedEndStr: string = ellide(endStr, (finalLength / 2) - (ellipsis.length / 2), 'beginning', ''); | ||
let removeFromBeginning: boolean = true; | ||
let removeFromBeginning = true; | ||
while (shortenedBeginningStr.length + ellipsis.length + shortenedEndStr.length > finalLength) { | ||
@@ -25,7 +25,7 @@ if (removeFromBeginning) { | ||
} | ||
let finalStr: string = `${shortenedBeginningStr}${ellipsis}${shortenedEndStr}`; | ||
const finalStr = `${shortenedBeginningStr}${ellipsis}${shortenedEndStr}`; | ||
return finalStr; | ||
case 'end': | ||
default: | ||
var shortStr = original.substring(0, (finalLength - ellipsis.length)); | ||
const shortStr = original.substring(0, (finalLength - ellipsis.length)); | ||
return `${shortStr}${ellipsis}`; | ||
@@ -35,2 +35,2 @@ } | ||
return original; // no need to ellide so return original string | ||
}; | ||
}; |
import { LogLevel } from '../logging/log-level'; | ||
import { Reporter } from '../plugins/reporting/reporter'; | ||
import { AftLogger, aftLogger } from '../logging/aft-logger'; | ||
import { aftLogger } from '../logging/aft-logger'; | ||
import { convert } from './convert'; | ||
@@ -138,4 +138,4 @@ import { Func } from './custom-types'; | ||
const stackLines: Array<string> = stack?.split('\n') || []; | ||
for (var i=1; i<stackLines.length; i++) { | ||
let line = stackLines[i]; | ||
for (let i=1; i<stackLines.length; i++) { | ||
const line = stackLines[i]; | ||
if (line.match(/.*(err).(ts|js)/gi) == null) { | ||
@@ -199,3 +199,3 @@ resultStackLines.push(line); | ||
if (opts.logger) { | ||
opts.logger[opts?.errLevel](e.toString()); | ||
opts.logger[opts?.errLevel](err.toString()); | ||
} else { | ||
@@ -205,3 +205,3 @@ aftLogger.log({ | ||
level: opts.errLevel, | ||
message: e.toString() | ||
message: err.toString() | ||
}); | ||
@@ -208,0 +208,0 @@ } |
@@ -109,2 +109,2 @@ import * as fs from "fs"; | ||
} | ||
} | ||
} |
@@ -96,2 +96,2 @@ import * as fs from "fs"; | ||
export const fileio = new FileIO(); | ||
export const fileio = new FileIO(); |
@@ -124,2 +124,2 @@ import * as path from "path"; | ||
} | ||
} | ||
} |
@@ -49,2 +49,2 @@ import * as os from 'os'; | ||
export const machineInfo = new MachineInfo(); | ||
export const machineInfo = new MachineInfo(); |
@@ -123,2 +123,2 @@ import * as uuid from 'uuid'; | ||
*/ | ||
export const rand = new Rand(); | ||
export const rand = new Rand(); |
@@ -254,2 +254,2 @@ import { AftConfig, aftConfig } from "../configuration/aft-config"; | ||
return new Retry<T>(retryable, aftCfg); | ||
}; | ||
}; |
@@ -45,2 +45,2 @@ import { Func } from "./custom-types"; | ||
.finally(() => disposable?.dispose(err)); | ||
} | ||
} |
@@ -49,2 +49,2 @@ import { Func } from "./custom-types"; | ||
export const wait = new Wait(); | ||
export const wait = new Wait(); |
@@ -18,3 +18,4 @@ import { AftConfig, aftConfig } from "../configuration/aft-config"; | ||
private _rep: Reporter; | ||
private _testName: string; | ||
private readonly _testName: string; | ||
@@ -93,3 +94,3 @@ public readonly startTime: number; | ||
return this._getVerifier<T>(verifierType) | ||
.verify(assertion) as T; | ||
.verify(assertion); | ||
} | ||
@@ -131,5 +132,4 @@ | ||
let results: TestResult[] = await this._generateResults(status, message, ...this.testCases); | ||
for (var i=0; i<results.length; i++) { | ||
let result: TestResult = results[i]; | ||
const results: TestResult[] = await this._generateResults(status, message, ...this.testCases); | ||
for (const result of results) { | ||
try { | ||
@@ -166,11 +166,10 @@ await this.reporter.submitResult(result); | ||
protected async _generateResults(status: TestStatus, logMessage: string, ...testIds: string[]): Promise<TestResult[]> { | ||
let results: TestResult[] = []; | ||
const results: TestResult[] = []; | ||
if (testIds.length > 0) { | ||
for (var i=0; i<testIds.length; i++) { | ||
let testId: string = testIds[i]; | ||
let result: TestResult = await this._generateTestResult(status, logMessage, testId); | ||
for (const testId of testIds) { | ||
const result: TestResult = await this._generateTestResult(status, logMessage, testId); | ||
results.push(result); | ||
} | ||
} else { | ||
let result: TestResult = await this._generateTestResult(status, logMessage); | ||
const result: TestResult = await this._generateTestResult(status, logMessage); | ||
results.push(result); | ||
@@ -196,2 +195,2 @@ } | ||
} | ||
} | ||
} |
@@ -18,4 +18,3 @@ export class TitleParser { | ||
const allMatches = [...input.matchAll(regex)]; | ||
for (var i=0; i<allMatches.length; i++) { | ||
let matches = allMatches[i]; | ||
for (const matches of allMatches) { | ||
matches?.forEach((match, groupIndex) => { | ||
@@ -29,2 +28,2 @@ if (groupIndex > 0) { | ||
} | ||
} | ||
} |
@@ -62,7 +62,7 @@ import * as colors from "colors"; | ||
log(data: LogMessageData): void { | ||
if (data?.level != 'none' && LogLevel.toValue(data?.level) >= LogLevel.toValue(this.logLevel)) { | ||
if (data?.message) { | ||
if (data?.level !== 'none' | ||
&& LogLevel.toValue(data?.level) >= LogLevel.toValue(this.logLevel) | ||
&& data?.message) { | ||
const out: string = this.format(data); | ||
this.toConsole(data.level, out); | ||
} | ||
} | ||
@@ -82,4 +82,4 @@ } | ||
data.level ??= 'none'; | ||
let d: string = new Date().toLocaleTimeString(); | ||
let out: string = `${d} - [${data.name}] - ${ellide(data.level.toUpperCase(), 5, 'end', '')} - ${data.message}`; | ||
const d: string = new Date().toLocaleTimeString(); | ||
const out = `${d} - [${data.name}] - ${ellide(data.level.toUpperCase(), 5, 'end', '')} - ${data.message}`; | ||
return out; | ||
@@ -130,2 +130,2 @@ } | ||
*/ | ||
export const aftLogger = new AftLogger(); | ||
export const aftLogger = new AftLogger(); |
@@ -45,2 +45,2 @@ const levels = ['trace', 'debug', 'info', 'step', 'warn', 'pass', 'fail', 'error', 'none'] as const; | ||
} | ||
} | ||
} |
@@ -8,2 +8,2 @@ import { LogLevel } from "./log-level"; | ||
args?: Array<any>; | ||
}; | ||
}; |
@@ -54,5 +54,5 @@ import { AftConfig, aftConfig } from "../../configuration/aft-config"; | ||
} | ||
let mi: MachineInfoData = machineInfo.data; | ||
let username: string = convert.toSafeString(mi.user, this._safeStrOpt); | ||
let machine: string = convert.toSafeString(mi.hostname, this._safeStrOpt); | ||
const mi: MachineInfoData = machineInfo.data; | ||
const username: string = convert.toSafeString(mi.user, this._safeStrOpt); | ||
const machine: string = convert.toSafeString(mi.hostname, this._safeStrOpt); | ||
return `${username.toLocaleUpperCase()}_${machine.toLocaleUpperCase()}`; | ||
@@ -81,3 +81,3 @@ } | ||
let d = new Date(); | ||
let month: number = d.getUTCMonth() + 1; | ||
const month: number = d.getUTCMonth() + 1; | ||
let monthStr: string = month.toString(); | ||
@@ -87,3 +87,3 @@ if (month < 10) { | ||
} | ||
let day: number = d.getUTCDate(); | ||
const day: number = d.getUTCDate(); | ||
let dayStr: string = day.toString(); | ||
@@ -93,5 +93,5 @@ if (day < 10) { | ||
} | ||
let now: string = convert.toSafeString(`${d.getUTCFullYear()}${monthStr}${dayStr}`, this._safeStrOpt); | ||
const now: string = convert.toSafeString(`${d.getUTCFullYear()}${monthStr}${dayStr}`, this._safeStrOpt); | ||
return now; | ||
} | ||
} | ||
} |
@@ -6,2 +6,2 @@ import { Plugin } from "../plugin"; | ||
buildNumber = (): Promise<string> => null; | ||
} | ||
} |
@@ -32,3 +32,3 @@ import { ReportingPlugin } from "./reporting-plugin"; | ||
private readonly _aftLogger: AftLogger; | ||
private _stepCount: number = 0; | ||
private _stepCount = 0; | ||
@@ -77,2 +77,10 @@ /** | ||
/** | ||
* creates a filtered array by checking all plugins' `enabled` property | ||
* and handling any exceptions as a `false` enabled state | ||
*/ | ||
get enabledPlugins() { | ||
return this.plugins?.filter(p => Err.handle(() => p?.enabled)) ?? []; | ||
} | ||
/** | ||
* calls the `log` function with a `LogLevel` of `trace` | ||
@@ -106,3 +114,4 @@ * @param message the message to be logged | ||
async step(message: string, ...data: Array<any>): Promise<void> { | ||
await this.log('step', ++this._stepCount + ': ' + message, ...data); | ||
this._stepCount += 1; | ||
await this.log('step', `${this._stepCount}: ${message}`, ...data); | ||
} | ||
@@ -156,9 +165,3 @@ | ||
}); | ||
for (var plugin of this.plugins.filter(p => { | ||
try{ | ||
return p?.enabled; | ||
} catch (e) { | ||
/* ignore */ | ||
} | ||
})) { | ||
for (const plugin of this.enabledPlugins) { | ||
try { | ||
@@ -182,3 +185,3 @@ await plugin?.log(this.reporterName, level, message, ...data); | ||
async submitResult(result: TestResult): Promise<void> { | ||
for (var plugin of this.plugins.filter(p => Err.handle(() => p?.enabled))) { | ||
for (const plugin of this.enabledPlugins) { | ||
try { | ||
@@ -203,9 +206,3 @@ await plugin?.submitResult(this.reporterName, cloneDeep(result)); | ||
const name = this.reporterName; | ||
for (var plugin of this.plugins.filter(p => { | ||
try{ | ||
return p?.enabled; | ||
} catch { | ||
/* ignore */ | ||
} | ||
})) { | ||
for (const plugin of this.enabledPlugins) { | ||
try { | ||
@@ -229,2 +226,2 @@ await plugin?.finalise(name); | ||
} | ||
} | ||
} |
@@ -11,3 +11,3 @@ import { Plugin, PluginConfig } from "../plugin"; | ||
override get enabled(): boolean { | ||
return this.logLevel != 'none'; | ||
return this.logLevel !== 'none'; | ||
} | ||
@@ -53,2 +53,2 @@ /** | ||
finalise = (name: string): Promise<void> => null; | ||
} | ||
} |
@@ -12,2 +12,2 @@ import { TestStatus } from "./test-status"; | ||
metadata?: JsonObject; | ||
}; | ||
}; |
@@ -1,1 +0,1 @@ | ||
export type TestStatus = 'untested' | 'passed' | 'blocked' | 'retest' | 'failed' | 'skipped'; | ||
export type TestStatus = 'untested' | 'passed' | 'blocked' | 'retest' | 'failed' | 'skipped'; |
@@ -12,2 +12,2 @@ import { AftConfig } from "../configuration/aft-config"; | ||
usingTestExecutionPolicyManager: (mgr: TestExecutionPolicyManager) => Verifier | ||
} | ||
} |
@@ -1,3 +0,1 @@ | ||
import { Class } from "../helpers/custom-types"; | ||
export interface VerifierMatcher { | ||
@@ -107,8 +105,8 @@ readonly expected: any; | ||
} | ||
private _compareObjects(actual: Record<string | number | symbol, any>, expected: Record<string | number | symbol, any>, depth: number = 1): boolean { | ||
let equivalent: boolean = true; | ||
private _compareObjects(actual: Record<string | number | symbol, any>, expected: Record<string | number | symbol, any>, depth = 1): boolean { | ||
let equiv = true; | ||
const expectedKeys = Object.keys(expected); | ||
for (let prop of expectedKeys) { | ||
for (const prop of expectedKeys) { | ||
if (actual[prop] == null && expected[prop] != null) { | ||
equivalent = false; | ||
equiv = false; | ||
this._failure = `'actual.${prop}' unset while 'expected.${prop}' had a value`; | ||
@@ -118,3 +116,3 @@ break; | ||
if (typeof actual[prop] !== typeof expected[prop]) { | ||
equivalent = false; | ||
equiv = false; | ||
this._failure = `typeof actual.${prop}: '${typeof actual[prop]}' not equal to '${typeof expected[prop]}'`; | ||
@@ -127,4 +125,4 @@ break; | ||
if (depth < this._maxDepth) { | ||
equivalent = this._compareObjects(actual[prop], expected[prop], depth + 1); | ||
if (!equivalent) { | ||
equiv = this._compareObjects(actual[prop], expected[prop], depth + 1); | ||
if (!equiv) { | ||
break; | ||
@@ -134,3 +132,3 @@ } | ||
} else if (actual[prop] != expected[prop]) { | ||
equivalent = false; | ||
equiv = false; | ||
this._failure = `actual.${prop}: '${actual[prop]}' != '${expected[prop]}'`; | ||
@@ -140,3 +138,3 @@ break; | ||
} | ||
return equivalent; | ||
return equiv; | ||
} | ||
@@ -309,7 +307,7 @@ } | ||
private _compareObjects(actual: Record<string | number | symbol, any>, expected: Record<string | number | symbol, any>, depth: number = 1): boolean { | ||
let equivalent: boolean = true; | ||
let equiv = true; | ||
const expectedKeys = Object.keys(expected); | ||
for (let prop of expectedKeys) { | ||
for (const prop of expectedKeys) { | ||
if (actual[prop] == null && expected[prop] != null) { | ||
equivalent = false; | ||
equiv = false; | ||
this._failure = `'actual.${prop}' unset or non-existing while 'expected.${prop}' exists`; | ||
@@ -319,16 +317,15 @@ break; | ||
if (typeof actual[prop] !== typeof expected[prop]) { | ||
equivalent = false; | ||
equiv = false; | ||
this._failure = `typeof actual.${prop}: '${typeof actual[prop]}' not equal to '${typeof expected[prop]}'`; | ||
break; | ||
} | ||
if (typeof expected[prop] === 'object') { | ||
if (depth < this._maxDepth) { | ||
equivalent = this._compareObjects(actual[prop], expected[prop], depth + 1); | ||
if (!equivalent) { | ||
if (typeof expected[prop] === 'object' | ||
&& depth < this._maxDepth) { | ||
equiv = this._compareObjects(actual[prop], expected[prop], depth + 1); | ||
if (!equiv) { | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
return equivalent; | ||
return equiv; | ||
} | ||
@@ -499,2 +496,2 @@ } | ||
return new Negate(expected); | ||
} | ||
} |
@@ -95,5 +95,7 @@ import { Reporter } from "../plugins/reporting/reporter"; | ||
async then<TResult1 = Verifier, TResult2 = never>(onfulfilled?: (value: void) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2> { | ||
return this._getInnerPromise() | ||
.then(onfulfilled, onrejected); | ||
async then<TResult1 = Verifier, TResult2 = never>( | ||
onfulfilled?: (value: void) => TResult1 | PromiseLike<TResult1>, | ||
onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>): Promise<TResult1 | TResult2> { | ||
return this._getInnerPromise() | ||
.then(onfulfilled, onrejected); | ||
} | ||
@@ -144,8 +146,8 @@ | ||
protected async _resolveAssertion(): Promise<void> { | ||
let result: any = await Promise.resolve(this._assertion(this)); | ||
if (this._matcher !== undefined) { | ||
if (!this._matcher.setActual(result).compare()) { | ||
const result: any = await Promise.resolve(this._assertion(this)); | ||
if (this._matcher !== undefined | ||
&& !this._matcher.setActual(result).compare()) { | ||
return Promise.reject(`${this._matcher.failureString()}`); | ||
} | ||
} | ||
return Promise.resolve(); | ||
} | ||
@@ -215,4 +217,4 @@ | ||
if (testIds?.length) { | ||
for (var i=0; i<testIds.length; i++) { | ||
this._testIds.add(testIds[i]); | ||
for (const id of testIds) { | ||
this._testIds.add(id); | ||
} | ||
@@ -303,12 +305,8 @@ } | ||
const shouldRunTests = new Array<string>(); | ||
const shouldNotRunTests = new Array<string>(); | ||
const testIds = Array.from(this._testIds.keys()); | ||
if (testIds?.length) { | ||
for (var i=0; i<testIds.length; i++) { | ||
let testId: string = testIds[i]; | ||
let result: ProcessingResult<boolean> = await this.policyEngMgr.shouldRun(testId); | ||
for (const testId of testIds) { | ||
const result: ProcessingResult<boolean> = await this.policyEngMgr.shouldRun(testId); | ||
if (result.result === true) { | ||
shouldRunTests.push(testId); | ||
} else { | ||
shouldNotRunTests.push(testId); | ||
} | ||
@@ -345,5 +343,4 @@ } | ||
let results: TestResult[] = await this._generateTestResults(status, message, ...Array.from(this._testIds.values())); | ||
for (var i=0; i<results.length; i++) { | ||
let result: TestResult = results[i]; | ||
const results: TestResult[] = await this._generateTestResults(status, message, ...Array.from(this._testIds.values())); | ||
for (const result of results) { | ||
try { | ||
@@ -380,11 +377,10 @@ await this.reporter.submitResult(result); | ||
protected async _generateTestResults(status: TestStatus, logMessage: string, ...testIds: string[]): Promise<TestResult[]> { | ||
let results: TestResult[] = []; | ||
const results: TestResult[] = []; | ||
if (testIds.length > 0) { | ||
for (var i=0; i<testIds.length; i++) { | ||
let testId: string = testIds[i]; | ||
let result: TestResult = await this._generateTestResult(status, logMessage, testId); | ||
for (const testId of testIds) { | ||
const result: TestResult = await this._generateTestResult(status, logMessage, testId); | ||
results.push(result); | ||
} | ||
} else { | ||
let result: TestResult = await this._generateTestResult(status, logMessage); | ||
const result: TestResult = await this._generateTestResult(status, logMessage); | ||
results.push(result); | ||
@@ -396,3 +392,3 @@ } | ||
protected async _generateTestResult(status: TestStatus, logMessage: string, testId?: string): Promise<TestResult> { | ||
let result: TestResult = { | ||
const result: TestResult = { | ||
testName: this.reporter.reporterName, | ||
@@ -433,2 +429,2 @@ testId: testId, | ||
return new Verifier().verify(assertion); | ||
}; | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
260
845028
13042