tldraw/scripts/e2e/commands/util.ts
Orange Mug 545e421423
Adds CI for webdriver tests (#1343)
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
2023-05-12 15:25:14 +00:00

16 lines
390 B
TypeScript

import { SpawnOptions, spawn } from 'child_process'
import kill from 'tree-kill'
export function promiseSpawn(command: string, args: string[], opts: SpawnOptions) {
return new Promise<number>((resolve) => {
const p = spawn(command, args, opts)
p.on('close', (exitCode) => {
resolve(exitCode ?? 0)
})
process.on('SIGINT', () => {
if (p.pid) {
kill(p.pid)
}
})
})
}