Skip to content

Commit cc5547c

Browse files
Christian Budde Christensenbudde377
authored andcommitted
feat(launcher): Enable specification of retry-limit
Allow specification of retry limit in configuration file with the `retryLimit` property. Closes #1126
1 parent 56073fc commit cc5547c

3 files changed

Lines changed: 83 additions & 60 deletions

File tree

docs/config/01-configuration-file.md

Lines changed: 78 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,6 @@ multiple changes into a single run so that the test runner doesn't try to start
7979
tests more than it should. The configuration setting tells Karma how long to wait (in milliseconds) after any changes
8080
have occurred before starting the test process again.
8181

82-
## restartOnFileChange
83-
**Type:** Boolean
84-
85-
**Default:** `false`
86-
87-
**Description:** When Karma is watching the files for changes, it will delay a new run until
88-
the current run is finished. Enabling this setting will cancel the current run and start a new run
89-
immediately when a change is detected.
9082

9183
## basePath
9284
**Type:** String
@@ -183,6 +175,36 @@ The `client.args` option allows you to set this value for actions other than `ru
183175
How this value is used is up to your test adapter - you should check your adapter's
184176
documentation to see how (and if) it uses this value.
185177

178+
179+
## client.useIframe
180+
**Type:** Boolean
181+
182+
**Default:** `true`
183+
184+
**Description:** Run the tests inside an iFrame or a new window
185+
186+
If true, Karma runs the tests inside an iFrame. If false, Karma runs the tests in a new window. Some tests may not run in an
187+
iFrame and may need a new window to run.
188+
189+
190+
## client.captureConsole
191+
**Type:** Boolean
192+
193+
**Default:** `true`
194+
195+
**Description:** Capture all console output and pipe it to the terminal.
196+
197+
198+
## client.clearContext
199+
**Type:** Boolean
200+
201+
**Default:** `true`
202+
203+
**Description:** Clear the context window
204+
205+
If true, Karma clears the context window upon the completion of running the tests. If false, Karma does not clear the context window
206+
upon the completion of running the tests. Setting this to false is useful when embedding a Jasmine Spec Runner Template.
207+
186208
## colors
187209
**Type:** Boolean
188210

@@ -193,6 +215,16 @@ documentation to see how (and if) it uses this value.
193215
**Description:** Enable or disable colors in the output (reporters and logs).
194216

195217

218+
## concurrency
219+
**Type:** Number
220+
221+
**Default:** `Infinity`
222+
223+
**Description:** How many browser Karma launches in parallel.
224+
225+
Especially on sevices like SauceLabs and Browserstack it makes sense to only launch a limited amount of browsers at once, and only start more when those have finished. Using this configuration you can sepcify how many browsers should be running at once at any given point in time.
226+
227+
196228
## customHeaders
197229
**Type:** Array
198230

@@ -336,6 +368,25 @@ plugins: [
336368
]
337369
```
338370

371+
372+
## mime
373+
**Type:** Object
374+
375+
**Default:** `{}`
376+
377+
**Description:** Redefine default mapping from file extensions to MIME-type
378+
379+
Set property name to required MIME, provide Array of extensions (without dots) as it's value
380+
381+
**Example:**
382+
```javascript
383+
mime: {
384+
'text/x-typescript': ['ts','tsx']
385+
'text/plain' : ['mytxt']
386+
}
387+
```
388+
389+
339390
## plugins
340391
**Type:** Array
341392

@@ -396,6 +447,7 @@ Determines the use of the Node `http` or `https` class.
396447

397448
Note: Using `'https:'` requires you to specify `httpsServerOptions`.
398449

450+
399451
## proxies
400452
**Type:** Object
401453

@@ -458,6 +510,24 @@ Additional reporters, such as `growl`, `junit`, `teamcity` or `coverage` can be
458510
Note: Just about all additional reporters in Karma (other than progress) require an additional library to be installed (via NPM).
459511

460512

513+
## restartOnFileChange
514+
**Type:** Boolean
515+
516+
**Default:** `false`
517+
518+
**Description:** When Karma is watching the files for changes, it will delay a new run until
519+
the current run is finished. Enabling this setting will cancel the current run and start a new run
520+
immediately when a change is detected.
521+
522+
523+
## retryLimit
524+
**Type:** Number
525+
526+
**Default:** 2
527+
528+
**Description:** When a browser crashes, karma will try to relaunch. This defines how many times karma should relaunch
529+
a browser before giving up.
530+
461531
## singleRun
462532
**Type:** Boolean
463533

@@ -470,22 +540,6 @@ Note: Just about all additional reporters in Karma (other than progress) require
470540
If `true`, Karma will start and capture all configured browsers, run tests and then exit with an exit code of `0` or `1` depending
471541
on whether all tests passed or any tests failed.
472542

473-
## mime
474-
**Type:** Object
475-
476-
**Default:** `{}`
477-
478-
**Description:** Redefine default mapping from file extensions to MIME-type
479-
480-
Set property name to required MIME, provide Array of extensions (without dots) as it's value
481-
482-
**Example:**
483-
```javascript
484-
mime: {
485-
'text/x-typescript': ['ts','tsx']
486-
'text/plain' : ['mytxt']
487-
}
488-
```
489543

490544

491545
## transports
@@ -497,32 +551,6 @@ mime: {
497551
is handed off to [socket.io](http://socket.io/) (which manages the communication
498552
between browsers and the testing server).
499553

500-
## client.useIframe
501-
**Type:** Boolean
502-
503-
**Default:** `true`
504-
505-
**Description:** Run the tests inside an iFrame or a new window
506-
507-
If true, Karma runs the tests inside an iFrame. If false, Karma runs the tests in a new window. Some tests may not run in an
508-
iFrame and may need a new window to run.
509-
510-
## client.captureConsole
511-
**Type:** Boolean
512-
513-
**Default:** `true`
514-
515-
**Description:** Capture all console output and pipe it to the terminal.
516-
517-
## client.clearContext
518-
**Type:** Boolean
519-
520-
**Default:** `true`
521-
522-
**Description:** Clear the context window
523-
524-
If true, Karma clears the context window upon the completion of running the tests. If false, Karma does not clear the context window
525-
upon the completion of running the tests. Setting this to false is useful when embedding a Jasmine Spec Runner Template.
526554

527555
## urlRoot
528556
**Type:** String
@@ -534,14 +562,6 @@ upon the completion of running the tests. Setting this to false is useful when
534562
All of Karma's urls get prefixed with the `urlRoot`. This is helpful when using proxies, as
535563
sometimes you might want to proxy a url that is already taken by Karma.
536564

537-
## concurrency
538-
**Type:** Number
539-
540-
**Default:** `Infinity`
541-
542-
**Description:** How many browser Karma launches in parallel.
543-
544-
Especially on sevices like SauceLabs and Browserstack it makes sense to only launch a limited amount of browsers at once, and only start more when those have finished. Using this configuration you can sepcify how many browsers should be running at once at any given point in time.
545565

546566
[plugins]: plugins.html
547567
[config/files]: files.html

lib/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ var Config = function () {
265265
this.browserNoActivityTimeout = 10000
266266
this.concurrency = Infinity
267267
this.failOnEmptyTestSuite = true
268+
this.retryLimit = 2
268269
}
269270

270271
var CONFIG_SYNTAX_HELP = ' module.exports = function(config) {\n' +

lib/launchers/retry.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ var RetryLauncher = function (retryLimit) {
2323
})
2424
}
2525

26-
RetryLauncher.decoratorFactory = function () {
26+
RetryLauncher.decoratorFactory = function (retryLimit) {
2727
return function (launcher) {
28-
RetryLauncher.call(launcher, 2)
28+
RetryLauncher.call(launcher, retryLimit)
2929
}
3030
}
3131

32+
RetryLauncher.decoratorFactory.$inject = ['config.retryLimit']
33+
3234
module.exports = RetryLauncher

0 commit comments

Comments
 (0)