Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: chrome/test/data/webui/mocha_adapter.js

Issue 1124873002: Mocha adapter for Polymer browser tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split out non-mocha stuff Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview A mocha adapter for browser tests.
7 *
8 * Mocha requires a browser (or node), so mocha and this adapter should be
9 * included as part of the WebUI (i.e., as opposed to using GEN_INCLUDE).
10 */
11
12 /**
13 * Initialize a reporter for the browser test framework.
14 * @param {Runner} runner
15 */
16 function BrowserTestReporter(runner) {
17 var passes = 0;
18 var failures = 0;
19
20 // Increment passes for each passed test.
21 runner.on('pass', function(test) {
22 passes++;
23 });
24
25 // Report failures. Mocha only catches "assert" failures, because "expect"
26 // failures are caught by test_api.js.
27 runner.on('fail', function(test, err) {
28 failures++;
29 console.error('Test failed: ' + test.fullTitle());
30 // The error message given by test_api.js includes relevant details like
31 // actual and expected values. The stack trace of the error isn't useful.
32 console.error(err.message);
33 });
34
35 // Report the results to the browser test API.
36 runner.on('end', function() {
37 if (failures == 0)
38 testDone();
39 testDone([
michaelpg 2015/05/05 16:46:33 should be "else {... }"
40 false,
41 'Test Errors: ' + failures + '/' + (passes + failures) + ' tests failed'
42 ]);
43 });
44 }
45
46 // Configure Mocha.
47 mocha.setup({
48 // Use "tdd" interface instead of "bdd".
49 ui: 'tdd',
50 // Use custom reporter to interface with browser test.
51 reporter: BrowserTestReporter,
52 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698