545e421423
Github action CI workflows added for webdriver tests.
I've also refactored the `./scripts/e2e-*` scripts. These scripts were
somewhat unique compared to the other scripts. They are now more inline
with the other scripts in that directory and run via
```
% yarn e2e --help
Usage: yarn e2e <command> [options]
Commands:
yarn e2e serve start test server
yarn e2e test:ci [env] runner for CI (github-actions)
yarn e2e test:local run webdriver tests locally
yarn e2e test:browserstack run webdriver tests on browserstack
yarn e2e selenium:grid start selenium grid (test linux)
Options:
--help Show help [boolean]
--version Show version number [boolean]
```
I've also added an experimental linux runner see
2cca4ddb77/e2e/README.md (L320-L333)
### Change Type
- [x] `tests` — Changes to any testing-related code only (will not
publish a new version)
### Release Notes
- Github action CI workflows added for webdriver tests
- Refactored e2e test runner
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
import { ChildProcess, spawn } from 'node:child_process'
|
|
import kill from 'tree-kill'
|
|
import { exec } from '../../lib/exec'
|
|
import { promiseSpawn } from './util'
|
|
|
|
export default async function testCi({ testEnv }: { testEnv: string }) {
|
|
await promiseSpawn('yarn', ['workspace', '@tldraw/tldraw', 'prebuild'], {
|
|
env: {
|
|
...process.env,
|
|
},
|
|
stdio: [0, 0, 0], // Use parent's [stdin, stdout, stderr]
|
|
})
|
|
|
|
const { success: foundStartMessage, commandProcess } = await new Promise<{
|
|
success: boolean
|
|
commandProcess: ChildProcess
|
|
}>((resolve, reject) => {
|
|
const p = spawn('yarn', ['dev-webdriver'], {
|
|
env: {
|
|
...process.env,
|
|
ENABLE_SSL: '1',
|
|
ENABLE_NETWORK_CACHING: '1',
|
|
},
|
|
})
|
|
|
|
const endHandler = () => {
|
|
p.stdout.off('end', endHandler)
|
|
reject({ success: false, commandProcess: p })
|
|
}
|
|
|
|
const dataHandler = (data: any) => {
|
|
if (data.toString().match(/\[tldraw:process_ready\]/gm)) {
|
|
// p.stdout.off('data', dataHandler)
|
|
resolve({ success: true, commandProcess: p })
|
|
}
|
|
console.log(`stdout: ${data}`)
|
|
}
|
|
p.stdout.on('data', dataHandler)
|
|
p.stdout.on('close', endHandler)
|
|
})
|
|
|
|
if (!foundStartMessage) {
|
|
console.error('Failed to start server')
|
|
process.exit(1)
|
|
}
|
|
|
|
const exitCode = await exec('yarn', ['workspace', '@tldraw/e2e', `test:${testEnv}`], {
|
|
env: {
|
|
...process.env,
|
|
BROWSERS: ['chrome'].join(','),
|
|
// OS: [process.platform].join(','),
|
|
},
|
|
})
|
|
|
|
if (commandProcess.pid) {
|
|
kill(commandProcess.pid)
|
|
}
|
|
|
|
return exitCode
|
|
}
|