#Express #node #jest #Testing #javascriptA testing guide for Express with request and response mocking/stubbing using Jest or sinonTo test an Express handler, it’s useful to know how to successfully mock/stub the request and response objects. The following examples will be written both using Jest and sinon (running in AVA). The rationale for this is the following. Jest is a very popular “all-in-one” testing ...
#Express #node #javascript #deploymentNode.js configuration management without config or dotenvThe config npm package is great (npmjs.com/package/config), but it encourages confusing and non-12-factor-app-compliant patterns. We’ll look at some of the patterns it encourages and why they’ll bring you struggles down the road as well a simple, single-file, no-dependency way to ...
#javascript #nodeAsync JavaScript: history, patterns and gotchasA look at the history, patterns and gotchas of asynchronous operations in JavaScript. We’ll go through the pros and cons of callbacks, Promises and async/await. Present some pitfalls to bear in mind as well as introducing how you would deal with certain situations. Live-cod ...
#Sequelize #Express #javascript #nodeSequelize Data Types: a practical guideDataTypes are core to the Sequelize 4 library. This is a practical and complete guide to make up for the sparse Sequelize official documentation on the subject. First of all, DataTypes contains both the types and generators for default values: eg. NOW, UUIDV1 and UUIDV4 are speci ...
#javascript #vuejs #nodePost Frequency: from prototype to production with Vue + NodeIf you want to ship, use the tools you know. — A lot of people Let’s apply that principle: I’m building Post Frequency/Accountable Blogging, I’m familiar with Vue and Node-based backends. Netlify makes frontend deployments trivial and I’ve settled on Dokku for ...
#node #javascript #meta #gitA simple JavaScript/Node coding setup on Mac OS XHere’s how I get productive for JavaScript/Node on Mac OS. It includes iTerm2, zsh, Node, Visual Studio Code and some git commands. ...
#node #sequelize #git #cli #javascriptProgress and roadblocks: a journey into open-sourceEnhancing generators for ES6 in the Sequelize CLI This is the story of my discovery of ES6-class style model definitions with Sequelize (see Using ES6 classes for Sequelize 4 models). The realisation that the current Sequelize CLI model generator didn’t support it (as is e ...
#micro #node #javascript #es6 #architectureSimple, but not too simple: how using Zeit’s `micro` improves your Node applicationsLeave the Express comfort zone to expand how you think about Node application architecture. tl;dr using a function composition model for building HTTP servers is awesome Functions as a Service are great but have some drawbacks micro has a similar, simple API to FaaS but doesn&rs ...
#node #javascript #es6Use ES modules/ES6 import in Node without Babel/Webpack using `esm`Node has been implementing more and more ES6+ (ESNext) features natively. One of the features that is taking the longest to implement is modules. The reason for this is that Node and npm run on what is called CommonJS, with which you use require('module-name') to import from othe ...
#node #jest #testing #javascript #SequelizeMocking/stubbing ES6 classes in tests with examples of Sequelize model unit testsThis post goes through some patterns that can be used to unit test ES6 classes. The examples will use Jest module auto-mocking but should be portable to other module mocking libraries (eg. Proxyquire) with some modifications. In “Using ES6 classes for Sequelize 4 models&rdq ...