21
votes
3answers
1k views

Code indentation for declaring inputs/outputs in an array

I'm writing a list of inputs and outputs for to be compared in unit tests. ...
13
votes
1answer
378 views

Unit-testing function

I've got this javascript function which was written a bit ad-hoc and I'm not really sure how to go about refactoring and improving it. It's basically an implementation of draft Unit-Testing/1.1 ...
6
votes
1answer
39 views

Catch-style unit testing in JavaScript (phase 1)

I decided to port my favorite unit testing framework, Catch, to JavaScript. So far I'm focusing on test cases and sections. I'll add assertions in phase 2, and output in phase 3. The goal for this ...
5
votes
1answer
815 views

Test mongoose model

I have mongoose model: ...
4
votes
1answer
115 views

First ever unit test. Am I headed in the right direction?

I'm learning backbone.js in parallel with unit testing. I've just made a simple model and wanted to unit test it. Do I have the right idea? I am simply making a model with some default values. ...
4
votes
1answer
354 views

User model with BackboneJS and RequireJS with test cases in Jasmine

I've been taking a stab at implementing test cases using the Jasmine testing framework. To do so, I've made an application which has a User object. This User object is created by the server, but its ...
4
votes
1answer
210 views

Does this nodeunit test conform to best practices?

I have inherited a node-js project, and I am completely new to it. Fortunately, it is already covered by unit tests. The class under test, FmsRescuers, has the ...
3
votes
1answer
272 views

my constructor is doing work. Is this a code smell in this example?

I have created a queue in javascript. This queue also has blocking take(). As you all probably know this is not really true, because javascript does not have ...
3
votes
1answer
118 views

Testing async API calls using Jasmine 2.0

I'm upgrading my project from YouTube's V2 API to their V3 API. I'm also taking the time to upgrade to Jasmine 2.0 since I already need to look at my test cases. Here's a couple of test cases and the ...
2
votes
1answer
70 views

Testing a mixin function

I have a mixin function which is as follows - ...
2
votes
4answers
454 views

What is a better (more testable) way to structure this page-specific JS?

I've created this (very) contrived example that demonstrates how we currently organize page specific JS in our app. Basically each page has a matching JS file that uses the module pattern to enclose ...
2
votes
0answers
15 views

Catch-style unit testing in JavaScript (phase 2)

Continued from phase 1; please read it first for background. Overview This phase focuses on assertions. Here's where things get ugly. Catch uses macro expansions to decompose assertion ...
1
vote
1answer
227 views

Is this factory method a good approach?

We are beginning to learn Node.js and we are not always sure if we do it the right way. We have a strong object oriented background so the adoption is not always easy. Right now we implemented a ...
1
vote
1answer
85 views

Is this a good approach to unit testing?

I'm relatively new to unit testing and having gone through quite a bit of pain I was starting to feel pretty good about my tests. The problem is, now I have a nice set of green ticks I'm also ...
1
vote
1answer
121 views

Production code to be good for unit testing

I would like to advise if the following production code is good to be unit tested. The segment of the production code gets data from a backend service and displays it on the page. It is a class: ...
1
vote
1answer
27 views

Testing individual nodes launched by naught using supertest

The purpose: an express node.js server which can be launched using naught, with an integration test using supertest. Each worker naught runs will test itself on a unique port, and only if passes it ...
0
votes
2answers
113 views

Is my JavaScript test actually testing anything worthwhile here

Given a production module like this: ...