Skip to content

Commit 87be7c1

Browse files
ergunshDevtools-frontend LUCI CQ
authored andcommitted
[TestRunner] Add auto-watch option for unit tests
This allows a workflow with: * Running `watch_build` to re-compile files with esbuild after each change in a matter of milliseconds. * Triggering tests after re-compilation without paying the setup costs again and without needing to run the tests again. Bug: none Change-Id: If8317b07e484e8f33fd902650601c1c946a61fc6 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6185445 Commit-Queue: Philip Pfaffe <[email protected]> Commit-Queue: Ergün Erdoğmuş <[email protected]> Auto-Submit: Ergün Erdoğmuş <[email protected]> Reviewed-by: Philip Pfaffe <[email protected]>
1 parent 798b81f commit 87be7c1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

test/run.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ const options = commandLineArgs(yargs(process.argv.slice(2)))
2525
.options('debug-driver', {type: 'boolean', hidden: true, desc: 'Debug the driver part of tests'})
2626
.options('verbose', {alias: 'v', type: 'count', desc: 'Increases the log level'})
2727
.options('bail', {alias: 'b', desc: ' bail after first test failure'})
28+
.options('auto-watch', {
29+
desc: 'watch changes to files and run tests automatically on file change (only for unit tests)'
30+
})
2831
.positional('tests', {
2932
type: 'string',
3033
desc: 'Path to the test suite, starting from out/Target/gen directory.',
@@ -104,6 +107,7 @@ class Tests {
104107
protected run(tests: PathPair[], args: string[], positionalTestArgs = true) {
105108
const argumentsForNode = [
106109
...args,
110+
...(options['auto-watch'] ? ['--auto-watch', '--no-single-run'] : []),
107111
'--',
108112
...tests.map(t => positionalTestArgs ? t.buildPath : `--tests=${t.buildPath}`),
109113
...forwardOptions(),

test/unit/karma.conf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ module.exports = function(config: any) {
7474
const targetDir = path.relative(SOURCE_ROOT, GEN_DIR);
7575
const options = {
7676
basePath: CHECKOUT_ROOT,
77-
autoWatchBatchDelay: 3000,
77+
autoWatchBatchDelay: 1000,
7878

7979
files: [
8080
// Global hooks in test_setup must go first

0 commit comments

Comments
 (0)