All Questions
Tagged with node.js unit-testing
11 questions
1
vote
1
answer
191
views
How to avoid messy variable dependencies for ease of testing in Node?
I couldn't decide if the question belongs on Stack Overflow, but I went with SE Stack Exchange for the higher quality, broader answers. Bare with me.
Examples are in Node but I guess applies to a ...
-3
votes
1
answer
219
views
Is splitting unit tests from integration test with mocks worth the effort (in nodejs)?
Well consider a relative simple server for a SPA application. Written in nodejs with express and knex as backends.
Now if we do it properly each function will have unit tests (as they are always all ...
3
votes
1
answer
296
views
Why should I write unit test for my example instead of (or with) my integration test
I have a repository function on my repository layer. I use sequelize as data access. I will write tests for my function.
Here is the logic I want in English:
My function should save a user to ...
2
votes
1
answer
312
views
How to unit test a service which output is an event with data?
Technologies : NodeJs, Kafka, Mocha
The issue : I have a nodeJS service which given a String returns events with a many data.
How can I test this using Mocha ?
In a simple scenario the service ...
3
votes
2
answers
610
views
How to test database dependent functionalities?
I have written this function which checks if a user already exists in the application:
async function ValidateUserExists(username, email){
if(!username || !email) throw new Error('Invalid number ...
1
vote
0
answers
55
views
Node JS Tape Unit Testing : All cases inside one function for a method
I am using tape for unit testing in Node JS. I wanted to ask one thing about better coding while writing unit testing.
When using different inputs to a single method, is it a better idea to use all ...
1
vote
2
answers
216
views
Is there any reason to use testing frameworks instead of assert for a lightweight lib of pure functions?
I've just written a simple mathematical library which consists of pure functions that take a few arguments, do some computation and return a result. I'd like to write unit tests for this library, but ...
9
votes
2
answers
1k
views
Respectable design pattern for making node modules flexible/testable?
I am looking to get some input from some more experienced testers than what I am. :)
I am trying to make my node modules testable, allowing for dependency spying/stubbing/mocking without the need to ...
10
votes
1
answer
932
views
Testing gap between unit and integration: Integration in the Small, Component, Unit Integration Tests
Over the past few weeks I've been mulling and researching how to fill a gap in our testing methodology. In simplified terms unit tests are too small and traditional integration tests are too big.
A ...
2
votes
1
answer
1k
views
How to unit test models in MVC / MVR app?
I'm building a node.js web app and am trying to do so for the first time in a test driven fashion. I'm using nodeunit for testing, which I find allows me to write tests quickly and painlessly. In this ...
2
votes
2
answers
2k
views
Unit testing in node.js and mocking modules
I'm trying to test this wrapper to request that I made:
// lib/http-client.js
var app = require('app'),
request = require('request');
exports.search = function(searchTerm, next) {
var options =...