http://whatis.techtarget.com
e2e testing
integration testing
unit testing
function openApp(option) {
browser.addMockModule('mockModule', function (opt) {
angular.module('mockModule', []).run(function (experiments, hotelState) {
experiments.UpgradeSection = opt;
experiments.HideGreedyPopup = true;
hotelState.upgraded = false;
});
}, option);
browser.get('http://localhost:9000/back-office-v2.html');
}
describe('A/B test for upgrade button', function () {
var upgrade;
function openApp(option) { ... }
it('should display upgrade button at the bottom', function () {
openApp('bottom');
upgrade = $('#upgrade-bar');
expect(upgrade.isDisplayed()).toBe(true);
});
it('should display upgrade button on the top-right corner', function () {
openApp('top-right');
upgrade = $('.upgrade-section');
expect(upgrade.isDisplayed()).toBe(true);
});
it('should display upgrade button inside the menu', function () {
openApp('menu');
upgrade = $('.upgrade-section-2');
expect(upgrade.isDisplayed()).toBe(true);
});
});
e2e testing
integration testing
unit testing
Test the
module.exports = function (config) {
config.set({
plugins: [
'karma-jasmine',
'karma-phantomjs-launcher',
'karma-ng-html2js-preprocessor'
],
ngHtml2JsPreprocessor: { ... },
frameworks: ['jasmine'],
files: [
...
'app/template/**/*.html',
'app/views/**/*.html'
]
...
});
};
beforeEach(function () {
module('backOfficeApp', function ($provide, $filterProvider) {
$provide.constant('hotelState', { ... });
$provide.constant('$wix', {
Dashboard: { ... },
Billing: { ... },
Extensions: { ... }
});
$filterProvider.register('translate', function () {
return function (str) {
return str;
};
});
});
});
var $rootScope;
beforeEach(function () {
inject(function ($injector) {
$rootScope = $injector.get('$rootScope');
});
$scope = $rootScope.$new();
$scope.vm = {}; // for controller as syntax
$scope.vm.experiments = {};
$scope.vm.premiumManager = {
showBoUpgradeBar: jasmine.createSpy().andReturn(true),
upgradeFromBo: jasmine.createSpy(),
ready: jasmine.createSpy()
};
});
var $templateCache, template;
beforeEach(function () {
inject(function ($injector) {
$templateCache = $injector.get('$templateCache');
});
template = $templateCache.get('views/layout.html');
});
var $templateCache, $rootScope, $compile, $scope, template;
beforeEach(function () {
module('backOfficeApp', function () { ... });
inject(function ($injector) {
$templateCache = $injector.get('$templateCache');
$rootScope = $injector.get('$rootScope');
$compile = $injector.get('$compile');
});
template = ...;
$scope = ...
});
function compile() {
var elem = $compile(angular.element('<div></div>').html(template))($scope);
$scope.$digest();
return elem;
}
describe('A/B test for upgrade button', function () {
var $templateCache, $rootScope, $compile, $scope, template;
beforeEach(function () { ... });
function compile() { ... }
it('should display upgrade button at the bottom', function () {
$scope.experiments.UpgradeSection = 'bottom';
expect(compile().find('#upgrade-bar').length).toBe(1);
});
it('should display upgrade button on the top-right corner', function () {
$scope.experiments.UpgradeSection = 'top-right';
expect(compile().find('.upgrade-section').length).toBe(1);
});
it('should display upgrade button inside the menu', function () {
$scope.experiments.UpgradeSection = 'menu';
expect(compile().find('.upgrade-section-2').length).toBe(1);
});
});