nodeunit icon indicating copy to clipboard operation
nodeunit copied to clipboard

Not all reporters support recursion.

Open rquadling opened this issue 8 years ago • 7 comments

Just started using nodeunit. It seems not all the reporters support the recursive option.

It seems recursive: options.recursive, is missing from the call to nodeunit.runFiles() in at least eclipse, html, junit, minimal, nested, skip-passed and verbose.

I can see where the missing option is missing from lcov and machineout, but in my limited testing, I couldn't see a difference ... or ANY output!

I have amended my installed nodeunit and get the recursion as expected.

I can create a patch (https://github.com/caolan/nodeunit/pull/348), but I'm not sure about proof/testing. Ideally, I'd like to know how to add tests to prove that the recursion is operational, but if the fix is correct and a super obvious oversight, then maybe it wouldn't be necessary.

rquadling avatar Jan 10 '18 17:01 rquadling

@rquadling you'll probably be better served exploring other testing frameworks. nodeunit is not under very active development. There are other modern and very active projects. My personal favorite is https://github.com/tapjs/node-tap

mreinstein avatar Jan 10 '18 17:01 mreinstein

Being completely new to JS unit testing, one thing I liked was how I could easily may the concepts of our PHPUnit testing (data providers, testcases, methods) to nodeunit. Very similar code layout.

Would you be able to "convert" one of our node unit tests to tap as an example? None of the team I'm with are expert enough yet, so we are learning from those that know more. https://gist.github.com/rquadling/457b5f4a7a3b01bd9df68e623bdc8fc5

rquadling avatar Jan 10 '18 17:01 rquadling

I'm not going to convert an entire unit test, but here's a stripped down example to get you started:

'use strict'

const Calculator = require(__dirname + '/../Digitickets').Calculator
const tap        = require('tap')


tap.test('basic calculator functionality', function(test) {
   const calculator = new Calculator()
   test.equals(calculator.getAmountTendered(), 0.00,
                'Amount Tendered starts at 0.00 for ' + testName)
   
   test.equals(calculator.getChange(), 0.00, 'Change Given starts at 0.00 for ' + testName)

   // ... further tests follow...

   test.end()
})

tap.test('some other calculator test', function(test) {
    // TODO: assertions go here

   test.end()
})

I'd recommend taking a look at http://www.node-tap.org/basics

I think you'll find these examples are pretty simple and you shouldn't have any trouble writing tap tests should you decide to do so.

mreinstein avatar Jan 10 '18 18:01 mreinstein

nodeunit is not under very active development

@mreinstein This would go great in the README or project description.

0joshuaolson1 avatar Feb 19 '18 19:02 0joshuaolson1

This would go great in the README or project description.

@0joshuaolson1 I'd accept a PR for this

mreinstein avatar Feb 19 '18 19:02 mreinstein

https://github.com/caolan/nodeunit/edit/master/README.md

0joshuaolson1 avatar Feb 19 '18 19:02 0joshuaolson1

send a proper pull request please

mreinstein avatar Feb 19 '18 19:02 mreinstein