Skip to content

Commit d40cc26

Browse files
authored
Merge pull request #562 from vizzuhq/test-suite-failures-script
Add e2e test suite failed/failure hash choices
2 parents 55be4e2 + 9a9786f commit d40cc26

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

test/e2e/accept-changes.cjs

+10-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ const fs = require('fs')
22
const prettier = require('prettier')
33

44
function copyHashes(failHashFile, refHashFile) {
5-
const failHashData = JSON.parse(fs.readFileSync(failHashFile))
5+
let failHashData
6+
try {
7+
failHashData = JSON.parse(fs.readFileSync(failHashFile))
8+
} catch (error) {
9+
return
10+
}
611
const refHashData = JSON.parse(fs.readFileSync(refHashFile))
712

813
for (const testFilename in failHashData.test) {
@@ -25,8 +30,7 @@ function copyHashes(failHashFile, refHashFile) {
2530
}
2631

2732
copyHashes('test_report/results/test_cases/test_cases.json', 'test_cases/test_cases.json')
28-
/*
29-
copyHashes(
30-
"test_report/results/tests/style/style_tests.json",
31-
"tests/style_tests.json"
32-
) */
33+
copyHashes('test_report/results/tests/style_tests/style_tests.json', 'tests/style_tests.json')
34+
copyHashes('test_report/results/tests/features/features.json', 'tests/features.json')
35+
copyHashes('test_report/results/tests/fixes/fixes.json', 'tests/fixes.json')
36+
copyHashes('test_report/results/tests/config_tests/config_tests.json', 'tests/config_tests.json')

test/e2e/modules/e2e-test/test-suite-result.cjs

+9-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ class TestSuiteResult {
8585
if (this.#createHashes !== 'DISABLED') {
8686
if (
8787
this.#createHashes === 'ALL' ||
88-
(this.#createHashes === 'FAILED' &&
88+
(this.#createHashes === 'FAILED' && this.#testSuiteResults.FAILED.length !== 0) ||
89+
(this.#createHashes === 'FAILURES' &&
8990
(this.#testSuiteResults.FAILED.length !== 0 ||
9091
this.#testSuiteResults.WARNING.length !== 0))
9192
) {
@@ -100,12 +101,18 @@ class TestSuiteResult {
100101
})
101102
for (const [key] of Object.entries(this.#testSuiteResults.RESULTS)) {
102103
if (
103-
this.#createHashes === 'FAILED' &&
104+
this.#createHashes === 'FAILURES' &&
104105
!this.#testSuiteResults.FAILED.includes(key) &&
105106
!this.#testSuiteResults.WARNING.includes(key)
106107
) {
107108
continue
108109
}
110+
if (
111+
this.#createHashes === 'FAILED' &&
112+
!this.#testSuiteResults.FAILED.includes(key)
113+
) {
114+
continue
115+
}
109116
Object.keys(testCasesConfig).forEach((suite) => {
110117
if (key.startsWith(suite)) {
111118
if (this.#testSuiteResults.RESULTS[key].hash) {

test/e2e/test.cjs

+4-3
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,16 @@ Please note that the test require Chrome, ChromeDriver and Selenium Webdriver to
9393
)
9494
.default('maxFailedImages', null)
9595

96-
.choices('hashes', ['ALL', 'FAILED', 'DISABLED'])
96+
.choices('hashes', ['ALL', 'FAILED', 'FAILURES', 'DISABLED'])
9797
.describe(
9898
'hashes',
9999
'Change the saving behavior of hashes, which are unique identifiers calculated for each test case' +
100100
'\n- "ALL": Write hashes into the report file for every test' +
101-
'\n- "FAILED": Write hashes into the report file for failed/warning tests only' +
101+
'\n- "FAILED": Write hashes into the report file for failed tests only' +
102+
'\n- "FAILURES": Write hashes into the report file for failed/warning tests only' +
102103
'\n- "DISABLED": Do not create report file'
103104
)
104-
.default('hashes', 'FAILED')
105+
.default('hashes', 'FAILURES')
105106

106107
.boolean('nologs')
107108
.describe('nologs', 'Disable the saving of browser and console logs into a log file')

0 commit comments

Comments
 (0)