Skip to content

Commit b3b2e1e

Browse files
authored
Merge pull request #31 from asambstack/main
Mark test as passed only when status is passed
2 parents 2709fdd + cf540c4 commit b3b2e1e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

playwright-test/fixtures.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ 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 isUndefined = val => (val === undefined || val === null || val === '');
49+
const evaluateSessionStatus = (status) => {
50+
if (!isUndefined(status)) {
51+
status = status.toLowerCase();
52+
}
53+
if (status === "passed") {
54+
return "passed";
55+
} else if (status === "failed" || status === "timedout") {
56+
return "failed";
57+
} else {
58+
return "";
59+
}
60+
}
4861

4962
exports.test = base.test.extend({
5063
page: async ({ page, playwright }, use, testInfo) => {
@@ -62,7 +75,7 @@ exports.test = base.test.extend({
6275
const testResult = {
6376
action: 'setSessionStatus',
6477
arguments: {
65-
status: testInfo.status,
78+
status: evaluateSessionStatus(testInfo.status),
6679
reason: nestedKeyValue(testInfo, ['error', 'message'])
6780
},
6881
};

0 commit comments

Comments
 (0)