Skip to content

Commit

Permalink
Add e2e test suite hash choices
Browse files Browse the repository at this point in the history
  • Loading branch information
schaumb committed Jul 30, 2024
1 parent 9cb3b5b commit 1623d2c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
16 changes: 10 additions & 6 deletions test/e2e/accept-changes.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ const fs = require('fs')
const prettier = require('prettier')

function copyHashes(failHashFile, refHashFile) {
const failHashData = JSON.parse(fs.readFileSync(failHashFile))
let failHashData
try {
failHashData = JSON.parse(fs.readFileSync(failHashFile))
} catch (error) {
return
}
const refHashData = JSON.parse(fs.readFileSync(refHashFile))

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

copyHashes('test_report/results/test_cases/test_cases.json', 'test_cases/test_cases.json')
/*
copyHashes(
"test_report/results/tests/style/style_tests.json",
"tests/style_tests.json"
) */
copyHashes('test_report/results/tests/style_tests/style_tests.json', 'tests/style_tests.json')
copyHashes('test_report/results/tests/features/features.json', 'tests/features.json')
copyHashes('test_report/results/tests/fixes/fixes.json', 'tests/fixes.json')
copyHashes('test_report/results/tests/config_tests/config_tests.json', 'tests/config_tests.json')
11 changes: 9 additions & 2 deletions test/e2e/modules/e2e-test/test-suite-result.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ class TestSuiteResult {
if (this.#createHashes !== 'DISABLED') {
if (
this.#createHashes === 'ALL' ||
(this.#createHashes === 'FAILED' &&
(this.#createHashes === 'FAILED' && this.#testSuiteResults.FAILED.length !== 0) ||
(this.#createHashes === 'FAILURES' &&
(this.#testSuiteResults.FAILED.length !== 0 ||
this.#testSuiteResults.WARNING.length !== 0))
) {
Expand All @@ -100,12 +101,18 @@ class TestSuiteResult {
})
for (const [key] of Object.entries(this.#testSuiteResults.RESULTS)) {
if (
this.#createHashes === 'FAILED' &&
this.#createHashes === 'FAILURES' &&
!this.#testSuiteResults.FAILED.includes(key) &&
!this.#testSuiteResults.WARNING.includes(key)
) {
continue
}
if (
this.#createHashes === 'FAILED' &&
!this.#testSuiteResults.FAILED.includes(key)
) {
continue
}
Object.keys(testCasesConfig).forEach((suite) => {
if (key.startsWith(suite)) {
if (this.#testSuiteResults.RESULTS[key].hash) {
Expand Down
7 changes: 4 additions & 3 deletions test/e2e/test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,16 @@ Please note that the test require Chrome, ChromeDriver and Selenium Webdriver to
)
.default('maxFailedImages', null)

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

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

0 comments on commit 1623d2c

Please sign in to comment.