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

Commit 2240c11

Browse files
committed
chore(tests): implement e2e test harness outside of docs app
Included: - A sample test fixture - A sample test - Server middleware to serve the E2E harness - Convenient test helpers to simplify loading the right fixture Closes #9557 Closes #9527
1 parent fc56c9b commit 2240c11

File tree

16 files changed

+278
-1
lines changed

16 files changed

+278
-1
lines changed

Gruntfile.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var files = require('./angularFiles').files;
44
var util = require('./lib/grunt/utils.js');
55
var versionInfo = require('./lib/versions/version-info');
66
var path = require('path');
7+
var e2e = require('./test/e2e/tools');
78

89
module.exports = function(grunt) {
910
//grunt plugins
@@ -50,6 +51,7 @@ module.exports = function(grunt) {
5051
return [
5152
util.conditionalCsp(),
5253
util.rewrite(),
54+
e2e.middleware(),
5355
connect.favicon('images/favicon.ico'),
5456
connect.static(base),
5557
connect.directory(base)
@@ -76,6 +78,7 @@ module.exports = function(grunt) {
7678
next();
7779
},
7880
util.conditionalCsp(),
81+
e2e.middleware(),
7982
connect.favicon('images/favicon.ico'),
8083
connect.static(base)
8184
];

protractor-conf.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
var config = require('./protractor-shared-conf').config;
44

55
config.specs = [
6+
'test/e2e/tests/**/*.js',
67
'build/docs/ptore2e/**/*.js',
78
'docs/app/e2e/**/*.scenario.js'
89
];

protractor-jenkins-conf.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ exports.config = {
44
allScriptsTimeout: 11000,
55

66
specs: [
7+
'test/e2e/tests/**/*.js',
78
'build/docs/ptore2e/**/*.js',
89
'docs/app/e2e/*.scenario.js'
910
],
@@ -30,7 +31,7 @@ exports.config = {
3031

3132
require('jasmine-reporters');
3233
jasmine.getEnv().addReporter(
33-
new jasmine.JUnitXmlReporter('test_out/e2e-' + exports.config.capabilities.browserName + '-', true, true));
34+
new jasmine.JUnitXmlReporter('test_out/docs-e2e-' + exports.config.capabilities.browserName + '-', true, true));
3435
},
3536

3637
jasmineNodeOpts: {

scripts/travis/build.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ if [ $JOB = "unit" ]; then
1111
grunt tests:docs --browsers SL_Chrome,SL_Safari,SL_Firefox,SL_IE_9,SL_IE_10,SL_IE_11 --reporters dots
1212
grunt test:travis-protractor --specs "docs/app/e2e/**/*.scenario.js"
1313
elif [ $JOB = "e2e" ]; then
14+
if [ $TEST_TARGET = "jquery" ]; then
15+
export USE_JQUERY=1
16+
fi
17+
1418
export TARGET_SPECS="build/docs/ptore2e/**/default_test.js"
1519
if [ $TEST_TARGET = "jquery" ]; then
1620
TARGET_SPECS="build/docs/ptore2e/**/jquery_test.js"
1721
fi
22+
23+
export TARGET_SPECS="test/e2e/tests/**/*.js,$TARGET_SPECS"
1824
grunt test:travis-protractor --specs "$TARGET_SPECS"
1925
else
2026
echo "Unknown job type. Please set JOB=unit or JOB=e2e-*."

test/e2e/fixtures/.jshintrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"browser": true,
3+
"globals": {
4+
"angular": false,
5+
"jQuery": false,
6+
"$": false
7+
}
8+
}

test/e2e/fixtures/sample/index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html ng-app="test">
3+
<div ng-controller="TestCtrl">
4+
<p>{{text}}</p>
5+
</div>
6+
7+
<script src="angular.js"></script>
8+
<script src="script.js"></script>
9+
</html>

test/e2e/fixtures/sample/script.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
angular.module("test", []).
2+
controller("TestCtrl", function($scope) {
3+
$scope.text = "Hello, world!";
4+
});

test/e2e/templates/test.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
{% if eq(test.ngAppTag, "html") %}
3+
<html ng-app="{{ test.ngApp }}">
4+
{% else %}
5+
<html>
6+
{% endif %}
7+
<head>
8+
{% if scripts.jQuery %}
9+
<script src="{{ scripts.jQuery }}"></script>
10+
{% endif %}
11+
{% for script in test.scripts %}
12+
<script src="{{ test.scripts[script] }}"></script>
13+
{% endfor %}
14+
{{ test.head }}
15+
</head>
16+
{% if test.ngAppTag === "body" %}
17+
<body ng-app="{{ test.ngApp }}">
18+
{% else %}
19+
<body>
20+
{% endif %}
21+
{% test.body %}
22+
</body>
23+
</html>

test/e2e/tests/.jshintrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"node": true,
3+
"globals": {
4+
"describe": false,
5+
"ddescribe": false,
6+
"xdescribe": false,
7+
"it": false,
8+
"xit": false,
9+
"iit": false
10+
}
11+
}

test/e2e/tests/helpers/main.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var helper = {
2+
andWaitForAngular: function() {
3+
browser.waitForAngular();
4+
},
5+
loadFixture: function(fixture) {
6+
var i = 0;
7+
while (fixture[i] === '/') ++i;
8+
fixture = fixture.slice(i);
9+
if (!/\/(index\.html)?$/.test(fixture)) {
10+
fixture += '/';
11+
}
12+
13+
if (process.env.USE_JQUERY) {
14+
fixture += '?jquery';
15+
}
16+
17+
browser.get('/e2e/fixtures/' + fixture);
18+
return helper;
19+
}
20+
};
21+
22+
global.test = helper;
23+
global.loadFixture = helper.loadFixture;

0 commit comments

Comments
 (0)