Skip to content

Commit a56f54c

Browse files
committed
tests: switch from phantom to puppeteer
1 parent 5d152a1 commit a56f54c

File tree

13 files changed

+58
-272
lines changed

13 files changed

+58
-272
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ cache:
1010
before_install:
1111
- yes y | sudo lein upgrade
1212
- curl -sSL https://raw.githubusercontent.com/cljs-oss/canary/master/scripts/install-canary.sh | bash
13+
- cd test; npm install

project.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@
163163
"compare-dead-code-with-pseudo-names" ["shell" "scripts/compare-dead-code.sh" "+testing,+dce-pseudo-names"]
164164
"test-tests" ["do"
165165
["with-profile" "+testing" "cljsbuild" "once" "tests"]
166-
["shell" "phantomjs" "test/resources/phantom.js" "test/resources/run-tests.html"]]
166+
["shell" "node" "test/resources/puppeteer.js" "test/resources" "run-tests.html"]]
167167
"test-tests-with-config" ["do"
168168
["shell" "scripts/compile-tests-with-config.sh"]
169-
["shell" "phantomjs" "test/resources/phantom.js" "test/resources/run-tests-with-config.html"]]
169+
["shell" "node" "test/resources/puppeteer.js" "test/resources" "run-tests-with-config.html"]]
170170
"test-advanced-warning" ["do"
171171
["with-profile" "+testing" "cljsbuild" "once" "advanced-warning"]
172-
["shell" "phantomjs" "test/resources/phantom.js" "test/resources/run-advanced-warning.html"]]
172+
["shell" "node" "test/resources/puppeteer.js" "test/resources" "run-advanced-warning.html"]]
173173
"release" ["shell" "scripts/release.sh"]})

src/lib/devtools/munging.cljs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@
138138
(defn trivial-fn-source? [fn-source]
139139
{:pre [(string? fn-source)]}
140140
(or (some? (re-matches #"function\s*\(\s*\)\s*\{\s*\}\s*" fn-source))
141-
(some? (re-matches #"function.*\(\)\s*\{\s*\[native code\]\s*\}\s*" fn-source))))
141+
(some? (re-matches #"function.*\(\)\s*\{\s*\[native code\]\s*\}\s*" fn-source))
142+
(some? (re-matches #"function anonymous\(\s*\)\s*\{\s*\}" fn-source))))
142143

143144
(defn cljs-fn?
144145
"Given a Javascript function object returns true if the function looks like a ClojureScript function.

test/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
yarn.lock

test/package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "cljs-devtools-tests",
3+
"version": "1.0.0",
4+
"license": "MIT",
5+
"private": true,
6+
"devDependencies": {
7+
"puppeteer": "^2.1.0",
8+
"http-server": "^0.12.1"
9+
},
10+
"dependencies": {
11+
}
12+
}

test/resources/js/promise-polyfill.js

Lines changed: 0 additions & 234 deletions
This file was deleted.

test/resources/phantom.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

test/resources/puppeteer.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const puppeteer = require('puppeteer');
2+
3+
const path = process.argv[2];
4+
const page = process.argv[3];
5+
6+
const httpServer = require('http-server');
7+
8+
const host = '127.0.0.1';
9+
const port = 3000;
10+
11+
const url = `http://${host}:${port}/${page}`;
12+
13+
const serverOptions = {root: path};
14+
15+
const server = httpServer.createServer(serverOptions);
16+
17+
server.listen(port, host, function () {
18+
console.log(`Server running at http://${host}:${port}/`);
19+
20+
(async () => {
21+
const browser = await puppeteer.launch();
22+
const page = await browser.newPage();
23+
page.on('console', msg => console.log(msg.text()));
24+
console.log("navigating to: ", url);
25+
await page.goto(url);
26+
27+
const failures = await page.evaluate(() => {
28+
return window["test-failures"];
29+
});
30+
31+
await browser.close();
32+
33+
process.exit(failures ? 100 : 0);
34+
})();
35+
36+
});

test/resources/run-advanced-warning.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
This file could be changed to include HTML for the tests to use
55
during their operation.
66
<script src="js/diff_match_patch.js" type="text/javascript"></script>
7-
<script src="js/promise-polyfill.js" type="text/javascript"></script>
87
<script>
98
// poor man's console listener
109
var lastWarning = null;

test/resources/run-tests-adhoc.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
This file could be changed to include HTML for the tests to use
55
during their operation.
66
<script src="js/diff_match_patch.js" type="text/javascript"></script>
7-
<script src="js/promise-polyfill.js" type="text/javascript"></script>
87
<script src=".compiled/tests/build.js" type="text/javascript"></script>
98
<script>
109
window.selectedTestSuite = "adhoc-tests";

0 commit comments

Comments
 (0)