tldraw/scripts/e2e/index.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

94 lines
2 KiB
TypeScript

import { hideBin } from 'yargs/helpers'
import yargs from 'yargs/yargs'
import * as commands from './commands'
yargs(hideBin(process.argv))
.usage('Usage: $0 <command> [options]')
.scriptName('yarn e2e')
.command(
'serve',
'start test server',
(yargs) => {
return yargs
},
async () => {
const exitCode = await commands.serve()
process.exit(exitCode)
}
)
.command(
'test:ci [env]',
'runner for CI (github-actions)',
(yargs) => {
return yargs.positional('env', {
type: 'string',
default: 'local',
choices: ['local', 'nightly'],
})
},
async (argv) => {
await commands.testCi({ testEnv: argv.env })
// process.exit(exitCode)
}
)
.command(
'test:local',
'run webdriver tests locally',
(yargs) => {
return yargs
.option('browser', {
alias: 'b',
type: 'array',
description: 'run with browsers',
choices: ['chrome', 'firefox', 'safari', 'edge', 'vscode'],
default: ['chrome'],
})
.option('os', {
type: 'string',
description: 'OS to run on (experimental)',
choices: [process.platform, 'linux'],
default: process.platform,
})
},
async (argv) => {
const exitCode = await commands.testLocal(argv)
process.exit(exitCode)
}
)
.command(
'test:browserstack',
'run webdriver tests on browserstack',
(yargs) => {
return yargs
.option('browser', {
alias: 'b',
type: 'array',
description: 'run with browsers',
choices: ['chrome', 'firefox', 'safari', 'edge'],
default: ['chrome'],
})
.option('os', {
type: 'array',
description: 'OS to run on (experimental)',
choices: [process.platform, 'linux'],
default: [process.platform],
})
},
async (argv) => {
const exitCode = await commands.testBrowserstack(argv)
process.exit(exitCode)
}
)
.command(
'selenium:grid',
'start selenium grid (test linux)',
(yargs) => {
return yargs
},
async () => {
const exitCode = await commands.seleniumGrid()
process.exit(exitCode)
}
)
.strict()
.parse()