Skip to content

Commit 9da6c37

Browse files
committed
test(*): Fix e2e testing setup and one test case
* Point to app.scenarios.js under files in karma-e2e.conf.js * Set up a proxy to run e2e tests without any cross-domain issue * Register two tasks for test:unit and test:e2e to run them using grunt * Update README
1 parent bbf39ef commit 9da6c37

File tree

4 files changed

+36
-9
lines changed

4 files changed

+36
-9
lines changed

Gruntfile.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ module.exports = function (grunt) {
9999
]
100100
},
101101
karma: {
102+
e2e: {
103+
configFile: 'karma-e2e.conf.js',
104+
singleRun: true
105+
},
102106
unit: {
103107
configFile: 'karma.conf.js',
104108
singleRun: true
@@ -272,13 +276,22 @@ module.exports = function (grunt) {
272276
'open',
273277
'watch'
274278
]);
275-
276-
grunt.registerTask('test', [
279+
280+
grunt.registerTask('test:unit', [
277281
'clean:server',
278282
'coffee',
279283
'compass',
280284
'connect:test',
281-
'karma'
285+
'karma:unit'
286+
]);
287+
288+
grunt.registerTask('test:e2e', [
289+
'clean:server',
290+
'coffee',
291+
'compass',
292+
'livereload-start',
293+
'connect:livereload',
294+
'karma:e2e'
282295
]);
283296

284297
grunt.registerTask('build', [

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,19 @@ Because I wanted to write Testable Application in AngularJS.
1818
#Try?
1919
You need to have [prerequisite components](http://wp.me/paveF-h6) installed to run it. Finally just run:
2020

21+
###basic setup
2122
* $ cd eShell
2223
* $ sudo npm install
2324
* $ sudo bower install
25+
26+
### Fire up an app
2427
* $ grunt server
2528

29+
### Run unit tests
30+
* $ grunt test:unit
31+
32+
### Run e2e tests
33+
* $ grunt test:e2e
34+
2635
#Todo?
2736
Include more templates

karma-e2e.conf.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ basePath = '';
77
files = [
88
ANGULAR_SCENARIO,
99
ANGULAR_SCENARIO_ADAPTER,
10-
'test/e2e/**/*.js'
10+
'test/app.scenarios.js'
1111
];
1212

1313
// list of files to exclude
@@ -18,7 +18,7 @@ exclude = [];
1818
reporters = ['progress'];
1919

2020
// web server port
21-
port = 8080;
21+
port = 8000;
2222

2323
// cli runner port
2424
runnerPort = 9100;
@@ -28,10 +28,10 @@ colors = true;
2828

2929
// level of logging
3030
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
31-
logLevel = LOG_INFO;
31+
logLevel = LOG_DEBUG;
3232

3333
// enable / disable watching file and executing tests whenever any file changes
34-
autoWatch = false;
34+
autoWatch = true;
3535

3636
// Start these browsers, currently available:
3737
// - Chrome
@@ -49,3 +49,8 @@ captureTimeout = 5000;
4949
// Continuous Integration mode
5050
// if true, it capture browsers, run tests and exit
5151
singleRun = false;
52+
53+
proxies = {
54+
'/': 'http://localhost:9000/'
55+
};
56+
urlRoot = '/_e2e/';

test/app.scenarios.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
describe('text box scenario', function () {
22
beforeEach(function () {
3-
browser().navigateTo('http://localhost:9000');
3+
browser().navigateTo('/');
44
});
55
it('should disable submit/tryagain/showans buttons on page/template load', function () {
66
expect(element('button:contains("Submit")').attr('disabled')).toBe('disabled');
@@ -9,7 +9,7 @@ describe('text box scenario', function () {
99
});
1010

1111
it('should set attempt 1 of N', function () {
12-
expect(element('div[ng-controller="FooterCtrl"] div.pull-left:first > input').val()).toContain('Attempt 1 of');
12+
expect(element('div[ng-controller="FooterCtrl"] div.pull-left:first > button:eq(0)').html()).toContain('Attempt 1 of');
1313
});
1414

1515
it('should set template 1 of N', function () {

0 commit comments

Comments
 (0)