@replayio/test-utils
Advanced tools
Comparing version 0.2.3-alpha.0 to 0.2.3
{ | ||
"name": "@replayio/test-utils", | ||
"version": "0.2.3-alpha.0", | ||
"version": "0.2.3", | ||
"description": "Utilities for recording tests with replay.io", | ||
@@ -29,8 +29,7 @@ "main": "src/index.js", | ||
"dependencies": { | ||
"@replayio/replay": "^0.10.2-alpha.0", | ||
"@replayio/replay": "^0.10.2", | ||
"@types/node-fetch": "^2.6.2", | ||
"node-fetch": "^2.6.7", | ||
"uuid": "^8.3.2" | ||
}, | ||
"gitHead": "c6826b5eb559a984bebcd660ac0ea8a5a48dc0af" | ||
} | ||
} |
"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) { | ||
@@ -22,24 +13,26 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
} | ||
function pingTestMetrics(recordingId, runId, test) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!shouldReportTestMetrics()) | ||
return; | ||
const webhookUrl = process.env.RECORD_REPLAY_WEBHOOK_URL || "https://webhooks.replay.io"; | ||
try { | ||
return yield (0, node_fetch_1.default)(`${webhookUrl}/api/metrics`, { | ||
method: "POST", | ||
headers: { "Content-Type": "application/json" }, | ||
body: JSON.stringify({ | ||
type: "test.finished", | ||
recordingId, | ||
test: Object.assign(Object.assign({}, test), { platform: os_1.default.platform, runId }), | ||
}), | ||
}); | ||
} | ||
catch (e) { | ||
console.log("Failed to send test metrics", e); | ||
} | ||
}); | ||
async function pingTestMetrics(recordingId, runId, test) { | ||
if (!shouldReportTestMetrics()) | ||
return; | ||
const webhookUrl = process.env.RECORD_REPLAY_WEBHOOK_URL || "https://webhooks.replay.io"; | ||
try { | ||
return await (0, node_fetch_1.default)(`${webhookUrl}/api/metrics`, { | ||
method: "POST", | ||
headers: { "Content-Type": "application/json" }, | ||
body: JSON.stringify({ | ||
type: "test.finished", | ||
recordingId, | ||
test: { | ||
...test, | ||
platform: os_1.default.platform, | ||
runId, | ||
}, | ||
}), | ||
}); | ||
} | ||
catch (e) { | ||
console.log("Failed to send test metrics", e); | ||
} | ||
} | ||
exports.pingTestMetrics = pingTestMetrics; | ||
//# sourceMappingURL=metrics.js.map |
@@ -13,2 +13,3 @@ export interface ReplayReporterConfig { | ||
id: string; | ||
parentId?: string; | ||
name: string; | ||
@@ -15,0 +16,0 @@ args?: any[]; |
@@ -19,3 +19,3 @@ "use strict"; | ||
function parseRuntime(runtime) { | ||
return ["chromium", "gecko", "node"].find(r => runtime === null || runtime === void 0 ? void 0 : runtime.includes(r)); | ||
return ["chromium", "gecko", "node"].find(r => runtime?.includes(r)); | ||
} | ||
@@ -91,3 +91,3 @@ class ReplayReporter { | ||
} | ||
catch (_a) { | ||
catch { | ||
console.warn("Failed to parse Replay metadata"); | ||
@@ -106,8 +106,10 @@ } | ||
this.startTimes[this.getTestId(testId)] = Date.now(); | ||
(0, fs_1.writeFileSync)(metadataFilePath, JSON.stringify(Object.assign(Object.assign({}, (this.baseMetadata || {})), { "x-replay-test": { | ||
(0, fs_1.writeFileSync)(metadataFilePath, JSON.stringify({ | ||
...(this.baseMetadata || {}), | ||
"x-replay-test": { | ||
id: this.getTestId(testId), | ||
} }), undefined, 2), {}); | ||
}, | ||
}, undefined, 2), {}); | ||
} | ||
onTestEnd(tests, replayTitle) { | ||
var _a; | ||
const recs = (0, replay_1.listAllRecordings)({ | ||
@@ -128,14 +130,17 @@ filter: `function($v) { $v.metadata.\`x-replay-test\`.id in ${JSON.stringify(tests.map(test => this.getTestId(test.id)))} and $not($exists($v.metadata.test)) }`, | ||
runtime = recs[0].runtime; | ||
recs.forEach(rec => (0, metadata_1.add)(rec.id, Object.assign({ title: replayTitle || test.title }, metadata_1.test.init({ | ||
recs.forEach(rec => (0, metadata_1.add)(rec.id, { | ||
title: replayTitle || test.title, | ||
result, | ||
path: test.path, | ||
runner: this.runner, | ||
run: { | ||
id: this.baseId, | ||
title: this.runTitle, | ||
}, | ||
file: test.relativePath, | ||
tests: tests, | ||
})))); | ||
...metadata_1.test.init({ | ||
title: replayTitle || test.title, | ||
result, | ||
path: test.path, | ||
runner: this.runner, | ||
run: { | ||
id: this.baseId, | ||
title: this.runTitle, | ||
}, | ||
file: test.relativePath, | ||
tests: tests, | ||
}), | ||
})); | ||
} | ||
@@ -149,3 +154,3 @@ const startTime = this.startTimes[this.getTestId(test.id)]; | ||
runtime: parseRuntime(runtime), | ||
runner: (_a = this.runner) === null || _a === void 0 ? void 0 : _a.name, | ||
runner: this.runner?.name, | ||
}); | ||
@@ -152,0 +157,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.removeAnsiCodes = void 0; | ||
const removeAnsiCodes = (message) => message === null || message === void 0 ? void 0 : message.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, ""); | ||
const removeAnsiCodes = (message) => message?.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, ""); | ||
exports.removeAnsiCodes = removeAnsiCodes; | ||
//# sourceMappingURL=terminal.js.map |
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
19783
271
Updated@replayio/replay@^0.10.2