OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview A mocha adapter for BrowserTests. To use, include mocha.js and | 6 * @fileoverview A mocha adapter for BrowserTests. To use, include mocha.js and |
7 * mocha_adapter.js in a WebUIBrowserTest's extraLibraries array. | 7 * mocha_adapter.js in a WebUIBrowserTest's extraLibraries array. |
8 */ | 8 */ |
9 | 9 |
10 // NOTE: When defining TEST_F() functions that use Mocha, use 'var self = this' | |
11 // for referencing the Test object within suite() and test() function objects | |
12 // (instead of binding |this|), since |this| within those objects will reference | |
13 // the Mocha Suite or Test instance. | |
Dan Beam
2015/12/28 20:01:39
this is probably more a general understanding of |
michaelpg
2015/12/28 20:39:35
Yes, the test cases are call'd or apply'd on a par
stevenjb
2015/12/28 20:49:16
There has been some confusion and discussion about
| |
14 | |
10 /** | 15 /** |
11 * Initializes a mocha reporter for the BrowserTest framework, which registers | 16 * Initializes a mocha reporter for the BrowserTest framework, which registers |
12 * event listeners on the given Runner. | 17 * event listeners on the given Runner. |
13 * @constructor | 18 * @constructor |
14 * @param {Runner} runner Runs the tests and provides hooks for test results | 19 * @param {Runner} runner Runs the tests and provides hooks for test results |
15 * (see Runner.prototype in mocha.js). | 20 * (see Runner.prototype in mocha.js). |
16 */ | 21 */ |
17 function BrowserTestReporter(runner) { | 22 function BrowserTestReporter(runner) { |
18 var passes = 0; | 23 var passes = 0; |
19 var failures = 0; | 24 var failures = 0; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 mocha.setup({ | 62 mocha.setup({ |
58 // Use TDD interface instead of BDD. | 63 // Use TDD interface instead of BDD. |
59 ui: 'tdd', | 64 ui: 'tdd', |
60 // Use custom reporter to interface with BrowserTests. | 65 // Use custom reporter to interface with BrowserTests. |
61 reporter: BrowserTestReporter, | 66 reporter: BrowserTestReporter, |
62 // Mocha timeouts are set to 2 seconds initially. This isn't nearly enough for | 67 // Mocha timeouts are set to 2 seconds initially. This isn't nearly enough for |
63 // slower bots (e.g., Dr. Memory). Disable timeouts globally, because the C++ | 68 // slower bots (e.g., Dr. Memory). Disable timeouts globally, because the C++ |
64 // will handle it (and has scaled timeouts for slower bots). | 69 // will handle it (and has scaled timeouts for slower bots). |
65 enableTimeouts: false, | 70 enableTimeouts: false, |
66 }); | 71 }); |
OLD | NEW |