Skip to content

Commit 2376abf

Browse files
author
Brad Berger
committed
Runs tests for all JavaScript changes
1 parent d8d155c commit 2376abf

File tree

5 files changed

+64
-10
lines changed

5 files changed

+64
-10
lines changed

README.md

+27
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,33 @@ angular.module("materialExample").controller("calendarCtrl", function($scope, $f
106106
</scr
107107
```
108108

109+
## Hacking On It
110+
111+
Use gulp to spin up the server and re-compile resources on the fly. The
112+
gulp `default` task does all that for you. Just make sure to Selenium is
113+
up and running:
114+
115+
```bash
116+
# In one terminal
117+
webdriver-manager start
118+
```
119+
120+
```bash
121+
# In separate terminal
122+
gulp
123+
```
124+
125+
Protractor is set up to run all the tests during development. To make it a bit
126+
faster development tests run using PhantomJS, while CI tests run with real
127+
browsers. JavaScript code is linted with `eslint`, too, so make sure that's
128+
not complaining about code styling or other issues.
129+
130+
The CI test is `test-ci` while the standard tests run all the time while
131+
developing.
132+
133+
If you're having trouble with PhantomJS we can easily just switch to Chrome
134+
instead.
135+
109136
## To Do
110137

111138
- Unit tests (the basic setup is there, need to fill them out)

gulpfile.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ gulp.task("html", function() {
4141
});
4242

4343
gulp.task("js:lint", function() {
44+
return gulp
45+
.src(p("src/angular-material-calendar.js"))
46+
.pipe(eslint())
47+
.pipe(eslint.format());
48+
});
49+
50+
gulp.task("js:lint-ci", function() {
4451
return gulp
4552
.src(p("src/angular-material-calendar.js"))
4653
.pipe(eslint())
@@ -58,15 +65,21 @@ gulp.task("scss", function() {
5865
.pipe(connect.reload());
5966
});
6067

61-
gulp.task("test", ["js:lint"], function() {
68+
gulp.task("test-ci", ["js:lint-ci"], function() {
6269
connect.server({ root: "website", port: 3000 });
6370
gulp
6471
.src(["./tests/*.spec.js"])
65-
.pipe(protractor({ configFile: p("protractor.conf.js") }))
72+
.pipe(protractor({ configFile: p("protractor-ci.conf.js") }))
6673
.on("error", function(e) { throw e; })
6774
.on("end", connect.serverClose);
6875
});
6976

77+
gulp.task("test", ["js:lint"], function() {
78+
gulp
79+
.src(["./tests/*.spec.js"])
80+
.pipe(protractor({ configFile: p("protractor.conf.js") }));
81+
});
82+
7083
gulp.task("build", function() {
7184
return runSequence(["scss"], "html", "js");
7285
});
@@ -76,7 +89,7 @@ gulp.task("connect", function() {
7689
});
7790

7891
gulp.task("watch", function() {
79-
gulp.watch(p("src/**/*"), ["build"]);
92+
gulp.watch(p("src/**/*"), ["test", "build"]);
8093
});
8194

8295
gulp.task("default", ["build", "connect", "watch"]);

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "A calendar directive for AngularJS and Angular Material Design",
55
"main": "gulpfile.js",
66
"scripts": {
7-
"test": "./node_modules/protractor/bin/webdriver-manager update && gulp test"
7+
"test": "./node_modules/protractor/bin/webdriver-manager update && gulp test-ci"
88
},
99
"repository": {
1010
"type": "git",
@@ -31,6 +31,7 @@
3131
"gulp-size": "^2.0.0",
3232
"gulp-uglify": "^1.2.0",
3333
"node-sass": "^3.3.2",
34+
"phantomjs": "^1.9.18",
3435
"protractor": "^2.2.0",
3536
"replacestream": "^4.0.0",
3637
"run-sequence": "^1.1.2"

protractor-ci.conf.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* eslint-env node */
2+
exports.config = {
3+
specs: [ "test/**/*.spec.js" ],
4+
seleniumServerJar: "./node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar",
5+
multiCapabilities: [
6+
{"browserName": "chrome"},
7+
{"browserName": "firefox"}
8+
],
9+
baseUrl: "http://localhost:3000/index.html",
10+
jasmineNodeOpts: {
11+
showColors: true
12+
}
13+
};

protractor.conf.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/* eslint-env node */
22
exports.config = {
33
specs: [ "test/**/*.spec.js" ],
4-
seleniumServerJar: "./node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar",
5-
// seleniumAddress: "http://localhost:4444/wd/hub",
6-
multiCapabilities: [
7-
{"browserName": "chrome"},
8-
{"browserName": "firefox"}
9-
],
4+
seleniumAddress: "http://localhost:4444/wd/hub",
105
baseUrl: "http://localhost:3000/index.html",
6+
capabilities: {
7+
browserName: "phantomjs",
8+
version: "",
9+
platform: "ANY"
10+
},
1111
jasmineNodeOpts: {
1212
showColors: true
1313
}

0 commit comments

Comments
 (0)