import { expect } from '@wdio/globals'
import { execSync } from 'node:child_process'
import { XvfbManager } from '@wdio/xvfb'
describe('xvfb fresh installation', () => {
it('should install xvfb using detected package manager', async function(this: Mocha.Context) {
this.timeout(300000)
const manager = new XvfbManager({ autoInstall: true })
expect(manager.shouldRun()).toBe(true)
const result = await manager.init()
expect(result).toBe(true)
const xvfbRunPath = execSync('which xvfb-run', { encoding: 'utf8' }).trim()
expect(xvfbRunPath).toContain('xvfb-run')
})
it('should verify xvfb works after installation', async function(this: Mocha.Context) {
this.timeout(300000)
const manager = new XvfbManager({ autoInstall: true })
const result = await manager.init()
expect(result).toBe(true)
try {
const testResult = execSync('xvfb-run --auto-servernum -- echo "installation verified"', {
encoding: 'utf8',
timeout: 10000
})
expect(testResult.trim()).toBe('installation verified')
} catch (error) {
throw new Error(`xvfb-run execution failed after installation: ${error}`)
}
})
})