wdio-performancetotal-service
Advanced tools
Comparing version 3.1.0 to 4.0.1-1
@@ -0,0 +0,0 @@ import performancetotal from "./src/performance-total"; |
@@ -0,0 +0,0 @@ "use strict"; |
export declare enum StepSuffix { | ||
used = "_used" | ||
} |
@@ -7,2 +7,2 @@ "use strict"; | ||
StepSuffix["used"] = "_used"; | ||
})(StepSuffix = exports.StepSuffix || (exports.StepSuffix = {})); | ||
})(StepSuffix || (exports.StepSuffix = StepSuffix = {})); |
@@ -7,2 +7,3 @@ export interface Options { | ||
performanceResultsDirectory: string; | ||
recentDays: number; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ export declare class PartialLogEntry { |
@@ -20,2 +20,2 @@ "use strict"; | ||
StepType[StepType["End"] = 1] = "End"; | ||
})(StepType = exports.StepType || (exports.StepType = {})); | ||
})(StepType || (exports.StepType = StepType = {})); |
@@ -0,0 +0,0 @@ export declare class PerformanceLogEntry { |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ export declare class PerformanceResult { |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ declare class Calculator { |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,4 +1,6 @@ | ||
import { Plogger } from './logger'; | ||
export declare class FileWriter { | ||
private static instance; | ||
private lock; | ||
_logger: Plogger; | ||
private constructor(); | ||
@@ -5,0 +7,0 @@ static getInstance(): FileWriter; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -19,5 +10,7 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const app_root_path_1 = __importDefault(require("app-root-path")); | ||
const logger_1 = require("./logger"); | ||
class FileWriter { | ||
constructor() { | ||
this.lock = Promise.resolve(); | ||
this._logger = new logger_1.Plogger(); | ||
} | ||
@@ -30,49 +23,43 @@ static getInstance() { | ||
} | ||
readAllLines(path) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.lock; | ||
let data = ""; | ||
try { | ||
this.lock = this.lockFile(); | ||
data = yield fs_1.promises.readFile(path, "utf-8"); | ||
} | ||
catch (error) { | ||
console.error(`An error occurred while reading file ${path}:`, error); | ||
} | ||
finally { | ||
yield this.unlockFile(); | ||
} | ||
const stringArray = data.split("\n"); | ||
return stringArray; | ||
}); | ||
async readAllLines(path) { | ||
let data = ""; | ||
await this.lock; | ||
try { | ||
this.lock = this.lockFile(); | ||
data = await fs_1.promises.readFile(path, "utf-8"); | ||
} | ||
catch (err) { | ||
this._logger.error(`An error occurred while reading file ${path}: ${err}`); | ||
} | ||
finally { | ||
await this.unlockFile(); | ||
} | ||
const stringArray = data.split("\n"); | ||
return stringArray; | ||
} | ||
writeToFile(path, data) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.lock; | ||
try { | ||
this.lock = this.lockFile(); | ||
yield fs_1.promises.writeFile(path, data); | ||
} | ||
catch (error) { | ||
console.error(`An error occurred while writing file ${path}:`, error); | ||
} | ||
finally { | ||
yield this.unlockFile(); | ||
} | ||
}); | ||
async writeToFile(path, data) { | ||
await this.lock; | ||
try { | ||
this.lock = this.lockFile(); | ||
await fs_1.promises.writeFile(path, data); | ||
} | ||
catch (err) { | ||
this._logger.error(`An error occurred while writing file ${path}: ${err}`); | ||
} | ||
finally { | ||
await this.unlockFile(); | ||
} | ||
} | ||
appendLineToFile(path, data) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.lock; | ||
try { | ||
this.lock = this.lockFile(); | ||
yield fs_1.promises.appendFile(path, data); | ||
} | ||
catch (error) { | ||
console.error(`An error occurred while appending file ${path}:`, error); | ||
} | ||
finally { | ||
yield this.unlockFile(); | ||
} | ||
}); | ||
async appendLineToFile(path, data) { | ||
await this.lock; | ||
try { | ||
this.lock = this.lockFile(); | ||
await fs_1.promises.appendFile(path, data); | ||
} | ||
catch (err) { | ||
this._logger.error(`An error occurred while appending file ${path}: ${err}`); | ||
} | ||
finally { | ||
await this.unlockFile(); | ||
} | ||
} | ||
@@ -82,61 +69,54 @@ getFilePath(resultsDir, fileName) { | ||
} | ||
createResultsDirIfNotExist(resultsPath) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let npath = ""; | ||
const root = app_root_path_1.default.path; | ||
let isNotLegal = true; | ||
if (resultsPath) { | ||
isNotLegal = /[*"\[\]:;|,]/g.test(resultsPath); | ||
npath = path_1.default.normalize(resultsPath); | ||
} | ||
const resultsDir = npath == undefined || npath == "" || isNotLegal ? "performance-results" : npath; | ||
if (!root) { | ||
console.log("Performance-Total error: Can't get root folder"); | ||
return ""; | ||
} | ||
const dirPath = path_1.default.join(root, resultsDir); | ||
const isFileExists = yield this.isFileExist(dirPath); | ||
if (!isFileExists) { | ||
yield this.makeDir(dirPath); | ||
} | ||
return dirPath; | ||
}); | ||
async createResultsDirIfNotExist(resultsPath) { | ||
let npath = ""; | ||
const root = app_root_path_1.default.path; | ||
let isNotLegal = true; | ||
if (resultsPath) { | ||
isNotLegal = /[*"\[\]:;|,]/g.test(resultsPath); | ||
npath = path_1.default.normalize(resultsPath); | ||
} | ||
; | ||
const resultsDir = npath == undefined || npath == "" || isNotLegal ? "performance-results" : npath; | ||
if (!root) { | ||
this._logger.error("Performance-Total error: Can't get root folder"); | ||
return ""; | ||
} | ||
; | ||
const dirPath = path_1.default.join(root, resultsDir); | ||
const isFileExists = await this.isFileExist(dirPath); | ||
if (!isFileExists) { | ||
await this.makeDir(dirPath); | ||
} | ||
; | ||
return dirPath; | ||
} | ||
makeDir(dirPath) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
yield fs_1.promises.mkdir(dirPath, { recursive: true }); | ||
} | ||
catch (err) { | ||
console.log(`Performance-Total error: can't create dir: ${dirPath}: ${err}, ${err.stack}`); | ||
} | ||
}); | ||
async makeDir(dirPath) { | ||
try { | ||
await fs_1.promises.mkdir(dirPath, { recursive: true }); | ||
} | ||
catch (err) { | ||
this._logger.error(`Performance-Total error: can't create dir ${dirPath}: ${err}`); | ||
} | ||
} | ||
isFileExist(dirPath) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let isExists = false; | ||
try { | ||
yield fs_1.promises.access(dirPath); | ||
isExists = true; | ||
} | ||
finally { | ||
return isExists; | ||
} | ||
}); | ||
async isFileExist(dirPath) { | ||
let isExists = false; | ||
try { | ||
await fs_1.promises.access(dirPath); | ||
isExists = true; | ||
} | ||
finally { | ||
return isExists; | ||
} | ||
} | ||
lockFile() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.lock; | ||
this.lock = new Promise((resolve) => { | ||
setImmediate(resolve); | ||
}); | ||
async lockFile() { | ||
await this.lock; | ||
this.lock = new Promise((resolve) => { | ||
setImmediate(resolve); | ||
}); | ||
} | ||
unlockFile() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.lock; | ||
this.lock = Promise.resolve(); | ||
}); | ||
async unlockFile() { | ||
await this.lock; | ||
this.lock = Promise.resolve(); | ||
} | ||
} | ||
exports.FileWriter = FileWriter; |
@@ -0,0 +0,0 @@ declare class Group { |
@@ -0,0 +0,0 @@ "use strict"; |
export declare class IdGenerator { | ||
getId(prefix?: string): string; | ||
} |
@@ -0,0 +0,0 @@ "use strict"; |
import { PerformanceResult } from "./entities/performance-result"; | ||
import { Plogger } from "./helpers/logger"; | ||
export declare class PerformanceAnalyzer { | ||
_performanceResults: Array<PerformanceResult>; | ||
_logger: Plogger; | ||
constructor(); | ||
analyze(logFileName: string, saveDataFilePath: string, dropResultsFromFailedTest: boolean | undefined, analyzeByBrowser: boolean | undefined): Promise<void>; | ||
analyze(logFileName: string, saveDataFilePath: string, dropResultsFromFailedTest: boolean | undefined, analyzeByBrowser: boolean | undefined, recentDays: number | undefined): Promise<void>; | ||
private serializeData; | ||
private deserializeData; | ||
} |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -21,65 +12,70 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const objects_to_csv_1 = __importDefault(require("objects-to-csv")); | ||
const logger_1 = require("./helpers/logger"); | ||
class PerformanceAnalyzer { | ||
constructor() { | ||
this._performanceResults = new Array(); | ||
this._logger = new logger_1.Plogger(); | ||
} | ||
analyze(logFileName, saveDataFilePath, dropResultsFromFailedTest, analyzeByBrowser) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let performanceLogEntries = yield this.deserializeData(logFileName); | ||
let groupedResults; | ||
if (dropResultsFromFailedTest) { | ||
const entriesWithTestPass = performanceLogEntries.filter((e) => e.isTestPassed == true); | ||
performanceLogEntries = entriesWithTestPass; | ||
} | ||
if (!performanceLogEntries || performanceLogEntries.length == 0) { | ||
return; | ||
} | ||
groupedResults = !analyzeByBrowser ? group_1.default.groupBy(performanceLogEntries, p => [p.name]) : group_1.default.groupBy(performanceLogEntries, p => [p.name, p.brName]); | ||
groupedResults.forEach(group => { | ||
const durationList = group.map(t => t.duration); | ||
const performanceResult = new performance_result_1.PerformanceResult(); | ||
const avgAndSte = calculator_1.default.getAverageAndStandardDeviation(durationList); | ||
performanceResult.name = group[0].name; | ||
performanceResult.brName = analyzeByBrowser ? group[0].brName : "general"; | ||
performanceResult.earliestTime = group[0].startDisplayTime; | ||
performanceResult.latestTime = group[group.length - 1].startDisplayTime; | ||
performanceResult.avgTime = avgAndSte[0]; | ||
performanceResult.sem = avgAndSte[1]; | ||
performanceResult.repeats = durationList.length; | ||
performanceResult.minValue = Math.min(...durationList); | ||
performanceResult.maxValue = Math.max(...durationList); | ||
this._performanceResults.push(performanceResult); | ||
async analyze(logFileName, saveDataFilePath, dropResultsFromFailedTest, analyzeByBrowser, recentDays) { | ||
let performanceLogEntries = await this.deserializeData(logFileName); | ||
let groupedResults; | ||
if (dropResultsFromFailedTest || recentDays) { | ||
const cutoffDate = Date.now() - ((recentDays || 0) * 24 * 60 * 60 * 1000); | ||
const filteredEntries = performanceLogEntries.filter((e) => { | ||
if (recentDays && e.startTime < cutoffDate) { | ||
return false; | ||
} | ||
if (dropResultsFromFailedTest) { | ||
return e.isTestPassed; | ||
} | ||
return true; | ||
}); | ||
const picked = this._performanceResults.map(({ name, brName, avgTime, sem, repeats, minValue, maxValue }) => ({ name, brName, avgTime, sem, repeats, minValue, maxValue })); | ||
console.log("\nPerformance-Total results:\n"); | ||
console.table(picked); | ||
yield this.serializeData(saveDataFilePath); | ||
console.log(`\nPerformance-Total results saved to: ${saveDataFilePath}.csv/json\n`); | ||
performanceLogEntries = filteredEntries; | ||
} | ||
if (!performanceLogEntries || performanceLogEntries.length == 0) { | ||
return; | ||
} | ||
groupedResults = !analyzeByBrowser ? group_1.default.groupBy(performanceLogEntries, p => [p.name]) : group_1.default.groupBy(performanceLogEntries, p => [p.name, p.brName]); | ||
groupedResults.forEach(group => { | ||
const durationList = group.map(t => t.duration); | ||
const performanceResult = new performance_result_1.PerformanceResult(); | ||
const avgAndSte = calculator_1.default.getAverageAndStandardDeviation(durationList); | ||
performanceResult.name = group[0].name; | ||
performanceResult.brName = analyzeByBrowser ? group[0].brName : "general"; | ||
performanceResult.earliestTime = group[0].startDisplayTime; | ||
performanceResult.latestTime = group[group.length - 1].startDisplayTime; | ||
performanceResult.avgTime = avgAndSte[0]; | ||
performanceResult.sem = avgAndSte[1]; | ||
performanceResult.repeats = durationList.length; | ||
performanceResult.minValue = Math.min(...durationList); | ||
performanceResult.maxValue = Math.max(...durationList); | ||
this._performanceResults.push(performanceResult); | ||
}); | ||
const picked = this._performanceResults.map(({ name, brName, avgTime, sem, repeats, minValue, maxValue }) => ({ name, brName, avgTime, sem, repeats, minValue, maxValue })); | ||
this._logger.info("Performance-Total results:"); | ||
console.table(picked); | ||
await this.serializeData(saveDataFilePath); | ||
this._logger.info(`\nPerformance-Total results saved to: ${saveDataFilePath}.csv/json\n`); | ||
} | ||
serializeData(saveDataFilePath) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const fileWriter = file_writer_1.FileWriter.getInstance(); | ||
yield fileWriter.writeToFile(saveDataFilePath + ".json", JSON.stringify(this._performanceResults)); | ||
const csv = new objects_to_csv_1.default(this._performanceResults); | ||
const csvString = yield csv.toString(true); | ||
yield fileWriter.writeToFile(saveDataFilePath + ".csv", csvString); | ||
}); | ||
async serializeData(saveDataFilePath) { | ||
const fileWriter = file_writer_1.FileWriter.getInstance(); | ||
await fileWriter.writeToFile(saveDataFilePath + ".json", JSON.stringify(this._performanceResults)); | ||
const csv = new objects_to_csv_1.default(this._performanceResults); | ||
const csvString = await csv.toString(true); | ||
await fileWriter.writeToFile(saveDataFilePath + ".csv", csvString); | ||
} | ||
deserializeData(fileName) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const resultsArray = new Array(); | ||
const textResultsArray = yield file_writer_1.FileWriter.getInstance().readAllLines(fileName); | ||
textResultsArray.forEach(textResult => { | ||
if (textResult != "") { | ||
const performanceResult = JSON.parse(textResult); | ||
if (performanceResult.id !== undefined) { | ||
resultsArray.push(performanceResult); | ||
} | ||
async deserializeData(fileName) { | ||
const resultsArray = new Array(); | ||
const textResultsArray = await file_writer_1.FileWriter.getInstance().readAllLines(fileName); | ||
textResultsArray.forEach(textResult => { | ||
if (textResult != "") { | ||
const performanceResult = JSON.parse(textResult); | ||
if (performanceResult.id !== undefined) { | ||
resultsArray.push(performanceResult); | ||
} | ||
}); | ||
return resultsArray; | ||
} | ||
}); | ||
return resultsArray; | ||
} | ||
} | ||
exports.PerformanceAnalyzer = PerformanceAnalyzer; |
@@ -0,0 +0,0 @@ import { PartialLogEntry } from "./entities/partial-log-entry"; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -35,7 +26,5 @@ exports.PerformanceCache = void 0; | ||
} | ||
flush(fileName, browser, isTestPassed) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.createPerformanceEntries(isTestPassed, browser); | ||
yield this.writePerformanceDataToFile(fileName); | ||
}); | ||
async flush(fileName, browser, isTestPassed) { | ||
this.createPerformanceEntries(isTestPassed, browser); | ||
await this.writePerformanceDataToFile(fileName); | ||
} | ||
@@ -73,3 +62,2 @@ setSample(stepType, stepName, instanceId) { | ||
revStartEntries.forEach(startEntry => { | ||
var _a; | ||
const tempPerformanceEntry = new performance_log_entry_1.PerformanceLogEntry(); | ||
@@ -81,3 +69,3 @@ const correspondedEndEntry = this._endLogEntries.find((e) => e.id == startEntry.id); | ||
tempPerformanceEntry.name = correspondedEndEntry.name; | ||
tempPerformanceEntry.brName = (_a = browser.capabilities.browserName) !== null && _a !== void 0 ? _a : ""; | ||
tempPerformanceEntry.brName = browser.capabilities.browserName ?? ""; | ||
tempPerformanceEntry.startDisplayTime = startEntry.displayTime; | ||
@@ -106,12 +94,10 @@ tempPerformanceEntry.startTime = startEntry.time; | ||
} | ||
writePerformanceDataToFile(fileName) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
for (let performanceEntry of this._performanceEntries) { | ||
yield file_writer_1.FileWriter.getInstance().appendLineToFile(fileName, `${JSON.stringify(performanceEntry)}\n`); | ||
} | ||
; | ||
this.clearData(); | ||
}); | ||
async writePerformanceDataToFile(fileName) { | ||
for (let performanceEntry of this._performanceEntries) { | ||
await file_writer_1.FileWriter.getInstance().appendLineToFile(fileName, `${JSON.stringify(performanceEntry)}\n`); | ||
} | ||
; | ||
this.clearData(); | ||
} | ||
} | ||
exports.PerformanceCache = PerformanceCache; |
@@ -26,3 +26,3 @@ declare class PerformanceTotal { | ||
*/ | ||
analyzeResults({ performanceResultsFileName, dropResultsFromFailedTest, analyzeByBrowser }: initializeParams): Promise<void>; | ||
analyzeResults({ performanceResultsFileName, dropResultsFromFailedTest, analyzeByBrowser, recentDays }: initializeParams): Promise<void>; | ||
} | ||
@@ -35,2 +35,3 @@ declare const _default: PerformanceTotal; | ||
analyzeByBrowser?: boolean; | ||
recentDays?: number; | ||
} |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -40,22 +31,20 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
*/ | ||
initialize(disableAppendToExistingFile, performanceResultsDirectory) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let resultsDir = ""; | ||
const fileWriter = file_writer_1.FileWriter.getInstance(); | ||
if (!global._performanceTotalResultsDir) { | ||
resultsDir = yield fileWriter.createResultsDirIfNotExist(performanceResultsDirectory); | ||
global._performanceTotalResultsDir = resultsDir; | ||
} | ||
else { | ||
resultsDir = global._performanceTotalResultsDir; | ||
} | ||
const initObj = JSON.stringify({ "startDisplayTime": new Date().toLocaleString(), "instanceID": this._instanceid }); | ||
const fileName = path_1.default.join(resultsDir, this.logFileName); | ||
if (disableAppendToExistingFile) { | ||
yield fileWriter.writeToFile(fileName, `${initObj}\n`); | ||
} | ||
else { | ||
yield fileWriter.appendLineToFile(fileName, `${initObj}\n`); | ||
} | ||
}); | ||
async initialize(disableAppendToExistingFile, performanceResultsDirectory) { | ||
let resultsDir = ""; | ||
const fileWriter = file_writer_1.FileWriter.getInstance(); | ||
if (!global._performanceTotalResultsDir) { | ||
resultsDir = await fileWriter.createResultsDirIfNotExist(performanceResultsDirectory); | ||
global._performanceTotalResultsDir = resultsDir; | ||
} | ||
else { | ||
resultsDir = global._performanceTotalResultsDir; | ||
} | ||
const initObj = JSON.stringify({ "startDisplayTime": new Date().toLocaleString(), "instanceID": this._instanceid }); | ||
const fileName = path_1.default.join(resultsDir, this.logFileName); | ||
if (disableAppendToExistingFile) { | ||
await fileWriter.writeToFile(fileName, `${initObj}\n`); | ||
} | ||
else { | ||
await fileWriter.appendLineToFile(fileName, `${initObj}\n`); | ||
} | ||
} | ||
@@ -66,6 +55,4 @@ /** | ||
*/ | ||
finalizeTest(browser, isTestPassed) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.performanceCache.flush(file_writer_1.FileWriter.getInstance().getFilePath(global._performanceTotalResultsDir, this.logFileName), browser, isTestPassed); | ||
}); | ||
async finalizeTest(browser, isTestPassed) { | ||
await this.performanceCache.flush(file_writer_1.FileWriter.getInstance().getFilePath(global._performanceTotalResultsDir, this.logFileName), browser, isTestPassed); | ||
} | ||
@@ -78,15 +65,13 @@ /** | ||
*/ | ||
analyzeResults({ performanceResultsFileName, dropResultsFromFailedTest, analyzeByBrowser }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const analyzer = new performance_analyzer_1.PerformanceAnalyzer(); | ||
const fileWriter = file_writer_1.FileWriter.getInstance(); | ||
let resultsFileName = this._performanceResultsFileName; | ||
const resultsDir = global._performanceTotalResultsDir; | ||
if (performanceResultsFileName) { | ||
resultsFileName = performanceResultsFileName; | ||
} | ||
yield analyzer.analyze(fileWriter.getFilePath(resultsDir, this.logFileName), fileWriter.getFilePath(resultsDir, resultsFileName), dropResultsFromFailedTest, analyzeByBrowser); | ||
}); | ||
async analyzeResults({ performanceResultsFileName, dropResultsFromFailedTest, analyzeByBrowser, recentDays }) { | ||
const analyzer = new performance_analyzer_1.PerformanceAnalyzer(); | ||
const fileWriter = file_writer_1.FileWriter.getInstance(); | ||
let resultsFileName = this._performanceResultsFileName; | ||
const resultsDir = global._performanceTotalResultsDir; | ||
if (performanceResultsFileName) { | ||
resultsFileName = performanceResultsFileName; | ||
} | ||
await analyzer.analyze(fileWriter.getFilePath(resultsDir, this.logFileName), fileWriter.getFilePath(resultsDir, resultsFileName), dropResultsFromFailedTest, analyzeByBrowser, recentDays); | ||
} | ||
} | ||
exports.default = new PerformanceTotal(); |
@@ -0,0 +0,0 @@ import { Options } from "./entities/options"; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -40,25 +31,17 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
} | ||
before(config, capabilities, browser) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this._browser = browser; | ||
yield performance_total_1.default.initialize(this._serviceOptions.disableAppendToExistingFile, this._serviceOptions.performanceResultsDirectory); | ||
}); | ||
async before(config, capabilities, browser) { | ||
this._browser = browser; | ||
await performance_total_1.default.initialize(this._serviceOptions.disableAppendToExistingFile, this._serviceOptions.performanceResultsDirectory); | ||
} | ||
//@ts-ignore | ||
afterTest(test, context, { error, result, duration, passed, retries }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield performance_total_1.default.finalizeTest(this._browser, passed); | ||
}); | ||
async afterTest(test, context, { error, result, duration, passed, retries }) { | ||
await performance_total_1.default.finalizeTest(this._browser, passed); | ||
} | ||
afterScenario(test, context) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield performance_total_1.default.finalizeTest(this._browser, test.result.status == Status.PASSED); | ||
}); | ||
async afterScenario(test, context) { | ||
await performance_total_1.default.finalizeTest(this._browser, test.result.status == Status.PASSED); | ||
} | ||
after(exitCode, config, capabilities) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield performance_total_1.default.analyzeResults({ performanceResultsFileName: this._serviceOptions.performanceResultsFileName, dropResultsFromFailedTest: this._serviceOptions.dropResultsFromFailedTest, analyzeByBrowser: this._serviceOptions.analyzeByBrowser }); | ||
}); | ||
async after(exitCode, config, capabilities) { | ||
await performance_total_1.default.analyzeResults({ performanceResultsFileName: this._serviceOptions.performanceResultsFileName, dropResultsFromFailedTest: this._serviceOptions.dropResultsFromFailedTest, analyzeByBrowser: this._serviceOptions.analyzeByBrowser, recentDays: this._serviceOptions.recentDays }); | ||
} | ||
} | ||
exports.default = PerformanceTotalService; |
{ | ||
"name": "wdio-performancetotal-service", | ||
"version": "3.1.0", | ||
"version": "4.0.1-1", | ||
"description": "WebdriverIO service for analyzing test flow performance", | ||
@@ -26,10 +26,9 @@ "main": "build/app.js", | ||
"@types/objects-to-csv": "^1.3.1", | ||
"@wdio/cli": "^8.0.13", | ||
"@wdio/local-runner": "^8.0.13", | ||
"@wdio/mocha-framework": "^8.0.13", | ||
"@wdio/spec-reporter": "^8.0.13", | ||
"geckodriver": "^3.2.0", | ||
"@wdio/cli": "^9.5.1", | ||
"@wdio/dot-reporter": "^9.5.0", | ||
"@wdio/local-runner": "^9.5.1", | ||
"@wdio/mocha-framework": "^9.5.0", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.3.5", | ||
"wdio-geckodriver-service": "^4.0.0" | ||
"webdriverio": "^9.5.1" | ||
}, | ||
@@ -36,0 +35,0 @@ "dependencies": { |
@@ -44,3 +44,4 @@ # performance-total | ||
performanceResultsDirectory: "performance-results", | ||
analyzeByBrowser: false | ||
analyzeByBrowser: false, | ||
recentDays: 0 | ||
}] | ||
@@ -74,2 +75,5 @@ ] | ||
<h3>recentDays</h3> | ||
To set the number of days to consider for performance analysis set the number of days. Partial days are also supported (e.g. `recentDays: 0.5`) | ||
<h3>performanceResultsDirectory</h3> | ||
@@ -76,0 +80,0 @@ You can override the default path for the results directory in the project's root dir. |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
9
32
139
35248
755
3