Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit f4916ad

Browse files
committed
test(ngHint): fix configs for testing
1 parent e7bab91 commit f4916ad

File tree

4 files changed

+50
-18
lines changed

4 files changed

+50
-18
lines changed

conf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
exports.config = {
2-
seleniumAddress: 'http://localhost:4444/wd/hub',
2+
seleniumServerJar: './node_modules/protractor/selenium/selenium-server-standalone-2.42.2.jar',
33

44
capabilities: {
55
'browserName': 'chrome'
@@ -10,4 +10,4 @@ exports.config = {
1010
jasmineNodeOpts: {
1111
showColors: true
1212
}
13-
};
13+
};

gulpfile.js

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,52 @@
11
var gulp = require('gulp');
22
var source = require('vinyl-source-stream');
33
var browserify = require('browserify');
4+
var exec = require('child_process').exec;
5+
var http = require('http');
6+
var st = require('st');
7+
var Router = require('routes-router');
48

59
var main = require('./package.json').main;
610

7-
gulp.task('watch', function(){
8-
gulp.watch(['./**/*.js', '!./dist/*.js'], ['browserify']);
11+
gulp.task('watch', function() {
12+
gulp.watch(['./*.js'], ['browserify']);
913
});
1014

1115
gulp.task('browserify', function() {
1216
var bundleStream = browserify('./' + main).bundle().pipe(source(main));
1317
return bundleStream.pipe(gulp.dest('./dist'));
1418
});
1519

16-
gulp.task('default', ['browserify']);
20+
21+
gulp.task('serve', startServer);
22+
23+
function startServer() {
24+
var app = Router();
25+
app.addRoute('/*', st({
26+
path: __dirname + '/',
27+
url: '/',
28+
index: 'index.html'
29+
}));
30+
server = http.createServer(app);
31+
server.listen(8080);
32+
return server;
33+
}
34+
35+
gulp.task('protractor', ['webdriver'], function (cb) {
36+
var server = startServer();
37+
exec('./node_modules/.bin/protractor conf.js', function (err, stdout, stderr) {
38+
server.close();
39+
if (err) {
40+
console.log(stdout, stderr);
41+
}
42+
cb(err);
43+
});
44+
});
45+
46+
gulp.task('webdriver', function (cb) {
47+
exec('./node_modules/.bin/webdriver-manager update', cb);
48+
});
49+
50+
gulp.task('test', ['webdriver', 'protractor']);
51+
gulp.task('build', ['browserify']);
52+
gulp.task('default', ['build', 'test']);

hint_test.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,24 @@ describe('angularHint', function() {
1818
// });
1919

2020
it('should have an inclusive mode', function() {
21-
browser.get('http://localhost:8080/e2e/inclusiveHint');
22-
ptor.sleep(5000);
21+
browser.get('http://localhost:8080/e2e/inclusiveHint/');
2322
expect(element(by.id('title')).getText()).toBe('Inclusive Hint Example');
2423
expect(element(by.id('console')).getText()).toContain('Angular best practices are to manipulate the DOM in the view.');
2524
expect(element(by.id('console')).getText()).not.toContain('Directive');
2625
});
2726

2827
it('should have an exclusive mode', function() {
29-
browser.get('http://localhost:8080/e2e/exclusiveHint');
30-
ptor.sleep(5000);
28+
browser.get('http://localhost:8080/e2e/exclusiveHint/');
3129
expect(element(by.id('title')).getText()).toBe('Exclusive Hint Example');
3230
expect(element(by.id('console')).getText()).not.toContain('Angular best practices are to manipulate the DOM in the view.');
3331
expect(element(by.id('console')).getText()).toContain('Directive');
3432
});
3533

3634
it('should not add modules if ng-hint is not included', function() {
37-
browser.get('http://localhost:8080/e2e/noHint');
38-
ptor.sleep(5000);
35+
browser.get('http://localhost:8080/e2e/noHint/');
3936
expect(element(by.id('title')).getText()).toBe('No Hint Example');
4037
expect(element(by.id('console')).getText()).not.toContain('Angular best practices are to manipulate the DOM in the view.');
4138
expect(element(by.id('console')).getText()).not.toContain('Directives');
4239
});
4340
});
44-
});
41+
});

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,16 @@
2525
},
2626
"homepage": "https://github.com/angular/angular-hint",
2727
"dependencies": {
28-
"browserify": "^4.2.0",
2928
"controller-training": "git://github.com/angular/angular-hint-dom",
30-
"directive-director": "git://github.com/angular/angular-hint-directives",
31-
"gulp": "^3.8.5",
32-
"karma": "^0.12.16",
33-
"karma-chrome-launcher": "^0.1.4",
34-
"karma-jasmine": "^0.1.5"
29+
"directive-director": "git://github.com/angular/angular-hint-directives"
3530
},
3631
"devDependencies": {
3732
"browserify": "^4.2.0",
3833
"gulp": "^3.8.5",
34+
"http-server": "^0.6.1",
35+
"protractor": "^1.0.0-rc4",
36+
"routes-router": "^3.3.0",
37+
"st": "^0.5.1",
3938
"vinyl-source-stream": "^0.1.1"
4039
}
4140
}

0 commit comments

Comments
 (0)