Created
December 6, 2012 18:34
-
-
Save codeprogression/4226867 to your computer and use it in GitHub Desktop.
Jasmine runner for multiple specs (AMD)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(['path/to/source', 'jasmine', 'jasmine-ajax'], function (source, jasmine) { | |
describe('spec description', function(){ | |
// Add specs here | |
}; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
"http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<title>Jasmine Spec Runner</title> | |
<link rel="stylesheet" type="text/css" href="lib/jasmine.css"> | |
<script type="text/javascript" src="../vendor/require.js" data-main="SpecRunner"></script> | |
</head> | |
<body> | |
<div id="sandbox" style="overflow:hidden; height: 1px;"></div> | |
</body> | |
</html> | |
<!-- http://www.bennadel.com/blog/2393-Writing-My-First-Unit-Tests-With-Jasmine-And-RequireJS.htm --> | |
<!-- http://kilon.org/blog/2012/08/testing-backbone-requirejs-applications-with-jasmine/ --> | |
<!-- https://github.com/uzikilon/Todos/tree/master/test/jasmine --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require.config({ | |
baseUrl: '..', | |
paths: { | |
// source directories | |
app: 'app' | |
// app libaries | |
log: 'app/common/log' | |
// vendor libraries | |
text: 'vendor/text', | |
domReady: 'vendor/domready', | |
jquery: 'vendor/jquery', | |
bootstrap: 'vendor/bootstrap', | |
underscore: 'vendor/underscore', | |
backbone: 'vendor/backbone', | |
broker: 'vendor/backbone-eventbroker', | |
nested: 'vendor/backbone-nested', | |
// test libraries | |
'jasmine': 'tests/lib/jasmine', | |
'jasmine-html': 'tests/lib/jasmine-html', | |
'jasmine-ajax': 'tests/lib/jasmine-ajax', | |
// specs directory | |
'specs': 'tests/specs' | |
}, | |
shim: { | |
jquery: { exports: '$' }, | |
backbone: { | |
deps: ['jquery', 'underscore'], | |
exports: 'Backbone' | |
}, | |
bootstrap: { | |
deps: ['jquery'], | |
exports: 'bootstrap' | |
}, | |
nested: ['backbone'], | |
broker: ['backbone'], | |
players: { exports: '_V_' }, | |
jasmine: { exports: 'jasmine' }, | |
'jasmine-ajax': { | |
deps: ['jasmine'], | |
exports: 'jasmine' | |
}, | |
'jasmine-html': { | |
deps: ['jasmine'], | |
exports: 'jasmine' | |
} | |
} | |
}); | |
require(['jquery', 'jasmine-html'], function($, jasmine) { | |
var jasmineEnv = jasmine.getEnv(); | |
jasmineEnv.updateInterval = 1000; | |
var htmlReporter = new jasmine.HtmlReporter(); | |
jasmineEnv.addReporter(htmlReporter); | |
jasmineEnv.specFilter = function(spec) { | |
return htmlReporter.specFilter(spec); | |
}; | |
var specs = []; | |
specs.push('specs/myspec.spec'); | |
$(function() { | |
require(specs, function() { | |
jasmineEnv.execute(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment