Skip to content

Commit 3e20b0a

Browse files
Kurdi SzabolcsKurdi Szabolcs
authored andcommitted
chore(e2e): e2e exposed
1 parent 68f8565 commit 3e20b0a

6 files changed

Lines changed: 87 additions & 0 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,8 @@ Promise.all([
3838
[Issue is here](https://github.com/nathanboktae/mocha-phantomjs/issues/248)
3939
* either wait for the upstream package to be updated
4040
* or update the binary manually
41+
42+
## exposed test
43+
44+
Temporarily the e2e standalone test page has been exposed to [docs](./docs) and is made
45+
available as a github page. TODO: browserstack?

docs/bar.png

2.33 KB
Loading

docs/baz.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#css-target { width: 20px; height: 20px; background-color: lime; border: 4px solid fuchsia; color: red; padding: 5px; }

docs/foo.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
window.foo = true;

docs/index.html

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<html>
2+
<head>
3+
<!-- https://mochajs.org/#running-mocha-in-the-browser -->
4+
<meta charset="utf-8">
5+
<title>Mocha Tests</title>
6+
<link href="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.css" rel="stylesheet" />
7+
<script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>
8+
<script src="https://cdn.rawgit.com/chaijs/chai/3.5.0/chai.js"></script>
9+
<script src="https://cdn.rawgit.com/cujojs/curl/0.8.13/dist/curl/curl.js"></script>
10+
<script src="https://cdn.rawgit.com/taylorhakes/promise-polyfill/6.0.2/promise.js"></script>
11+
</head>
12+
<body>
13+
<div id="mocha"></div>
14+
15+
<div id="css-target"></div>
16+
17+
<script type="text/javascript">
18+
curl.config({ baseUrl: "../lib" });
19+
curl(['basic-loader-amd'], function (load) {
20+
21+
mocha.ui('bdd');
22+
expect = chai.expect;
23+
24+
function getProp(elem, prop) {
25+
return window.getComputedStyle(elem, null).getPropertyValue(prop);
26+
}
27+
28+
describe('basic-loader', function () {
29+
30+
it('should load javascript files', function (done) {
31+
expect(window.foo).to.be.undefined;
32+
load.js('foo.js').then(function () {
33+
expect(window.foo).to.be.true;
34+
done();
35+
});
36+
});
37+
38+
it('should raise a promise error for non-existent javascript files', function (done) {
39+
load.js('foo-missing.js').catch(function () {
40+
done();
41+
});
42+
});
43+
44+
it('should load image files', function (done) {
45+
expect(document.getElementsByTagName('IMG').length).to.equal(0); // empty breaks phantom
46+
load.img('bar.png').then(function () {
47+
expect(document.getElementsByTagName('IMG')).to.have.length(1);
48+
done();
49+
});
50+
});
51+
52+
it('should raise a promise error for non-existent image files', function (done) {
53+
load.img('bar-missing.png').catch(function () {
54+
done();
55+
});
56+
});
57+
58+
it('should load css files', function (done) {
59+
var target = document.getElementById('css-target');
60+
expect(getProp(target, 'color')).to.equal('rgb(0, 0, 0)'); // phantom is terribly picky about props
61+
load.css('baz.css').then(function () {
62+
expect(getProp(target, 'color')).to.equal('rgb(255, 0, 0)');
63+
done();
64+
});
65+
});
66+
67+
it('should raise a promise error for non-existent css files', function (done) {
68+
load.img('baz-missing.css').catch(function () {
69+
done();
70+
});
71+
});
72+
73+
});
74+
75+
mocha.run();
76+
});
77+
</script>
78+
</body>
79+
</html>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"test:watch": "npm t -- --watch --reporter min",
1010
"e2e": "mocha-phantomjs ./e2e/test.html --ignore-ssl-errors=true --ssl-protocol=any",
1111
"build": "shx rm -rf lib && babel src --ignore spec.js -d lib && babel -o lib/basic-loader-amd.js --plugins transform-es2015-modules-amd src/basic-loader.js",
12+
"publish-test": "shx rm -rf docs && mkdir docs && shx cp -r e2e/* docs/ && shx mv docs/test.html docs/index.html",
1213
"precommit": "npm run lint",
1314
"prepush": "npm test && npm run e2e",
1415
"release": "npm run build && git status --porcelain && git checkout master && git pull origin master && standard-version && git push --follow-tags origin master && npm publish --access=public"

0 commit comments

Comments
 (0)