Comments (4)
Kind of surprised it works in windows at all ;)
For now you could use a custom reporter, just copy lib/reporters/default.js and specify your new file as the reporter once you have updated the success and error characters. You can specify a reporter by using the reporter option:
nodeunit --reporter path/to/reporter.js
If you can work out a way to change the output depending on the environment I'll happily accept a patch.
from nodeunit.
Why wouldn't it work in Windows?
I'm using PuTTY from Windows and SSH into Ubuntu 10.10 server where I run nodeunit. I experience the same issue, except I get "รข" in place of both error and success marks. I'm not quite sure how to fix that, even in custom reporter. Maybe you know?
from nodeunit.
I also had the same issue with the default Command Prompt (cmd.exe), I (and still am) using Nodeunit through my cygwin Node installation. It really bothered me as well, and I looked into the issue. Even if I change the font for cmd to something more UTF8 capable, like Consolas, I could only improve those signs from question marks to weird symbols. I found out that the cause of the problem was that cmd uses "codepage" (chcp
) number 437.
Since then, I switched my Cygwin CMD console to Mintty, which handles UTF8 wonderfully, and well integrated to windows (even better than cmd...). Now I have other set of issues with it (vim works terribly, cannot use backspace inside, have to use gvim). But this is the best I could find so far.
Maybe you could go along the chcp line. Keep me posted if there is advancement! :)
from nodeunit.
Created a new reporter, almost like the default reporter, ready for windows.
- Is using text instead of signs
- Shows current test name before test starts.
Installation:
- copy the code below to lib/reporters/windows.js
- add 'windows': require('./windows') to lib/reporters/index.js
- use nodeunit with option: "--reporter windows"
/*!
* Nodeunit
* Copyright (c) 2010 Caolan McMahon
* MIT Licensed
*/
/**
* Module dependencies
*/
var nodeunit = require('../nodeunit'),
utils = require('../utils'),
sys = require('sys'),
fs = require('fs'),
track = require('../track'),
path = require('path'),
AssertionError = require('../assert').AssertionError;
/**
* Reporter info string
*/
exports.info = "Default tests reporter";
/**
* Run all tests within each module, reporting the results to the command-line.
*
* @param {Array} files
* @api public
*/
exports.run = function (files, options) {
if (!options) {
// load default options
var content = fs.readFileSync(
__dirname + '/../../bin/nodeunit.json', 'utf8'
);
options = JSON.parse(content);
}
var error = function (str) {
return options.error_prefix + str + options.error_suffix;
};
var ok = function (str) {
return options.ok_prefix + str + options.ok_suffix;
};
var bold = function (str) {
return options.bold_prefix + str + options.bold_suffix;
};
var assertion_message = function (str) {
return options.assertion_prefix + str + options.assertion_suffix;
};
var start = new Date().getTime();
var paths = files.map(function (p) {
return path.join(process.cwd(), p);
});
var tracker = track.createTracker(function (tracker) {
if (tracker.unfinished()) {
console.log('');
console.log(error(bold(
'FAILURES: Undone tests (or their setups/teardowns): '
)));
var names = tracker.names();
for (var i = 0; i < names.length; i += 1) {
console.log('- ' + names[i]);
}
console.log('');
console.log('To fix this, make sure all tests call test.done()');
process.reallyExit(tracker.unfinished());
}
});
nodeunit.runFiles(paths, {
testspec: options.testspec,
moduleStart: function (name) {
console.log('\n ' + bold(name));
},
testStart: function(name) {
var line = ' @ ' + name.toString() + ' ';
for (var i=name.toString().length; i<65;i++)
line += '.';
sys.print(line);
tracker.put(name);
},
testDone: function (name, assertions) {
tracker.remove(name);
if (!assertions.failures()) {
console.log(ok(' SUCCESS'));
}
else {
console.log(error(' FAILED'));
assertions.forEach(function (a) {
if (a.failed()) {
a = utils.betterErrors(a);
if (a.error instanceof AssertionError && a.message)
console.log(assertion_message(' -> Message:' + a.message))
console.log('\n' + a.error.stack + '\n');
}
});
console.log('')
}
},
done: function (assertions, end) {
var end = end || new Date().getTime();
var duration = end - start;
if (assertions.failures()) {
console.log(
'\n\n' + bold(error('FAILURES: ')) + assertions.failures() +
'/' + assertions.length + ' assertions failed (' +
assertions.duration + 'ms)'
);
}
else {
console.log(
'\n\n' + bold(ok('OK: ')) + assertions.length +
' assertions (' + assertions.duration + 'ms)'
);
}
}
});
};
from nodeunit.
Related Issues (20)
- Some reporters do not display assertion error message HOT 4
- TAP reporter is broken in [email protected]+ (works in nodeunit 0.9.2) HOT 9
- issues with the _deepEqual algorithm HOT 2
- replace the old makefile with browserify or webpack
- Add explicit process exit on success HOT 1
- nodeunit.js in examples/browser is out of date HOT 1
- Incorrect exit code when running multiple directories HOT 2
- ReferenceError when using junit reporter in 0.11.0 HOT 4
- Q: Is there a better way to dynamically create tests than a monkey-patch? HOT 1
- Release 0.11.1 HOT 1
- FYI: nodeunit plugin for exhaustive testing of asynchronous sequences HOT 1
- setUp & tearDown not called as docs would imply
- Ways to skip, and run single(s) tests
- ES6 Module export
- Use template-literal instead of EJS
- Not all reporters support recursion. HOT 7
- Tap dependency update to v11 HOT 9
- make test on fresh clone failes due to undeclared dependencies HOT 1
- How to export function from module without nodeunit testing it?
- how to output html reporter to the file HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodeunit.