Multi-Environment Deployments with React

If you are using Create-React-App to scaffold your react application there is built in support for changing environment variables based on the NODE_ENV values, this is done by using .env files.  In short this process works by having a .env, .env.production, .env.development set of files.  When you run/build your application CRA will set the NODE_ENV value …

Continue reading Multi-Environment Deployments with React

Sinon Error: Attempted to wrap undefined property ‘XYZ as function

I ran into a fun little error recently when working on a ReactJs application.  In my application I was using SinonJs to setup some spies on a method, I wanted to capture the input arguments for verification.  However, when I ran my test I received the following error. Attempted to wrap undefined property handlOnAccountFilter as …

Continue reading Sinon Error: Attempted to wrap undefined property ‘XYZ as function

Ensuring componentDidMount is not called in Unit Tests

If you are building a ReactJs you will often times implement componentDidMount on your components.  This is very handy at runtime, but can pose an issue for unit tests. If you are building tests for your React app you are very likely using enzyme to create instances of your component.  The issue is that when enzyme creates …

Continue reading Ensuring componentDidMount is not called in Unit Tests

Using Manual Mocks to test the AWS SDK with Jest

Anytime you build Node applications it is highly suggested that your cover your code with tests.  When your code interacts with 3rd party API's such as AWS you will most certainly want to mock/stub your calls in order to prevent external calls (if you actually want to do external calls, these are called integration tests …

Continue reading Using Manual Mocks to test the AWS SDK with Jest

Configure Visual Studio Code to debug Jest Tests

If you have not given Visual Studio Code a spin you really should, especially if  you are doing web/javascript/Node development. One super awesome feature of VS Code is the ability to easily configure the ability to debug your Jest (should work just fine with other JavaScript testing frameworks) tests.  I have found that most of …

Continue reading Configure Visual Studio Code to debug Jest Tests

Going Async with Node AWS SDK with Express

When building applications in Node/Express you will quickly come to realize that everything is done asynchronously . But how you accomplish these tasks async can vary.  The 'old school' way was to use call backs, which often led to callback hell.  Than came along Promises which we thought was going to solve all the worlds problems, turned out they helped, but did not solve everything.  Finally in Node 8.0 (ok, you could use them in Node 7.6) the support for async/await was introduced and this really has cleaned up and enhanced the readability of your code.