-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwdio.conf.ts
More file actions
103 lines (88 loc) · 3.53 KB
/
wdio.conf.ts
File metadata and controls
103 lines (88 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import * as path from 'node:path'
import * as url from 'node:url'
import { minVersion } from 'semver'
import shell from 'shelljs'
import pkg from '../packages/vscode-webdriverio/package.json' with { type: 'json' }
import type { Frameworks } from '@wdio/types'
type TestTargets = 'workspace' | 'mocha' | 'jasmine' | 'cucumber'
const __dirname = path.dirname(url.fileURLToPath(import.meta.url))
const target = (process.env.VSCODE_WDIO_E2E_SCENARIO || 'mocha') as TestTargets
const minimumVersion = minVersion(pkg.engines.vscode)?.version || 'stable'
const isCompatibilityMode = process.env.VSCODE_WDIO_E2E_COMPATIBILITY_MODE === 'yes'
const version = isCompatibilityMode ? minimumVersion : 'stable'
const outputDir = path.join(__dirname, 'logs', [isCompatibilityMode ? 'compatibility' : 'e2e', target].join('-'))
process.env.VSCODE_WDIO_TRACE_LOG_PATH = outputDir
const loglevel = process.env.VSCODE_WDIO_SMOKE_RETRO_WIN ? 'debug' : 'trace'
function defineSpecs(target: TestTargets) {
switch (target) {
case 'cucumber':
return ['./tests/basicCucumber.spec.ts']
case 'workspace':
return ['./tests/basicWorkspace.spec.ts']
default:
return ['./tests/basic.spec.ts']
}
}
const specs = defineSpecs(target)
let screenshotCount = 0
export function createBaseConfig(workspacePath: string, userSettings = {}): WebdriverIO.Config {
const resolvedUserSettings = Object.assign(
{},
{
'webdriverio.logLevel': loglevel,
},
userSettings
)
return {
runner: 'local',
tsConfigPath: './tsconfig.json',
specs,
maxInstances: 10,
capabilities: [
{
browserName: 'vscode',
browserVersion: version,
'wdio:vscodeOptions': {
// points to directory where extension package.json is located
extensionPath: path.resolve('../packages/vscode-webdriverio'),
// optional VS Code settings
userSettings: resolvedUserSettings,
workspacePath: path.resolve(workspacePath),
},
'wdio:enforceWebDriverClassic': true,
},
],
logLevel: 'debug',
outputDir,
bail: 0,
waitforTimeout: 120000,
connectionRetryTimeout: 120000,
connectionRetryCount: 3,
services: [['vscode', { cachePath: path.join(__dirname, '.wdio-vscode-service') }]],
framework: 'mocha',
reporters: ['spec'],
mochaOpts: {
ui: 'bdd',
timeout: 6000000,
require: ['assertions/index.ts'],
},
before: async function (_capabilities, _specs, _browser) {
if (process.platform === 'linux') {
const result = shell.exec('xdotool search --onlyvisible --name code')
const windowId = result.stdout.trim()
shell.exec(`xdotool windowmove ${windowId} 0 0`)
shell.exec(`xdotool windowsize ${windowId} 100% 100%`)
}
},
afterTest: async function (_test: unknown, _context: unknown, result: Frameworks.TestResult) {
if (!result.passed) {
await browser.saveScreenshot(path.join(outputDir, `screenshot-${screenshotCount++}.png`))
}
},
}
}
const workspace = target === 'workspace' ? '../samples/e2e/wdio.code-workspace' : `../samples/e2e/${target}`
export const config: WebdriverIO.Config = {
...createBaseConfig(workspace),
specs,
}