mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-08 06:43:49 +00:00
Cleaning up the jasmine plugin adaptor
This commit is contained in:
parent
e42a062dcc
commit
297a924d05
@ -12,6 +12,8 @@ The main module of the Jasmine test plugin for TiddlyWiki5
|
|||||||
/*global $tw: false */
|
/*global $tw: false */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var TEST_TIDDLER_FILTER = "[type[application/javascript]tag[$:/tags/test-spec]]";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Startup function for running tests
|
Startup function for running tests
|
||||||
*/
|
*/
|
||||||
@ -27,24 +29,17 @@ exports.startup = function() {
|
|||||||
clearTimeout: clearTimeout,
|
clearTimeout: clearTimeout,
|
||||||
$tw: $tw
|
$tw: $tw
|
||||||
});
|
});
|
||||||
// Add the HTMLReporter
|
|
||||||
if($tw.browser) {
|
|
||||||
var reporterTitle = "$:/plugins/tiddlywiki/jasmine/jasmine-html.js";
|
|
||||||
var code = $tw.wiki.getTiddlerText(reporterTitle,"");
|
|
||||||
$tw.utils.evalSandboxed(code,context,reporterTitle);
|
|
||||||
} else {
|
|
||||||
var reporterTitle = "$:/plugins/tiddlywiki/jasmine/reporter.js";
|
|
||||||
context.require = function(moduleTitle) {
|
|
||||||
return $tw.modules.execute(moduleTitle,reporterTitle);
|
|
||||||
};
|
|
||||||
var code = $tw.wiki.getTiddlerText(reporterTitle,"");
|
|
||||||
var nodeReporters = $tw.utils.evalSandboxed(code,context,reporterTitle);
|
|
||||||
jasmine.TerminalVerboseReporter = nodeReporters.jasmineNode.TerminalVerboseReporter;
|
|
||||||
jasmine.TerminalReporter = nodeReporters.jasmineNode.TerminalReporter;
|
|
||||||
}
|
|
||||||
// Prepare the Jasmine environment
|
// Prepare the Jasmine environment
|
||||||
var jasmineEnv = jasmine.jasmine.getEnv();
|
var jasmineEnv = jasmine.jasmine.getEnv();
|
||||||
jasmineEnv.updateInterval = 1000;
|
jasmineEnv.updateInterval = 1000;
|
||||||
|
// Execute the appropriate reporter
|
||||||
|
var reporterTitle = $tw.browser ? "$:/plugins/tiddlywiki/jasmine/jasmine-html.js" : "$:/plugins/tiddlywiki/jasmine/reporter.js";
|
||||||
|
context.require = function(moduleTitle) {
|
||||||
|
return $tw.modules.execute(moduleTitle,reporterTitle);
|
||||||
|
};
|
||||||
|
var code = $tw.wiki.getTiddlerText(reporterTitle,""),
|
||||||
|
reporterExports = $tw.utils.evalSandboxed(code,context,reporterTitle);
|
||||||
|
// Link the reporter into jasmine
|
||||||
if($tw.browser) {
|
if($tw.browser) {
|
||||||
var htmlReporter = new jasmine.jasmine.HtmlReporter();
|
var htmlReporter = new jasmine.jasmine.HtmlReporter();
|
||||||
jasmineEnv.addReporter(htmlReporter);
|
jasmineEnv.addReporter(htmlReporter);
|
||||||
@ -52,14 +47,17 @@ exports.startup = function() {
|
|||||||
return htmlReporter.specFilter(spec);
|
return htmlReporter.specFilter(spec);
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
jasmineEnv.addReporter(new jasmine.TerminalVerboseReporter({
|
// The HTMLReporter links itself into the jasmine object automatically, but we have to manually add the node reporter
|
||||||
|
jasmine.jasmine.TerminalVerboseReporter = reporterExports.jasmineNode.TerminalVerboseReporter;
|
||||||
|
jasmine.jasmine.TerminalReporter = reporterExports.jasmineNode.TerminalReporter;
|
||||||
|
jasmineEnv.addReporter(new jasmine.jasmine.TerminalVerboseReporter({
|
||||||
print: require("util").print,
|
print: require("util").print,
|
||||||
color: true,
|
color: true,
|
||||||
includeStackTrace: true
|
includeStackTrace: true
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
// Iterate through all the test modules
|
// Iterate through all the test modules
|
||||||
var tests = $tw.wiki.filterTiddlers("[type[application/javascript]tag[$:/tags/test-spec]]");
|
var tests = $tw.wiki.filterTiddlers(TEST_TIDDLER_FILTER);
|
||||||
$tw.utils.each(tests,function(title,index) {
|
$tw.utils.each(tests,function(title,index) {
|
||||||
// Get the test specification code
|
// Get the test specification code
|
||||||
var code = $tw.wiki.getTiddlerText(title,"");
|
var code = $tw.wiki.getTiddlerText(title,"");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user