8000 chore(testing): Testacular config files + rake tasks · angular/angular.js@9d168f0 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 9d168f0

Browse files
committed
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
1 parent 5418564 commit 9d168f0

File tree

6 files changed

+119
-40
lines changed

6 files changed

+119
-40
lines changed

Rakefile

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,24 +170,60 @@ task :package => [:clean, :minify, :version, :docs] do
170170
end
171171

172172

173-
namespace :server do
173+
desc 'Run all AngularJS tests'
174+
task :test, :browsers, :misc_options do |t, args|
174175

175-
desc 'Run JsTestDriver Server'
176-
task :start do
177-
sh %x(java -jar lib/jstestdriver/JsTestDriver.jar --browser open --port 9876)
176+
puts args
177+
178+
[ 'test:jqlite',
179+
'test:jquery',
180+
'test:modules',
181+
'test:e2e'
182+
].each do |task|
183+
Rake::Task[task].invoke(args[:browsers], args[:misc_options])
184+
end
185+
end
186+
187+
188+
namespace :test do
189+
190+
desc 'Run jqLite-based unit test suite (single run)'
191+
task :jqlite, :browsers, :misc_options do |t, args|
192+
start_testacular('testacular-jqlite.conf.js', true, args[:browsers], args[:misc_options])
178193
end
179194

180-
desc 'Run JavaScript tests against the server'
181-
task :test do
182-
sh %(java -jar lib/jstestdriver/JsTestDriver.jar --tests all)
195+
196+
desc 'Run jQuery-based unit test suite (single run)'
197+
task :jquery, :browsers do |t, args|
198+
start_testacular('testacular-jquery.conf.js', true, args[:browsers], args[:misc_options])
199+
end
200+
201+
202+
desc 'Run bundled modules unit test suite (single run)'
203+
task :modules, :browsers, :misc_options do |t, args|
204+
start_testacular('testacular-modules.conf.js', true, args[:browsers], args[:misc_options])
183205
end
184206

207+
208+
desc 'Run e2e test suite (single run)'
209+
task :e2e, :browsers, :misc_options do |t, args|
210+
start_testacular('testacular-e2e.conf.js', true, args[:browsers], args[:misc_options])
211+
end
185212
end
186213

187214

188-
desc 'Run JavaScript tests'
189-
task :test do
190-
sh %(java -jar lib/jstestdriver/JsTestDriver.jar --tests all --browser open --port 9876)
215+
namespace :autotest do
216+
217+
desc 'Run jqLite-based unit test suite (autowatch)'
218+
task :jqlite, :browsers, :misc_options do |t, args|
219+
start_testacular('testacular-jqlite.conf.js', false, args[:browsers], args[:misc_options])
220+
end
221+
222+
223+
desc 'Run jQuery-based unit test suite (autowatch)'
224+
task :jquery, :browsers, :misc_options do |t, args|
225+
start_testacular('testacular-jquery.conf.js', false, args[:browsers], args[:misc_options])
226+
end
191227
end
192228

193229

@@ -302,3 +338,12 @@ def rewrite_file(filename)
302338
f.write content
303339
end
304340
end
341+
342+
343+
def start_testacular(config, singleRun, browsers, misc_options)
344+
sh "testacular start " +
345+
"#{config} " +
346+
"#{'--single-run=true' if singleRun} " +
347+
"#{'--browsers=' + browsers.gsub('+', ',') if browsers} " +
348+
"#{misc_options}"
349+
end

angularFiles.js

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -196,36 +196,30 @@ angularFiles = {
196196
]
197197
};
198198

199-
// Execute only in slim-jim
200-
if (typeof JASMINE_ADAPTER !== 'undefined') {
201-
// Testacular config
202-
var mergedFiles = [];
203-
angularFiles.jstd.forEach(function(file) {
204-
// replace @ref
205-
var match = file.match(/^\@(.*)/);
206-
if (match) {
207-
var deps = angularFiles[match[1]];
208-
if (!deps) {
209-
console.log('No dependency:' + file)
199+
if (exports) {
200+
exports.files = angularFiles
201+
exports.mergeFiles = function mergeFiles() {
202+
var files = [];
203+
204+
[].splice.call(arguments, 0).forEach(function(file) {
205+
if (file.match(/testacular/)) {
206+
files.push(file);
207+
} else {
208+
angularFiles[file].forEach(function(f) {
209+
// replace @ref
210+
var match = f.match(/^\@(.*)/);
211+
if (match) {
212+
var deps = angularFiles[match[1]];
213+
files = files.concat(deps);
214+
} else {
215+
if (!/jstd|jasmine/.test(f)) { //TODO(i): remove once we don't have jstd/jasmine in repo
216+
files.push(f);
217+
}
218+
}
219+
});
210220
}
211-
mergedFiles = mergedFiles.concat(deps);
212-
} else {
213-
mergedFiles.push(file);
214-
}
215-
});
221+
});
216222

217-
files = [JASMINE, JASMINE_ADAPTER];
218-
219-
mergedFiles.forEach(function(file){
220-
if (/jstd|jasmine/.test(file)) return;
221-
files.push(file);
222-
});
223-
224-
225-
exclude = angularFiles.jstdExclude;
226-
227-
autoWatch = true;
228-
autoWatchInterval = 1;
229-
logLevel = LOG_INFO;
230-
logColors = true;
223+
return files;
224+
}
231225
}

testacular-e2e.conf.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var angularFiles = require(__dirname + '/angularFiles.js');
2+
3+
files = [ANGULAR_SCENARIO, ANGULAR_SCENARIO_ADAPTER, 'build/docs/docs-scenario.js'];
4+
5+
autoWatch = false;
6+
singleRun = true;
7+
logLevel = LOG_INFO;
8+
logColors = true;
9+
browsers = ['Chrome']
10+
11+
proxies = {
12+
'/': 'http://localhost:8000/build/docs/'
13+
};

testacular-jqlite.conf.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var angularFiles = require(__dirname + '/angularFiles.js');
2+
3+
files = angularFiles.mergeFiles(JASMINE, JASMINE_ADAPTER, 'jstd');
4+
exclude = ['**/*jasmine*/**', '**/*jstd*/**'].concat(angularFiles.files.jstdExclude);
5+
6+
autoWatch = true;
7+
logLevel = LOG_INFO;
8+
logColors = true;
9+
browsers = ['Chrome']

testacular-jquery.conf.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var angularFiles = require(__dirname + '/angularFiles.js');
2+
3+
files = angularFiles.mergeFiles(JASMINE, JASMINE_ADAPTER, 'jstdJquery');
4+
exclude = ['**/*jasmine*/**', '**/*jstd*/**'].concat(angularFiles.files.jstdJqueryExclude);
5+
6+
autoWatch = true;
7+
logLevel = LOG_INFO;
8+
logColors = true;
9+
browsers = ['Chrome']

testacular-modules.conf.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var angularFiles = require(__dirname + '/angularFiles.js');
2+
3+
files = angularFiles.mergeFiles(JASMINE, JASMINE_ADAPTER, 'jstdModules', 'angularSrcModules');
4+
exclude = ['**/*jasmine*/**', '**/*jstd*/**'];
5+
6+
autoWatch = true;
7+
logLevel = LOG_INFO;
8+
logColors = true;
9+
browsers = ['Chrome']

0 commit comments

Comments
 (0)
0