feat(test): add e2e tests for benchmarks and examples

Disables running the actual benchmarks on every commit as well
to speed up the build.
This commit is contained in:
Tobias Bosch 2015-01-08 10:02:23 -08:00
parent 8c6527251b
commit 14e91e209e
14 changed files with 232 additions and 4 deletions

View File

@ -26,6 +26,10 @@ module.exports = function(config) {
'test-main.js' 'test-main.js'
], ],
exclude: [
'modules/**/e2e_test/**'
],
preprocessors: { preprocessors: {
'modules/**/*.js': ['traceur'], 'modules/**/*.js': ['traceur'],
'modules/**/*.es6': ['traceur'], 'modules/**/*.es6': ['traceur'],

View File

@ -0,0 +1,20 @@
var benchpress = require('../../../tools/benchpress/index.js');
describe('ng2 change detection benchmark', function () {
var URL = 'benchmarks/web/change_detection/change_detection_benchmark.html';
afterEach(benchpress.verifyNoBrowserErrors);
it('should not throw errors', function() {
browser.get(URL);
clickAll(['#ng2DetectChanges', '#baselineDetectChanges']);
});
});
function clickAll(buttonSelectors) {
buttonSelectors.forEach(function(selector) {
$(selector).click();
});
}

View File

@ -0,0 +1,21 @@
"use strict";
var benchpress = require('../../../tools/benchpress/index.js');
describe('ng2 compiler benchmark', function () {
var URL = 'benchmarks/web/compiler/compiler_benchmark.html';
afterEach(benchpress.verifyNoBrowserErrors);
it('should not throw errors', function() {
browser.get(URL);
clickAll(['#compileWithBindings', '#compileNoBindings']);
});
});
function clickAll(buttonSelectors) {
buttonSelectors.forEach(function(selector) {
$(selector).click();
});
}

View File

@ -0,0 +1,20 @@
var benchpress = require('../../../tools/benchpress/index.js');
describe('ng2 di benchmark', function () {
var URL = 'benchmarks/web/di/di_benchmark.html';
afterEach(benchpress.verifyNoBrowserErrors);
it('should not throw errors', function() {
browser.get(URL);
clickAll(['#getByToken', '#getByKey', '#getChild', '#instantiate']);
});
});
function clickAll(buttonSelectors) {
buttonSelectors.forEach(function(selector) {
$(selector).click();
});
}

View File

@ -0,0 +1,20 @@
var benchpress = require('../../../tools/benchpress/index.js');
describe('ng2 element injector benchmark', function () {
var URL = 'benchmarks/web/element_injector/element_injector_benchmark.html';
afterEach(benchpress.verifyNoBrowserErrors);
it('should not throw errors', function() {
browser.get(URL);
clickAll(['#instantiate', '#instantiateDirectives']);
});
});
function clickAll(buttonSelectors) {
buttonSelectors.forEach(function(selector) {
$(selector).click();
});
}

View File

@ -0,0 +1,20 @@
var benchpress = require('../../../tools/benchpress/index.js');
describe('ng2 tree benchmark', function () {
var URL = 'benchmarks/web/tree/tree_benchmark.html';
afterEach(benchpress.verifyNoBrowserErrors);
it('should not throw errors', function() {
browser.get(URL);
clickAll(['#ng2CreateDom', '#ng2DestroyDom', '#baselineCreateDom', '#baselineDestroyDom']);
});
});
function clickAll(buttonSelectors) {
buttonSelectors.forEach(function(selector) {
$(selector).click();
});
}

View File

@ -0,0 +1,20 @@
var benchpress = require('../../../tools/benchpress/index.js');
describe('ng1.x compiler benchmark', function () {
var URL = 'benchmarks_external/web/compiler/compiler_benchmark.html';
afterEach(benchpress.verifyNoBrowserErrors);
it('should not throw errors', function() {
browser.get(URL);
clickAll(['#compileWithBindings', '#compileNoBindings']);
});
});
function clickAll(buttonSelectors) {
buttonSelectors.forEach(function(selector) {
$(selector).click();
});
}

View File

@ -0,0 +1,20 @@
var benchpress = require('../../../tools/benchpress/index.js');
describe('ng1.x tree benchmark', function () {
var URL = 'benchmarks_external/web/tree/tree_benchmark.html';
afterEach(benchpress.verifyNoBrowserErrors);
it('should not throw errors', function() {
browser.get(URL);
clickAll(['#createDom', '#destroyDom']);
});
});
function clickAll(buttonSelectors) {
buttonSelectors.forEach(function(selector) {
$(selector).click();
});
}

View File

@ -0,0 +1,30 @@
var benchpress = require('../../../../tools/benchpress/index.js');
describe('hello world', function () {
afterEach(benchpress.verifyNoBrowserErrors);
describe('static reflection', function() {
var URL = 'examples/web/hello_world/index_static.html';
it('should greet', function() {
browser.get(URL);
expect(getShadowText('hello-app')).toBe('hello world!');
});
});
describe('dynamic reflection', function() {
var URL = 'examples/web/hello_world/index.html';
it('should greet', function() {
browser.get(URL);
expect(getShadowText('hello-app')).toBe('hello world!');
});
});
});
function getShadowText(selector) {
return browser.executeScript('return document.querySelector("'+selector+'").shadowRoot.textContent');
}

View File

@ -0,0 +1,3 @@
var config = exports.config = require('./protractor-e2e-shared.js').config;
config.baseUrl = 'http://localhost:8002/';

View File

@ -0,0 +1,3 @@
var config = exports.config = require('./protractor-e2e-shared.js').config;
config.baseUrl = 'http://localhost:8001/';

46
protractor-e2e-shared.js Normal file
View File

@ -0,0 +1,46 @@
// load traceur runtime as our tests are written in es6
require('traceur/bin/traceur-runtime.js');
var config = exports.config = {
specs: ['dist/cjs/**/*_spec.js'],
// Disable waiting for Angular as we don't have an integration layer yet...
// TODO(tbosch): Implement a proper debugging API for Ng2.0, remove this here
// and the sleeps in all tests.
onPrepare: function() {
browser.ignoreSynchronization = true;
var _get = browser.get;
var sleepInterval = process.env.TRAVIS ? 5000 : 2000;
browser.get = function() {
var result = _get.apply(this, arguments);
browser.sleep(sleepInterval);
return result;
}
},
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
}
};
if (process.env.TRAVIS) {
config.capabilities = {
name: 'Dartium',
browserName: 'chrome',
chromeOptions: {
'binary': process.env.DARTIUM
},
loggingPrefs: {
performance: 'ALL'
}
};
} else {
config.capabilities = {
browserName: 'chrome',
loggingPrefs: {
performance: 'ALL'
}
};
}

View File

@ -27,10 +27,11 @@ var config = exports.config = {
onPrepare: function() { onPrepare: function() {
browser.ignoreSynchronization = true; browser.ignoreSynchronization = true;
var _get = browser.get; var _get = browser.get;
var sleepInterval = process.env.TRAVIS ? 5000 : 1000; var sleepInterval = process.env.TRAVIS ? 5000 : 2000;
browser.get = function() { browser.get = function() {
var result = _get.apply(this, arguments);
browser.sleep(sleepInterval); browser.sleep(sleepInterval);
return _get.apply(this, arguments); return result;
} }
}, },

View File

@ -29,5 +29,5 @@ serverPid=$!
trap killServer EXIT trap killServer EXIT
./node_modules/.bin/protractor protractor-perf-js.conf.js ./node_modules/.bin/protractor protractor-e2e-js.conf.js
./node_modules/.bin/protractor protractor-perf-dart2js.conf.js ./node_modules/.bin/protractor protractor-e2e-dart2js.conf.js