Skip to content

Commit 2a167f1

Browse files
committed
chore: update e2e test configuration
1 parent 9b562ae commit 2a167f1

File tree

5 files changed

+42
-7
lines changed

5 files changed

+42
-7
lines changed

.github/workflows/auto-close.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
with:
1414
repo-token: ${{ secrets.WDIO_BOT_GITHUB_TOKEN }}
1515
only-issue-labels: 'Reproducible Example Missing'
16-
stale-issue-label: ':classical_building: Stale'
16+
stale-issue-label: 'Stale :classical_building:'
1717
days-before-close: 0
1818
days-before-stale: 7
1919
close-issue-message: >

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777

7878
smoke-retro-wdio:
7979
name: Smoke - Run test with temporary configuration file when lower version of WDIO
80-
needs: [lint, build, e2e]
80+
needs: [lint, build, unit, license-check, typecheck, e2e]
8181
uses: ./.github/workflows/ci-smoke.yml
8282
with:
8383
os: "['windows-latest']"

e2e/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"wdio": "wdio run ./wdio.conf.ts"
2929
},
3030
"devDependencies": {
31+
"@actions/core": "^1.11.1",
3132
"@types/semver": "^7.7.0",
3233
"@wdio/cli": "^9.16.2",
3334
"@wdio/globals": "^9.16.2",

e2e/wdio.conf.ts

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as path from 'node:path'
22
import * as url from 'node:url'
33

4+
import * as core from '@actions/core'
45
import { minVersion } from 'semver'
56
import shell from 'shelljs'
67

@@ -10,6 +11,7 @@ import type { Frameworks } from '@wdio/types'
1011
type TestTargets = 'workspace' | 'mocha' | 'jasmine' | 'cucumber'
1112

1213
const __dirname = path.dirname(url.fileURLToPath(import.meta.url))
14+
const prjRoot = path.resolve(__dirname, '..')
1315
const target = (process.env.VSCODE_WDIO_E2E_SCENARIO || 'mocha') as TestTargets
1416

1517
const minimumVersion = minVersion(pkg.engines.vscode)?.version || 'stable'
@@ -34,7 +36,28 @@ function defineSpecs(target: TestTargets) {
3436
}
3537

3638
const specs = defineSpecs(target)
37-
let screenshotCount = 0
39+
40+
class ScreenshotNameGenerator {
41+
private readonly _counterMap = new Map<string, number>
42+
43+
private _generateMapId(file:string, title:string) {
44+
return `${file}-${title}`
45+
}
46+
47+
getFilename(file:string, title:string) {
48+
const mapId = this._generateMapId(file, title)
49+
const counter = this._counterMap.get(mapId)
50+
const newCounter = typeof counter === 'undefined' ? 0 : counter + 1
51+
this._counterMap.set(mapId, newCounter)
52+
const _title = title
53+
.split(' ')
54+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
55+
.join('')
56+
return `screenshot-${path.basename(file)}-${_title}-${newCounter}.png`
57+
}
58+
}
59+
60+
const ssNameGenerator = new ScreenshotNameGenerator()
3861

3962
export function createBaseConfig(workspacePath: string, userSettings = {}): WebdriverIO.Config {
4063
const resolvedUserSettings = Object.assign(
@@ -80,16 +103,24 @@ export function createBaseConfig(workspacePath: string, userSettings = {}): Webd
80103
require: ['assertions/index.ts'],
81104
},
82105
before: async function (_capabilities, _specs, _browser) {
83-
if (process.platform === 'linux') {
84-
const result = shell.exec('xdotool search --onlyvisible --name code')
106+
// For Github Actions on Linux, Maximize the screen by GUI approach
107+
// See also .github/actions/set-screen-resolution/action.yml
108+
if (process.env.GITHUB_ACTIONS === 'true' && process.platform === 'linux') {
109+
const result = shell.exec('xdotool search --onlyvisible --name code', { silent: true })
85110
const windowId = result.stdout.trim()
86111
shell.exec(`xdotool windowmove ${windowId} 0 0`, { silent: true })
87112
shell.exec(`xdotool windowsize ${windowId} 100% 100%`, { silent: true })
88113
}
89114
},
90-
afterTest: async function (_test: unknown, _context: unknown, result: Frameworks.TestResult) {
115+
afterTest: async function (test: Frameworks.Test, _context: unknown, result: Frameworks.TestResult) {
91116
if (!result.passed) {
92-
await browser.saveScreenshot(path.join(outputDir, `screenshot-${screenshotCount++}.png`))
117+
await browser.saveScreenshot(path.join(outputDir, ssNameGenerator.getFilename(test.file, test.title)))
118+
}
119+
if (process.env.GITHUB_ACTIONS === 'true' && result.retries.attempts === 1) {
120+
core.warning(`Retried: ${test.title}`, {
121+
title: 'Test was retried.',
122+
file: path.relative(prjRoot, test.file),
123+
})
93124
}
94125
},
95126
}

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)