mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-04-23 08:04:43 +00:00
chore(testing): Testacular config files + rake tasks
- adds testacular config files for jqlite, jquery, modules and e2e tests - replaces obsolete JsTD Rake tasks with Testacular onces - rake tasks are parameterazied so that they can be used locally as well as on CI server usage: rake test # run all tests on Chrome rake test[Safari+Chrome+Opera] # run all tests on Safari, Chrome and Opera rake test[Safari] # run all tests on Safari rake test:jqlite # run unit tests using jqlite on Chrome rake test:jqlite[Safari,"--reporter=dots"] # run jqlite-based unit tests on Safari with dots reporter rake autotest:jquery # start testacular with jquery-based config and watch fs for changes rake test:e2e # run end to end tests
This commit is contained in:
parent
8133d468b9
commit
06eceeb09f
6 changed files with 122 additions and 43 deletions
71
Rakefile
71
Rakefile
|
|
@ -170,24 +170,60 @@ task :package => [:clean, :minify, :version, :docs] do
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
namespace :server do
|
desc 'Run all AngularJS tests'
|
||||||
|
task :test, :browsers, :misc_options do |t, args|
|
||||||
|
|
||||||
desc 'Run JsTestDriver Server'
|
puts args
|
||||||
task :start do
|
|
||||||
sh %x(java -jar lib/jstestdriver/JsTestDriver.jar --browser open --port 9876)
|
[ 'test:jqlite',
|
||||||
|
'test:jquery',
|
||||||
|
'test:modules',
|
||||||
|
'test:e2e'
|
||||||
|
].each do |task|
|
||||||
|
Rake::Task[task].invoke(args[:browsers], args[:misc_options])
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Run JavaScript tests against the server'
|
|
||||||
task :test do
|
|
||||||
sh %(java -jar lib/jstestdriver/JsTestDriver.jar --tests all)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
desc 'Run JavaScript tests'
|
namespace :test do
|
||||||
task :test do
|
|
||||||
sh %(java -jar lib/jstestdriver/JsTestDriver.jar --tests all --browser open --port 9876)
|
desc 'Run jqLite-based unit test suite (single run)'
|
||||||
|
task :jqlite, :browsers, :misc_options do |t, args|
|
||||||
|
start_testacular('testacular-jqlite.conf.js', true, args[:browsers], args[:misc_options])
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
desc 'Run jQuery-based unit test suite (single run)'
|
||||||
|
task :jquery, :browsers do |t, args|
|
||||||
|
start_testacular('testacular-jquery.conf.js', true, args[:browsers], args[:misc_options])
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
desc 'Run bundled modules unit test suite (single run)'
|
||||||
|
task :modules, :browsers, :misc_options do |t, args|
|
||||||
|
start_testacular('testacular-modules.conf.js', true, args[:browsers], args[:misc_options])
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
desc 'Run e2e test suite (single run)'
|
||||||
|
task :e2e, :browsers, :misc_options do |t, args|
|
||||||
|
start_testacular('testacular-e2e.conf.js', true, args[:browsers], args[:misc_options])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
namespace :autotest do
|
||||||
|
|
||||||
|
desc 'Run jqLite-based unit test suite (autowatch)'
|
||||||
|
task :jqlite, :browsers, :misc_options do |t, args|
|
||||||
|
start_testacular('testacular-jqlite.conf.js', false, args[:browsers], args[:misc_options])
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
desc 'Run jQuery-based unit test suite (autowatch)'
|
||||||
|
task :jquery, :browsers, :misc_options do |t, args|
|
||||||
|
start_testacular('testacular-jquery.conf.js', false, args[:browsers], args[:misc_options])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -302,3 +338,12 @@ def rewrite_file(filename)
|
||||||
f.write content
|
f.write content
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def start_testacular(config, singleRun, browsers, misc_options)
|
||||||
|
sh "testacular start " +
|
||||||
|
"#{config} " +
|
||||||
|
"#{'--single-run=true' if singleRun} " +
|
||||||
|
"#{'--browsers=' + browsers.gsub('+', ',') if browsers} " +
|
||||||
|
"#{misc_options}"
|
||||||
|
end
|
||||||
|
|
|
||||||
54
angularFiles.js
vendored
54
angularFiles.js
vendored
|
|
@ -196,36 +196,30 @@ angularFiles = {
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
// Execute only in slim-jim
|
if (exports) {
|
||||||
if (typeof JASMINE_ADAPTER !== 'undefined') {
|
exports.files = angularFiles
|
||||||
// Testacular config
|
exports.mergeFiles = function mergeFiles() {
|
||||||
var mergedFiles = [];
|
var files = [];
|
||||||
angularFiles.jstd.forEach(function(file) {
|
|
||||||
// replace @ref
|
[].splice.call(arguments, 0).forEach(function(file) {
|
||||||
var match = file.match(/^\@(.*)/);
|
if (file.match(/testacular/)) {
|
||||||
if (match) {
|
files.push(file);
|
||||||
var deps = angularFiles[match[1]];
|
} else {
|
||||||
if (!deps) {
|
angularFiles[file].forEach(function(f) {
|
||||||
console.log('No dependency:' + file)
|
// replace @ref
|
||||||
|
var match = f.match(/^\@(.*)/);
|
||||||
|
if (match) {
|
||||||
|
var deps = angularFiles[match[1]];
|
||||||
|
files = files.concat(deps);
|
||||||
|
} else {
|
||||||
|
if (!/jstd|jasmine/.test(f)) { //TODO(i): remove once we don't have jstd/jasmine in repo
|
||||||
|
files.push(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
mergedFiles = mergedFiles.concat(deps);
|
});
|
||||||
} else {
|
|
||||||
mergedFiles.push(file);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
files = [JASMINE, JASMINE_ADAPTER];
|
return files;
|
||||||
|
}
|
||||||
mergedFiles.forEach(function(file){
|
|
||||||
if (/jstd|jasmine/.test(file)) return;
|
|
||||||
files.push(file);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
exclude = angularFiles.jstdExclude;
|
|
||||||
|
|
||||||
autoWatch = true;
|
|
||||||
autoWatchInterval = 1;
|
|
||||||
logLevel = LOG_INFO;
|
|
||||||
logColors = true;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
13
testacular-e2e.conf.js
Normal file
13
testacular-e2e.conf.js
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
var angularFiles = require(__dirname + '/angularFiles.js');
|
||||||
|
|
||||||
|
files = [ANGULAR_SCENARIO, ANGULAR_SCENARIO_ADAPTER, 'build/docs/docs-scenario.js'];
|
||||||
|
|
||||||
|
autoWatch = false;
|
||||||
|
singleRun = true;
|
||||||
|
logLevel = LOG_INFO;
|
||||||
|
logColors = true;
|
||||||
|
browsers = ['Chrome']
|
||||||
|
|
||||||
|
proxies = {
|
||||||
|
'/': 'http://localhost:8000/build/docs/'
|
||||||
|
};
|
||||||
9
testacular-jqlite.conf.js
Normal file
9
testacular-jqlite.conf.js
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
var angularFiles = require(__dirname + '/angularFiles.js');
|
||||||
|
|
||||||
|
files = angularFiles.mergeFiles(JASMINE, JASMINE_ADAPTER, 'jstd');
|
||||||
|
exclude = ['**/*jasmine*/**', '**/*jstd*/**'].concat(angularFiles.files.jstdExclude);
|
||||||
|
|
||||||
|
autoWatch = true;
|
||||||
|
logLevel = LOG_INFO;
|
||||||
|
logColors = true;
|
||||||
|
browsers = ['Chrome']
|
||||||
9
testacular-jquery.conf.js
Normal file
9
testacular-jquery.conf.js
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
var angularFiles = require(__dirname + '/angularFiles.js');
|
||||||
|
|
||||||
|
files = angularFiles.mergeFiles(JASMINE, JASMINE_ADAPTER, 'jstdJquery');
|
||||||
|
exclude = ['**/*jasmine*/**', '**/*jstd*/**'].concat(angularFiles.files.jstdJqueryExclude);
|
||||||
|
|
||||||
|
autoWatch = true;
|
||||||
|
logLevel = LOG_INFO;
|
||||||
|
logColors = true;
|
||||||
|
browsers = ['Chrome']
|
||||||
9
testacular-modules.conf.js
Normal file
9
testacular-modules.conf.js
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
var angularFiles = require(__dirname + '/angularFiles.js');
|
||||||
|
|
||||||
|
files = angularFiles.mergeFiles(JASMINE, JASMINE_ADAPTER, 'jstdModules', 'angularSrcModules');
|
||||||
|
exclude = ['**/*jasmine*/**', '**/*jstd*/**'];
|
||||||
|
|
||||||
|
autoWatch = true;
|
||||||
|
logLevel = LOG_INFO;
|
||||||
|
logColors = true;
|
||||||
|
browsers = ['Chrome']
|
||||||
Loading…
Reference in a new issue