Giter Site home page Giter Site logo

Comments (7)

mreinstein avatar mreinstein commented on June 16, 2024

@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

from nodeunit.

rquadling avatar rquadling commented on June 16, 2024

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

from nodeunit.

mreinstein avatar mreinstein commented on June 16, 2024

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.

from nodeunit.

0joshuaolson1 avatar 0joshuaolson1 commented on June 16, 2024

nodeunit is not under very active development

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

from nodeunit.

mreinstein avatar mreinstein commented on June 16, 2024

This would go great in the README or project description.

@0joshuaolson1 I'd accept a PR for this

from nodeunit.

0joshuaolson1 avatar 0joshuaolson1 commented on June 16, 2024

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

from nodeunit.

mreinstein avatar mreinstein commented on June 16, 2024

send a proper pull request please

from nodeunit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.