Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

allow more user control over paths to js file in lib dir #16

Merged
merged 2 commits into from

2 participants

Craig Blaszczyk Trevor Menagh
Craig Blaszczyk

In my project, I want more control over the path to jasmine used in EnvJasmine. I don['t want to use one copy of jasmine for the tests on the commandline and another for tests run in the browser.

Trevor Menagh
Owner

I like this addition. Could you also make a command line option for setting the reporter type? That would be trick.

Thanks for contributing!

Trevor Menagh trevmex merged commit d1f5f1b into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 20, 2012
  1. Craig Blaszczyk
  2. Craig Blaszczyk

    allow specification of custom reporter; add reporter which outputs co…

    jakul authored
    …unts of specs passed/failed instead of expect statments passed/failed
This page is out of date. Refresh to see the latest.
8 include/dependencies.js
View
@@ -2,6 +2,14 @@
//
// NOTE: Load order does matter.
+// Load the envjasmine environment
+EnvJasmine.loadGlobal(EnvJasmine.libDir + "envjs/env.rhino.1.2.js");
+EnvJasmine.loadGlobal(EnvJasmine.libDir + "jasmine/jasmine.js");
+EnvJasmine.loadGlobal(EnvJasmine.libDir + "jasmine-ajax/mock-ajax.js");
+EnvJasmine.loadGlobal(EnvJasmine.libDir + "jasmine-ajax/spec-helper.js");
+EnvJasmine.loadGlobal(EnvJasmine.libDir + "jasmine-jquery/jasmine-jquery-1.2.0.js");
+EnvJasmine.loadGlobal(EnvJasmine.libDir + "jasmine-rhino-reporter/jasmine-rhino-reporter.js");
+
// This is your main JavaScript directory in your project.
EnvJasmine.jsDir = EnvJasmine.rootDir + "/samples/"; // TODO: Change this to your project's main js directory.
19 lib/envjasmine.js
View
@@ -180,16 +180,6 @@ EnvJasmine.disableColor = (function (env) {
}());
EnvJasmine.results = [];
-// Load the envjasmine environment
-EnvJasmine.loadEnv = function () {
- EnvJasmine.loadGlobal(EnvJasmine.libDir + "envjs/env.rhino.1.2.js");
- EnvJasmine.loadGlobal(EnvJasmine.libDir + "jasmine/jasmine.js");
- EnvJasmine.loadGlobal(EnvJasmine.libDir + "jasmine-ajax/mock-ajax.js");
- EnvJasmine.loadGlobal(EnvJasmine.libDir + "jasmine-ajax/spec-helper.js");
- EnvJasmine.loadGlobal(EnvJasmine.libDir + "jasmine-jquery/jasmine-jquery-1.2.0.js");
- EnvJasmine.loadGlobal(EnvJasmine.libDir + "jasmine-rhino-reporter/jasmine-rhino-reporter.js");
-};
-
EnvJasmine.loadConfig = function () {
EnvJasmine.loadGlobal(EnvJasmine.configFile);
};
@@ -197,8 +187,15 @@ EnvJasmine.loadConfig = function () {
(function() {
var i, fileIn, len;
- EnvJasmine.loadEnv();
EnvJasmine.loadConfig();
+
+ if (typeof EnvJasmine.reporterClass === "undefined") {
+ // Use the standard reporter
+ EnvJasmine.reporterClass = RhinoReporter;
+ }
+
+
+ jasmine.getEnv().addReporter(new EnvJasmine.reporterClass());
if (EnvJasmine.suppressConsoleMsgs === true) {
// suppress console messages
89 lib/jasmine-rhino-reporter/jasmine-rhino-reporter.js
View
@@ -1,6 +1,10 @@
importPackage(java.lang);
var RhinoReporter = function() {
+ /*
+ * Reporter which reports the number of //expects// checks which
+ * passed/failed at the end of the test run
+ */
return {
reportRunnerStarting: function(runner) {
if (EnvJasmine.incrementalOutput) {
@@ -80,4 +84,87 @@ var RhinoReporter = function() {
};
};
-jasmine.getEnv().addReporter(new RhinoReporter());
+var RhinoSpecReporter = function() {
+ /*
+ * Reporter which reports the number of //specs// which passed/failed at the end
+ * of the test run
+ */
+ return {
+ reportRunnerStarting: function(runner) {
+ if (EnvJasmine.incrementalOutput) {
+ print(EnvJasmine.specFile);
+ }
+ },
+
+ reportRunnerResults: function(runner) {
+ var results = runner.results();
+
+ if (EnvJasmine.incrementalOutput) {
+ print();
+ print([
+ EnvJasmine.green("Passed: " + (results.passedCount - EnvJasmine.passedCount)),
+ EnvJasmine.red("Failed: " + (results.failedCount - EnvJasmine.failedCount)),
+ EnvJasmine.plain("Total: " + (results.totalCount - EnvJasmine.totalCount))
+ ].join(' '));
+ }
+ },
+
+ reportSuiteResults: function(suite) {
+ },
+
+ reportSpecStarting: function(spec) {
+ },
+
+ reportSpecResults: function(spec) {
+ if (spec.results().passed()) {
+ System.out.print(EnvJasmine.green("."));
+ EnvJasmine.passedCount += 1;
+ } else {
+ var i, msg, result,
+ specResults = spec.results().getItems();
+
+ System.out.print(EnvJasmine.red("F"));
+
+ msg = [
+ "FAILED",
+ "File : " + EnvJasmine.specFile,
+ "Suite: " + this.getSuiteName(spec.suite),
+ "Spec : " + spec.description
+ ];
+
+ for (i = 0; i < specResults.length; i++) {
+ result = specResults[i];
+ if (result.type == 'log') {
+ msg.push(result.toString());
+ } else if (result.type == 'expect' && result.passed && !result.passed()) {
+ msg.push(result.message);
+
+ if (result.trace.stack) {
+ msg.push(specResults[i].trace.stack);
+ }
+ }
+ }
+ EnvJasmine.failedCount += 1;
+
+ EnvJasmine.results.push(msg.join("\n"));
+ }
+ EnvJasmine.totalCount += 1;
+ },
+
+ log: function(str) {
+ },
+
+ getSuiteName: function(suite) {
+ var suitePath = [];
+
+ while (suite) {
+ suitePath.unshift(suite.description);
+ suite = suite.parentSuite;
+ }
+
+ return suitePath.join(' - ');
+ }
+ };
+};
+
+
Something went wrong with that request. Please try again.