Created
November 5, 2012 21:44
-
-
Save klipstein/4020539 to your computer and use it in GitHub Desktop.
Execute Jasmine Tests within BonsaiJS runner context
This file contains hidden or 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([], function() { | |
describe('bar', function() { | |
// ... | |
}); | |
}); |
This file contains hidden or 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> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Jasmine Spec Runner</title> | |
<link rel="stylesheet" href="lib/jasmine-core/jasmine.css"> | |
<style> | |
#bonsai-player { | |
position: absolute; | |
visibility: hidden; | |
} | |
</style> | |
<!-- or your local bonsaijs --> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/bonsai/0.4/bonsai.min.js"></script> | |
<script src="lib/jasmine-core/jasmine.js"></script> | |
<script src="lib/jasmine-core/jasmine-html.js"></script> | |
<script src="lib/jasmine-core/jasmine.junit-reporter.js"></script> | |
</head> | |
<body> | |
<div id="bonsai-player"></div> | |
<script> | |
bonsai.setup({ | |
// required to access the parent context from within runner.js | |
runnerContext: bonsai.IframeRunnerContext, | |
}).run(document.getElementById('bonsai-player'), { | |
urls: [ | |
'lib/requirejs/require.js', | |
'runner.js' // see below | |
] | |
}); | |
</script> | |
</body> | |
</html> |
This file contains hidden or 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
// copy jasmine properties to internal bonsai scope | |
jasmine = parent.jasmine; | |
afterEach = parent.afterEach; | |
beforeEach = parent.beforeEach; | |
describe = parent.describe; | |
it = parent.it; | |
expect = parent.expect; | |
spyOn = parent.spyOn; | |
xit = parent.xit; | |
runs = parent.runs; | |
waitsFor = parent.waitsFor; | |
xdescribe = parent.xdescribe; | |
waitForAsync = parent.waitForAsync; | |
require.config({ | |
paths: {} | |
}); | |
require([ | |
'foo-spec.js' | |
// your other specs | |
], function() { | |
var jasmineEnv = jasmine.getEnv(); | |
jasmineEnv.execute(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment