All Questions
21 questions
2
votes
0
answers
73
views
Express compatible JSON Web Token authentication middleware
I am writing an Express.js middleware function in a TypeScript NodeJS project that uses a function from a third-party module to perform a small workload. When writing unit tests, I want to mock this ...
3
votes
1
answer
114
views
Correct way to unit-test express API
I wrote an express API for a document management service (repo to be found here) and even though I understand the importance of unit-testing I never quite managed to wrap my head around how I would ...
5
votes
1
answer
705
views
Unit testing async functions in node/express
I am looking for the cleanest pattern to test middleware that contains async code using Mocha, Node's assert library, and Sinon. Here's a paired-down example of the function I'm testing.
...
2
votes
1
answer
66
views
NodeJS module to calculate linear motion
I am on the process of changing jobs, so I would like to get an idea of what I do wrong in order to improve.
For this, I have created a small node module. It's very simple; it calculates linear ...
3
votes
0
answers
43
views
Test Driven Development in JS and Sinon Stub
I am going through some TDD and BDD tutorials which guide one through implementing a simple beverage-ordering system. While I think I understand the material, I am still wondering about some ...
2
votes
2
answers
1k
views
RESTful CRUD application API Unit Tests
So I am trying to learn TDD/BDD with Javascript. I am creating a simple RESTful web app that uses GET, POST, PUT, and DELETE API calls to update data in a MongoDB database, and wanted to see if there ...
6
votes
1
answer
175
views
Support static typing / analysis with dependency injection
I am working on creating a test library, and I found DI to be pretty convenient, maybe even to create more functional coding patterns.
Normally we can have an awkward before-hook setup in Node.js ...
8
votes
2
answers
323
views
Yet Another Todo API
I've been on an adventure trying to learn NodeJs and put together a stack that I'd be happy to put into production if one day my team said to me "Let's build it in Node!". What we have here is your ...
2
votes
0
answers
134
views
One-based array in JavaScript
One day I stumbled upon a question on Stack Overflow: How do I create an array in javascript whose index starts from 1. The top answer says that it's impossible. However, that answer was posted ...
4
votes
0
answers
418
views
Restructure of Express CORS middleware for unit test
How should one break this component down to better perform unit test on its behaviors?
Issues:
Authentication middleware component makes external request.
Must recognize preflight and final flight. (...
4
votes
1
answer
132
views
One class unit-tests
Its my first attempt to unit-test in Js. Not yet TDD.
What I can change?
EventsPersistancyService.js:
...
5
votes
1
answer
3k
views
Unit Testing Express Middleware That Verifies Auth Tokens
I am writing an Express middleware component that'll run on Node 4, which has limited ES2015 support.
The fundamental purpose of this component is to verify JSON web tokens, using the jsonwebtoken ...
13
votes
1
answer
259
views
Generate a URL, shorten it, insert it in a tex file and compile those tex files
I have written a NodeJS module and its tests to generate a URL, shorten it with Bitly, insert the short link in a tex file, compile these tex files to PDF and then merge them into one.
The code is ...
5
votes
0
answers
1k
views
Mocking the file system within a test
I've been using this method to test file-system functions as an alternative to mock-fs due to its lack of symlink support. I'd love to hear what others think and ...
3
votes
2
answers
2k
views
Diamond kata in JavaScript
I'm just starting to learn JavaScript. I implemented the Diamond kata, and I would appreciate if anybody could give me some feedback. I'm particularly concerned about learning the most 'idiomatic' way ...