Skip to content

Commit ad65eea

Browse files
committed
sort screenshots by type and previous to other captures in the tests
1 parent 324e34c commit ad65eea

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

scripts/pit/its/test-utils.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,20 @@ async function closePage(page, arg) {
146146
const screenshots = "screenshots.out"
147147
let sscount = 0;
148148
// Screenshot filename format: args.name-args.mode-args.version-test_filename-test_subject-counter.png
149+
// For 'before'/'after' screenshots: prefixed with _0_ and _1_ respectively to sort first in folder
149150
async function takeScreenshot(page, arg, testFile, subject) {
150151
if (process.env.FAST) return;
151152
const testName = path.basename(testFile).replace('.js', '');
152153
const cnt = String(++sscount).padStart(2, "0");
154+
// Use _0_ prefix for 'before' and _1_ prefix for 'after' so they sort first
155+
let prefix = '';
156+
if (subject === 'before') {
157+
prefix = '_0_';
158+
} else if (subject === 'after') {
159+
prefix = '_1_';
160+
}
153161
const parts = [arg.name, arg.mode, arg.version, testName, subject, cnt].filter(Boolean);
154-
const file = `${screenshots}/${parts.join('-')}.png`;
162+
const file = `${screenshots}/${prefix}${parts.join('-')}.png`;
155163
await page.waitForTimeout(/^win/.test(process.platform) ? 10000 : process.env.GITHUB_ACTIONS ? 800 : 200);
156164
await page.screenshot({ path: file });
157165
ok(` 📸 Screenshot taken: ${file}\n`);

0 commit comments

Comments
 (0)