Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: test/run.js

Issue 29866577: Issue 6887 - add Chrome to "npm test" (Closed)
Patch Set: Created Aug. 27, 2018, 3:09 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« test/browser/firefox.js ('K') | « test/firefox.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
Sebastian Noack 2018/08/27 19:56:16 FWIW, I think all.js is a slightly better name for
tlucas 2018/08/28 08:18:14 Done.
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH
4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 /* eslint-env mocha */
19
20 "use strict";
21
22 const glob = require("glob");
23 const path = require("path");
24 const {exec} = require("child_process");
25
26 let testFiles = glob.sync("./test/cases/*.js");
Sebastian Noack 2018/08/27 19:56:16 Nit: IMO, the code reads better if we inline this
tlucas 2018/08/28 08:18:14 Done.
27
28 for (let browser of glob.sync("./test/browser/*.js"))
29 {
30 let module = require(path.resolve(browser));
Sebastian Noack 2018/08/27 19:56:16 Is path.resolve() necessary here?
tlucas 2018/08/28 08:18:14 Well, "./test/browsers/firefox.js" can't be implic
Sebastian Noack 2018/08/28 14:44:57 Right, require() expects a path, relative to the c
31 let buildCommand = `python build.py devenv -t ${module.platform}`;
Sebastian Noack 2018/08/27 19:56:16 Nit: Since this variable is only used once, inline
tlucas 2018/08/28 08:18:14 Done.
32
33
34 describe(module.platform, function()
35 {
36 this.timeout(0);
37
38 let driver;
39 let origin;
40
41 let buildDevenv = new Promise((resolve, reject) =>
Sebastian Noack 2018/08/27 19:56:16 This should happen within before().
tlucas 2018/08/28 08:18:14 Moved it. To clarify, fmi - doesn't the line below
Sebastian Noack 2018/08/28 14:44:58 Nope. This is not a function (that is called). You
42 {
43 exec(buildCommand, (error, stdout, stderr) =>
44 {
45 if (error) reject(stderr);
Sebastian Noack 2018/08/27 19:56:15 In case of an error, we might rather want to forwa
tlucas 2018/08/28 08:18:14 Done.
46 else resolve(stdout);
47 });
48 });
49
50 before(() => buildDevenv.then(() =>
51 module.getDriver().then(d =>
52 {
53 driver = d;
54 return driver.wait(() =>
55 driver.getAllWindowHandles().then(handles => handles[1])
56 );
57 }).then(handle =>
58 driver.switchTo().window(handle)
59 ).then(() =>
60 driver.executeScript("return location.origin;")
61 ).then(o =>
62 {
63 origin = o;
64 })
65 ));
66
67 for (let file of testFiles)
68 {
69 let testModule = require(path.resolve(file));
70
71 it(testModule.title, () =>
Sebastian Noack 2018/08/27 19:56:15 I wonder, would it work if we call it() on the top
tlucas 2018/08/28 08:18:14 In theory yes - How would you pass "driver" and "o
Sebastian Noack 2018/08/28 14:44:58 From looking at other examples using Mocha, it see
tlucas 2018/08/29 09:16:53 Thanks for clarifying. But i don't see, how we'd c
Sebastian Noack 2018/08/29 15:22:12 Well, it would be less code here, less boilerplate
tlucas 2018/09/01 09:38:30 This actually works pretty nicely. After finding o
72 {
73 return testModule.it(driver, origin);
74 });
75 }
76
77 after(() => driver.quit());
78 });
79 }
OLDNEW
« test/browser/firefox.js ('K') | « test/firefox.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld