jasmine
Advanced tools
Comparing version 2.2.1 to 2.3.0
@@ -9,4 +9,4 @@ #!/usr/bin/env node | ||
var examplesDir = path.join(__dirname, '..', 'node_modules', 'jasmine-core', 'lib', 'jasmine-core', 'example', 'node_example'); | ||
var command = new Command(path.resolve(), examplesDir); | ||
var command = new Command(path.resolve(), examplesDir, console.log); | ||
command.run(jasmine, process.argv.slice(2)); |
@@ -17,7 +17,13 @@ var path = require('path'), | ||
description: 'show help', | ||
action: help | ||
action: help, | ||
alias: '-h' | ||
}, | ||
version: { | ||
description: 'show jasmine and jasmine-core versions', | ||
action: version, | ||
alias: '-v' | ||
} | ||
}; | ||
function Command(projectBaseDir, examplesDir) { | ||
function Command(projectBaseDir, examplesDir, print) { | ||
this.projectBaseDir = projectBaseDir; | ||
@@ -33,4 +39,7 @@ this.specDir = path.join(projectBaseDir, 'spec'); | ||
Object.keys(subCommands).forEach(function(cmd) { | ||
if (commands.indexOf(cmd) >= 0) { | ||
commandToRun = subCommands[cmd]; | ||
var commandObject = subCommands[cmd]; | ||
if (commands.indexOf(cmd) >= 0) { | ||
commandToRun = commandObject; | ||
} else if(commandObject.alias && commands.indexOf(commandObject.alias) >= 0) { | ||
commandToRun = commandObject; | ||
} | ||
@@ -40,3 +49,3 @@ }); | ||
if (commandToRun) { | ||
commandToRun.action({projectBaseDir: command.projectBaseDir, specDir: command.specDir, examplesDir: examplesDir}); | ||
commandToRun.action({projectBaseDir: command.projectBaseDir, specDir: command.specDir, examplesDir: examplesDir, print: print}); | ||
} else { | ||
@@ -54,7 +63,15 @@ runJasmine(jasmine, parseOptions(commands)); | ||
var files = [], | ||
color = true; | ||
color = process.stdout.isTTY || false, | ||
filter, | ||
stopOnFailure; | ||
argv.forEach(function(arg) { | ||
if (arg === '--no-color') { | ||
color = false; | ||
} else if (isFileArg(arg)) { | ||
} else if (arg.match("^--filter=")) { | ||
filter = arg.match("^--filter=(.*)")[1]; | ||
} | ||
else if (arg.match("^--stop-on-failure=")) { | ||
stopOnFailure = arg.match("^--stop-on-failure=(.*)")[1] === 'true'; | ||
} | ||
else if (isFileArg(arg)) { | ||
files.push(arg); | ||
@@ -65,2 +82,4 @@ } | ||
color: color, | ||
filter: filter, | ||
stopOnFailure: stopOnFailure, | ||
files: files | ||
@@ -72,10 +91,12 @@ }; | ||
jasmine.loadConfigFile(process.env.JASMINE_CONFIG_PATH); | ||
if (env.stopOnFailure !== undefined) { | ||
jasmine.stopSpecOnExpectationFailure(env.stopOnFailure); | ||
} | ||
jasmine.configureDefaultReporter({ | ||
showColors: env.color | ||
}); | ||
jasmine.execute(env.files); | ||
jasmine.showColors(env.color); | ||
jasmine.execute(env.files, env.filter); | ||
} | ||
function initJasmine(options) { | ||
var print = options.print; | ||
var specDir = options.specDir; | ||
@@ -87,3 +108,3 @@ makeDirStructure(path.join(specDir, 'support/')); | ||
else { | ||
console.log('spec/support/jasmine.json already exists in your project.'); | ||
print('spec/support/jasmine.json already exists in your project.'); | ||
} | ||
@@ -121,19 +142,35 @@ } | ||
function help() { | ||
console.log('Usage: jasmine [command] [options] [files]'); | ||
console.log(''); | ||
console.log('Commands:'); | ||
function help(options) { | ||
var print = options.print; | ||
print('Usage: jasmine [command] [options] [files]'); | ||
print(''); | ||
print('Commands:'); | ||
Object.keys(subCommands).forEach(function(cmd) { | ||
console.log('%s\t%s', lPad(cmd, 10), subCommands[cmd].description); | ||
var commandNameText = cmd; | ||
if(subCommands[cmd].alias) { | ||
commandNameText = commandNameText + ',' + subCommands[cmd].alias; | ||
} | ||
print('%s\t%s', lPad(commandNameText, 10), subCommands[cmd].description); | ||
}); | ||
console.log(''); | ||
print(''); | ||
print('If no command is given, jasmine specs will be run'); | ||
print(''); | ||
print(''); | ||
console.log('Options:'); | ||
console.log('%s\t\tturn off color in spec output', lPad('--no-color', 15)); | ||
console.log(''); | ||
console.log('if no command is given, jasmine specs will be run'); | ||
print('Options:'); | ||
print('%s\tturn off color in spec output', lPad('--no-color', 18)); | ||
print('%s\tfilter specs to run only those that match the given string', lPad('--filter=', 18)); | ||
print('%s\t[true|false] stop spec execution on expectation failure. This takes precedence over the stopSpecOnExpectationFailure option in jasmine.json', lPad('--stop-on-failure=', 18)); | ||
print(''); | ||
print('The path to your jasmine.json can be configured by setting the JASMINE_CONFIG_PATH environment variable'); | ||
} | ||
function version(options) { | ||
var print = options.print; | ||
print('jasmine v' + require('../package.json').version); | ||
print('jasmine-core v' + require('../node_modules/jasmine-core/package.json').version); | ||
} | ||
function lPad(str, length) { | ||
if (str.length === length) { | ||
if (str.length >= length) { | ||
return str; | ||
@@ -140,0 +177,0 @@ } else { |
var path = require('path'), | ||
util = require('util'), | ||
glob = require('glob'), | ||
exit = require('exit'); | ||
exit = require('./exit'), | ||
ExitCodeReporter = require('./reporters/exit_code_reporter'), | ||
ConsoleSpecFilter = require('./filters/console_spec_filter'); | ||
module.exports = Jasmine; | ||
module.exports.ConsoleReporter = require('./console_reporter'); | ||
module.exports.ConsoleReporter = require('./reporters/console_reporter'); | ||
@@ -15,7 +17,17 @@ function Jasmine(options) { | ||
this.projectBaseDir = options.projectBaseDir || path.resolve(); | ||
this.printDeprecation = options.printDeprecation || require('./printDeprecation'); | ||
this.specFiles = []; | ||
this.helperFiles = []; | ||
this.env = this.jasmine.getEnv(); | ||
this.reportersCount = 0; | ||
this.exitCodeReporter = new ExitCodeReporter(); | ||
this.onCompleteCallbackAdded = false; | ||
this.exit = exit; | ||
this.showingColors = true; | ||
} | ||
Jasmine.prototype.showColors = function(value) { | ||
this.showingColors = value; | ||
}; | ||
Jasmine.prototype.addSpecFile = function(filePath) { | ||
@@ -31,11 +43,2 @@ this.specFiles.push(filePath); | ||
Jasmine.prototype.configureDefaultReporter = function(options) { | ||
var defaultOnComplete = function(passed) { | ||
if(passed) { | ||
exit(0); | ||
} | ||
else { | ||
exit(1); | ||
} | ||
}; | ||
options.timer = options.timer || new this.jasmine.Timer(); | ||
@@ -46,5 +49,7 @@ options.print = options.print || function() { | ||
options.showColors = options.hasOwnProperty('showColors') ? options.showColors : true; | ||
options.onComplete = options.onComplete || defaultOnComplete; | ||
options.jasmineCorePath = options.jasmineCorePath || this.jasmineCorePath; | ||
if(options.onComplete) { | ||
this.printDeprecation('Passing in an onComplete function to configureDefaultReporter is deprecated.'); | ||
} | ||
var consoleReporter = new module.exports.ConsoleReporter(options); | ||
@@ -64,2 +69,8 @@ this.addReporter(consoleReporter); | ||
Jasmine.prototype.loadHelpers = function() { | ||
this.helperFiles.forEach(function(file) { | ||
require(file); | ||
}); | ||
}; | ||
Jasmine.prototype.loadConfigFile = function(configFilePath) { | ||
@@ -79,4 +90,4 @@ var absoluteConfigFilePath = path.resolve(this.projectBaseDir, configFilePath || 'spec/support/jasmine.json'); | ||
filePaths.forEach(function(filePath) { | ||
if(jasmineRunner.specFiles.indexOf(filePath) === -1) { | ||
jasmineRunner.specFiles.push(filePath); | ||
if(jasmineRunner.helperFiles.indexOf(filePath) === -1) { | ||
jasmineRunner.helperFiles.push(filePath); | ||
} | ||
@@ -87,2 +98,4 @@ }); | ||
this.env.throwOnExpectationFailure(config.stopSpecOnExpectationFailure); | ||
if(config.spec_files) { | ||
@@ -106,7 +119,27 @@ jasmineRunner.addSpecFiles(config.spec_files); | ||
Jasmine.prototype.execute = function(files) { | ||
Jasmine.prototype.onComplete = function(onCompleteCallback) { | ||
this.exitCodeReporter.onComplete(onCompleteCallback); | ||
this.onCompleteCallbackAdded = true; | ||
}; | ||
Jasmine.prototype.stopSpecOnExpectationFailure = function(value) { | ||
this.env.throwOnExpectationFailure(value); | ||
}; | ||
Jasmine.prototype.execute = function(files, filterString) { | ||
this.loadHelpers(); | ||
if(this.reportersCount === 0) { | ||
this.configureDefaultReporter({}); | ||
this.configureDefaultReporter({ showColors: this.showingColors }); | ||
} | ||
if(filterString) { | ||
var specFilter = new ConsoleSpecFilter({ | ||
filterString: filterString | ||
}); | ||
this.env.specFilter = function(spec) { | ||
return specFilter.matches(spec.getFullName()); | ||
}; | ||
} | ||
if (files && files.length > 0) { | ||
@@ -119,3 +152,17 @@ this.specDir = ''; | ||
this.loadSpecs(); | ||
if(!this.onCompleteCallbackAdded) { | ||
var jasmineRunner = this; | ||
this.exitCodeReporter.onComplete(function(passed) { | ||
if(passed) { | ||
jasmineRunner.exit(0, process.platform, process.version, process.exit, require('exit')); | ||
} | ||
else { | ||
jasmineRunner.exit(1, process.platform, process.version, process.exit, require('exit')); | ||
} | ||
}); | ||
} | ||
this.addReporter(this.exitCodeReporter); | ||
this.env.execute(); | ||
}; |
@@ -11,3 +11,4 @@ { | ||
], | ||
"version": "2.2.1", | ||
"license": "MIT", | ||
"version": "2.3.0", | ||
"repository": { | ||
@@ -23,3 +24,3 @@ "type": "git", | ||
"glob": "^3.2.11", | ||
"jasmine-core": "~2.2.0" | ||
"jasmine-core": "~2.3.0" | ||
}, | ||
@@ -29,8 +30,7 @@ "bin": "./bin/jasmine.js", | ||
"devDependencies": { | ||
"grunt": "~0.4.2", | ||
"grunt-cli": "~0.1.13", | ||
"grunt-contrib-jshint": "~0.8.0", | ||
"grunt-contrib-copy": "~0.5.0", | ||
"shelljs": "~0.2.6" | ||
"grunt": "^0.4.2", | ||
"grunt-cli": "^0.1.13", | ||
"grunt-contrib-jshint": "^0.11.0", | ||
"shelljs": "^0.3.0" | ||
} | ||
} |
@@ -11,10 +11,5 @@ 'use strict'; | ||
jasmine.loadConfigFile('./spec/support/jasmine.json'); | ||
jasmine.configureDefaultReporter({ | ||
onComplete: function(passed) { | ||
done(passed); | ||
} | ||
}); | ||
jasmine.onComplete(done); | ||
jasmine.execute(); | ||
}); | ||
}; |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found
Found 1 instance in 1 package
4
0
586
21185
14
6
1
+ Addedjasmine-core@2.3.4(transitive)
- Removedjasmine-core@2.2.0(transitive)
Updatedjasmine-core@~2.3.0