Skip to content

Commit 69f0bd5

Browse files
committed
chore: create method for evaluating session status
1 parent 7619e61 commit 69f0bd5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

playwright-test/fixtures.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ const patchCaps = (name, title) => {
4545

4646
const isHash = (entity) => Boolean(entity && typeof(entity) === "object" && !Array.isArray(entity));
4747
const nestedKeyValue = (hash, keys) => keys.reduce((hash, key) => (isHash(hash) ? hash[key] : undefined), hash);
48+
const evaluateSessionsStatus = (status) => {
49+
if (status === "passed") {
50+
return "passed";
51+
} else if (status === "failed" || status === "timedOut") {
52+
return "failed";
53+
} else {
54+
return "";
55+
}
56+
}
4857

4958
exports.test = base.test.extend({
5059
page: async ({ page, playwright }, use, testInfo) => {
@@ -62,7 +71,7 @@ exports.test = base.test.extend({
6271
const testResult = {
6372
action: 'setSessionStatus',
6473
arguments: {
65-
status: testInfo.status === "passed" ? "passed" : "skipped" ? "" : "failed",
74+
status: evaluateSessionsStatus(testInfo.status),
6675
reason: nestedKeyValue(testInfo, ['error', 'message'])
6776
},
6877
};

0 commit comments

Comments
 (0)