Skip to content

Commit b4ca00e

Browse files
author
paulsouche
committed
end to end tests
1 parent 17a752a commit b4ca00e

File tree

9 files changed

+341
-132
lines changed

9 files changed

+341
-132
lines changed

.jshintrc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@
1010
"strict" : true,
1111
"trailing" : true,
1212
"globals": {
13+
"exports": false,
1314
"require": false,
1415
"define": false,
1516
"window": false,
1617
"jasmine": false,
17-
"describe":false,
18-
"it":false,
19-
"expect":false,
20-
"module":false
18+
"describe": false,
19+
"it": false,
20+
"expect": false,
21+
"module": false,
22+
"waitsFor": false,
23+
"runs": false
2124
}
2225
}

Gruntfile.js

Lines changed: 124 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,140 @@
11
module.exports = function(grunt) {
2-
'use strict';
2+
'use strict';
33

4-
require('load-grunt-tasks')(grunt);
4+
require('load-grunt-tasks')(grunt);
55

6-
grunt.initConfig({
7-
assetsDir: 'app',
8-
distDir: 'dist',
9-
testsDir: 'test',
10-
availabletasks: {
11-
tasks: {
12-
options: {
13-
filter: 'include',
14-
groups: {
15-
'Development': ['dev', 'test:unit', 'test:e2e']
16-
},
17-
sort: ['dev', 'test:unit', 'test:e2e'],
18-
descriptions: {
19-
'dev' : 'Launch the static server and watch tasks',
20-
'test:unit' : 'Run unit tests and show coverage report',
21-
'test:e2e' : 'Run end-to-end tests using webdriverJS'
22-
},
23-
tasks: ['dev', 'test:unit', 'test:e2e']
24-
}
25-
}
6+
grunt.initConfig({
7+
assetsDir: 'app',
8+
distDir: 'dist',
9+
testsDir: 'test',
10+
availabletasks: {
11+
tasks: {
12+
options: {
13+
filter: 'include',
14+
groups: {
15+
'Development': ['dev', 'test:unit', 'test:e2e']
16+
},
17+
sort: ['dev', 'test:unit', 'test:e2e'],
18+
descriptions: {
19+
'dev' : 'Launch the static server and watch tasks',
20+
'test:unit' : 'Run unit tests and show coverage report',
21+
'test:e2e' : 'Run end-to-end tests using webdriverJS & jasmine_node'
22+
},
23+
tasks: ['dev', 'test:unit', 'test:e2e']
24+
}
25+
}
26+
},
27+
browserSync: {
28+
dev: {
29+
bsFiles: {
30+
src : []
31+
},
32+
options: {
33+
watchTask: true,
34+
ghostMode: {
35+
clicks: true,
36+
scroll: true,
37+
links: false,
38+
forms: false
39+
},
40+
server: {
41+
baseDir: "<%= assetsDir %>"
42+
}
43+
}
44+
}
45+
},
46+
connect: {
47+
test : {
48+
options: {
49+
port: 8887,
50+
base: '<%= assetsDir %>',
51+
keepalive: false,
52+
livereload: false,
53+
open: false
54+
}
55+
}
56+
},
57+
csslint: {
58+
options: {
59+
csslintrc: '.csslintrc'
2660
},
27-
browserSync: {
28-
dev: {
29-
bsFiles: {
30-
src : []
31-
},
32-
options: {
33-
watchTask: true,
34-
ghostMode: {
35-
clicks: true,
36-
scroll: true,
37-
links: false,
38-
forms: false
39-
},
40-
server: {
41-
baseDir: "<%= assetsDir %>"
42-
}
43-
}
44-
}
61+
all: {
62+
src: ['<%= assets_dir %>/css/*.css']
63+
}
64+
},
65+
jasmine_node: {
66+
options: {
67+
forceExit: true,
68+
match: '.',
69+
matchall: false,
70+
extensions: 'js',
71+
specNameMatcher: 'Spec'
4572
},
46-
csslint: {
47-
options: {
48-
csslintrc: '.csslintrc'
49-
},
50-
all: {
51-
src: ['<%= assets_dir %>/css/*.css']
52-
}
73+
all: ['test/e2e']
74+
},
75+
jshint: {
76+
options: {
77+
jshintrc: '.jshintrc'
5378
},
54-
jasmine_node: {
55-
options: {
56-
forceExit: true,
57-
match: '.',
58-
matchall: false,
59-
extensions: 'js',
60-
specNameMatcher: 'spec'
61-
},
62-
all: ['test/e2e/']
79+
all : {
80+
src : [
81+
'<%= assetsDir %>/js/*.js','<%= testsDir %>/**/*.js'
82+
]
83+
}
84+
},
85+
karma: {
86+
dev_unit: {
87+
options: {
88+
configFile: 'test/unit/conf/unit-test-conf.js',
89+
background: true,
90+
singleRun: false,
91+
autoWatch: true,
92+
reporters: ['progress']
93+
}
6394
},
64-
jshint: {
65-
options: {
66-
jshintrc: '.jshintrc'
67-
},
68-
all : {
69-
src : [
70-
'<%= assetsDir %>/js/*.js','<%= testsDir %>/**/*.js'
71-
]
72-
}
95+
dist_unit: {
96+
options: {
97+
configFile: 'test/unit/conf/unit-test-conf.js',
98+
background: false,
99+
singleRun: true,
100+
autoWatch: false,
101+
reporters: ['progress', 'coverage'],
102+
coverageReporter : {
103+
type : 'html',
104+
dir : 'reports/coverage'
105+
}
106+
}
107+
}
108+
},
109+
watch: {
110+
options : {
111+
interrupt: true
73112
},
74-
karma: {
75-
dev_unit: {
76-
options: {
77-
configFile: 'test/unit/conf/unit-test-conf.js',
78-
background: true,
79-
singleRun: false,
80-
autoWatch: true,
81-
reporters: ['progress']
82-
}
83-
},
84-
dist_unit: {
85-
options: {
86-
configFile: 'test/unit/conf/unit-test-conf.js',
87-
background: false,
88-
singleRun: true,
89-
autoWatch: false,
90-
reporters: ['progress', 'coverage'],
91-
coverageReporter : {
92-
type : 'html',
93-
dir : 'reports/coverage'
94-
}
95-
}
96-
}
113+
js: {
114+
files: ['<%= assetsDir %>/**/*.js','<%= testsDir %>/**/*.js'],
115+
tasks: ['newer:jshint','karma:dev_unit:run']
97116
},
98-
watch: {
99-
options : {
100-
interrupt: true
101-
},
102-
js: {
103-
files: ['<%= assetsDir %>/**/*.js','<%= testsDir %>/**/*.js'],
104-
tasks: ['newer:jshint','karma:dev_unit:run']
105-
},
106-
css: {
107-
files: ['<%= assetsDir %>/scss/**/*.scss'],
108-
tasks: ['newer:sass']
109-
}
117+
css: {
118+
files: ['<%= assetsDir %>/scss/**/*.scss'],
119+
tasks: ['newer:sass']
110120
}
111-
});
112-
113-
grunt.registerTask('dev', [
114-
'browserSync',
115-
'karma:dev_unit:start',
116-
'watch'
117-
]);
121+
}
122+
});
118123

119-
grunt.registerTask('test:unit', [
120-
'karma:dist_unit:start'
121-
]);
124+
grunt.registerTask('dev', [
125+
'browserSync',
126+
'karma:dev_unit:start',
127+
'watch'
128+
]);
122129

123-
grunt.registerTask('test:e2e', [
130+
grunt.registerTask('test:unit', [
131+
'karma:dist_unit:start'
132+
]);
124133

125-
]);
134+
grunt.registerTask('test:e2e', [
135+
'jasmine_node'
136+
]);
126137

127-
grunt.registerTask('ls', ['availabletasks']);
138+
grunt.registerTask('ls', ['availabletasks']);
128139

129140
};

package.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,29 @@
2727
"homepage": "https://github.com/paulsouche/devFactory-jquery-requirejs",
2828
"devDependencies": {
2929
"grunt": "^0.4.5",
30-
"load-grunt-tasks": "^0.6.0",
31-
"grunt-contrib-jshint": "^0.10.0",
30+
"grunt-available-tasks": "^0.5.0",
31+
"grunt-browser-sync": "^1.1.2",
3232
"grunt-contrib-clean": "^0.5.0",
3333
"grunt-contrib-concat": "^0.4.0",
34-
"grunt-contrib-uglify": "^0.5.0",
35-
"grunt-contrib-cssmin": "^0.10.0",
34+
"grunt-contrib-connect": "^0.8.0",
35+
"grunt-contrib-copy": "^0.5.0",
3636
"grunt-contrib-csslint": "^0.2.0",
37+
"grunt-contrib-cssmin": "^0.10.0",
38+
"grunt-contrib-jshint": "^0.10.0",
39+
"grunt-contrib-uglify": "^0.5.0",
3740
"grunt-contrib-watch": "^0.6.1",
38-
"grunt-contrib-copy": "^0.5.0",
39-
"grunt-contrib-connect": "^0.8.0",
41+
"grunt-karma": "^0.8.3",
4042
"grunt-newer": "^0.7.0",
41-
"grunt-browser-sync": "^1.1.2",
43+
"grunt-jasmine-node": "^0.2.1",
4244
"karma": "^0.12.16",
43-
"grunt-karma": "^0.8.3",
44-
"karma-firefox-launcher": "^0.1.3",
4545
"karma-chrome-launcher": "^0.1.4",
46+
"karma-coverage": "^0.2.4",
47+
"karma-firefox-launcher": "^0.1.3",
4648
"karma-jasmine": "^0.1.5",
4749
"karma-phantomjs-launcher": "^0.1.4",
48-
"karma-coverage": "^0.2.4",
49-
"requirejs": "^2.1.14",
5050
"karma-requirejs": "^0.2.2",
51-
"grunt-available-tasks": "^0.5.0",
51+
"load-grunt-tasks": "^0.6.0",
52+
"requirejs": "^2.1.14",
5253
"webdriverjs": "^1.7.2"
5354
}
5455
}

test/e2e/mainSpec.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1-
/**
2-
* Created by sfeir on 31/07/14.
3-
*/
1+
/*jslint node: true */
2+
'use strict';
3+
4+
var webdriverjs = require('webdriverjs'),
5+
specs = require('./scenarios/scenarios'),
6+
root = 'http://localhost:3000';
7+
8+
var client = webdriverjs.remote({
9+
host: 'localhost',
10+
port: 4444,
11+
desiredCapabilities: {
12+
browserName: 'chrome'
13+
}
14+
});
15+
16+
jasmine.getEnv().defaultTimeoutInterval = 10000;
17+
client.init();
18+
specs.runScenarios(client,root);
19+
client.end();

0 commit comments

Comments
 (0)