How to use the nodeunit-x.reporters function in nodeunit-x

To help you get started, we’ve selected a few nodeunit-x examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gruntjs / grunt-contrib-nodeunit / tasks / nodeunit.js View on Github external
if (options.reporterOutput) {
      // Hook into stdout to capture report
      var unhook = hook_stdout(function(string) {
        output += string;
        return '';
      });
    }

    // if reporterOutput has a directory destination make sure to create it.
    // See: https://github.com/caolan/nodeunit/issues/262
    if (options.reporterOptions.output) {
      grunt.file.mkdir(path.normalize(options.reporterOptions.output));
    }

    // Run test(s).
    nodeunit.reporters[options.reporter].run(this.filesSrc, options.reporterOptions, function(err) {
      // Write the output of the reporter if wanted
      if (options.reporterOutput) {
        // no longer hook stdout so we can grunt.log
        if (unhook) {
          unhook();
        }

        // save all of the output we saw up to this point
        grunt.file.write(options.reporterOutput, output);

        grunt.log.ok('Report "' + options.reporterOutput + '" created.');
      }

      done(err);
    });
  });
github gruntjs / grunt-contrib-nodeunit / tasks / nodeunit.js View on Github external
function logFailedAssertions() {
    var assertion;
    // Print each assertion error + stack.
    while (assertion = failedAssertions.shift()) {
      betterErrors(assertion);
      cleanStack(assertion.error);
      grunt.verbose.or.error(assertion.testName);
      if (assertion.error.name === 'AssertionError' && assertion.message) {
        grunt.log.error('Message: ' + assertion.message.magenta);
      }
      grunt.log.error(assertion.error.stack).writeln();
    }
  }

  // Define our own Nodeunit reporter.
  nodeunit.reporters.grunt = {
    info: 'Grunt reporter',
    run: function(files, options, callback) {
      var opts = {
        // No idea.
        testspec: undefined,
        // Executed when the first test in a file is run. If no tests exist in
        // the file, this doesn't execute.
        moduleStart: function(name) {
          // Keep track of this so that moduleDone output can be suppressed in
          // cases where a test file contains no tests.
          currentModule = name;
          grunt.verbose.subhead('Testing ' + name).or.write('Testing ' + name);
        },
        // Executed after a file is done being processed. This executes whether
        // tests exist in the file or not.
        moduleDone: function(name) {

nodeunit-x

Easy unit testing for node.js and the browser.

MIT
Latest version published 2 years ago

Package Health Score

45 / 100
Full package analysis

Popular nodeunit-x functions

Similar packages