Questions tagged [node.js-tape]

A simple TAP-producing test library for node.js. The tape API is a small superset of the node core assert module.

Tape's NPM Page:
https://www.npmjs.com/package/tape

Tape source code:
https://github.com/substack/tape

Tape advocacy essay:
https://medium.com/javascript-scene/why-i-use-tape-instead-of-mocha-so-should-you-6aa105d8eaf4

45 questions
1
vote
1 answer

When carrying out my unit tests, how can I execute custom code if at least one of my unit tests fails?

In a test file, I've added several unit tests using the Tape test harness. What I'd like to do now is ensure that, if at least one of my unit tests fails (screenshot), some custom JS code is executed. How would I approach that? In this case, the…
cag8f
  • 817
  • 1
  • 10
  • 33
1
vote
0 answers

Need explanation for this particular quirky asynchronous behavior

I have e2e tests for a javascript library, which works with the canvas element. It's organized this way: there is an html page with a list of links, the canvas, and an image element. When I click on a link the library draws a particular test case on…
d.k
  • 4,234
  • 2
  • 26
  • 38
1
vote
1 answer

nodejs - How to check which portion of code is tested with unit tests?

I am using tape and istanbul to write unit tests in my Node.js project and the result is the following: Statements : 93.04% ( 107/115 ) Branches : 86.84% ( 33/38 ) Functions : 90% ( 27/30 ) Lines : 93.86% ( 107/114 ) Is there a way…
1
vote
0 answers

Making tests independent in Node JS Tape

I am trying to test functions in my script that I have written in Node JS. I am using tape for unit testing. But I am facing one problem of how to make each test case independent. Eg. there are some global variables in the script. The values of…
Chacha
  • 411
  • 1
  • 5
  • 12
1
vote
1 answer

Mocking methods in Tape Node js

What is the way to mock methods in unit tests using tape in Node js? I did not find anything in readme. I am pretty new to Node js, so this question seems pretty simple to some people. Please provide some suggestions.
Chacha
  • 411
  • 1
  • 5
  • 12
1
vote
1 answer

JS Tape - Wait for previous async test to complete to move to next test

I am new to the working with TAPE JS for testing. I have it all setup and working, and it works fine with regular tests. But I am trying to test a unique REST API based product that relies on certain calls to have been made before the next call has…
Dylan Cross
  • 5,918
  • 22
  • 77
  • 118
1
vote
1 answer

Testing method calls

I'm a bit of a hacker (i.e. write some code and manually test the functionality) but now I want to add a bit more structure to my coding by adding some unit tests and follow a TDD approach. But I'm struggling to build a unit test that validates a…
hloughrey
  • 958
  • 3
  • 11
  • 22
1
vote
1 answer

How to write a custom assertion for testing node or javascript with tape, or check for substring rather than t.deepEquals()?

Using tape, how can I write a custom assertion method to use in place of t.equal()? Or is there a test assertion method that can check for a substring so that the entire string I'm testing does not have to be compared verbatim using…
1
vote
0 answers

Why does this promise code never run?

As you can see in the .gif below, I call tape.js twice in my integration tests and it works fine. But the second time I run the tests, after I've commented out the code to insert test data into my database, the body of the tape.js function never…
Richard
  • 14,798
  • 21
  • 70
  • 103
1
vote
2 answers

Testing AMD modules with tape/ES6 unit tests?

I have a web app using: ES5 RequireJS Underscore Backbone jQuery I have tried setting up a new unit test suite using: ES6 Tape Babel6 My AMD module app/util/stringUtil.js: define([], function() { 'use strict'; return { isBlank:…
BunnyRabbit
  • 347
  • 1
  • 2
  • 12
1
vote
1 answer

running multiple tests via npm test and jspm

I'm using jspm to manage the modules in my project. I'd like to write tests using tape and using ES6 syntax. I'd like to be able to run those tests from the command line using npm test. If I run jspm run test/example.js directly from the command…
user5325596
  • 2,310
  • 4
  • 25
  • 42
1
vote
2 answers

How to set up JavaScript github test harness using tape & testling

I have a (JavaScript) repository on github which I would like to set up a test harness for. It seems ‘tape’ and ‘testling’ should do what I want (minimal lightweight solution with pretty github badges), unless anyone has alternative solutions, but…
ChrisV
  • 8,748
  • 3
  • 48
  • 38
0
votes
0 answers

Nodejs HAPI Tape Pre Unit test

Added in a pre-requisite for the endpoint to validate that the client information being passed is legit or it will throw an error. The clientProfileValidation.clientProfileValidation method receives the request object and returns a profile object…
chris clifton
  • 133
  • 1
  • 13
0
votes
1 answer

How to use jsdom in a file which is bundled with Browserify?

I am trying to create a unit test for a function. In the test, I would like to emulate the global document object (e.g. document.getElementById()) using the jsdom package. I have installed jsdom in my project, and to my test file…
cag8f
  • 817
  • 1
  • 10
  • 33
0
votes
0 answers

Testing if object implements interface (type alias)

I am using a minimal testing library (Tape) which has a handful of testing methods available similar to many test frameworks. I have a type alias and an object which implements it. export type myType = { myFunc(cb: (val: string) => void):…
myol
  • 8,857
  • 19
  • 82
  • 143