#jest #javascript #node #testingHow to run, ignore or skip Jest tests, suites and filesWhen debugging or writing units tests with Jest it can be useful to specify a single file or test to run or to exclude a specific failing test for the Jest run. This post goes how to skip and exclude a single test, a whole Jest test suite and a whole Jest test file using the CLI ...
#micro #node #javascript #SQLiteRecord analytics events with a Zeit "micro" + SQLite3 Node.js applicationmicro-analytics-events - A Node.js microservice to record analytics events to SQLite3 with Zeit’s “micro” In order to finally switch off Google Analytics, I need to replace my goal conversion tracking somehow. I’ve got pageview data using Simple Analytics ...
#jest #javascript #node #testingHow to run Jest tests sequentiallyBy default Jest runs tests in parallel with a “a worker pool of child processes that run tests” (Jest CLI docs). As per the Jest documentation, running tests in sequence (serially), can be helpful for debugging purposes and for test run performance reasons. ...
#javascript #nodeDetect if the current file/module is the entrypoint or import/require-d in Node.jsHow does one identify whether a JavaScript file is being run directly (node file.js) or it’s being import/require-d (require('./file') in another JS file). In Python the pattern leverages the __main__ property in modules like so: if __name__ == '__main__': # do some ...
#javascript #node #metaYarn Workspaces: monorepo management without Lerna for applications and coding examplesHow to use Yarn Workspaces to manage applications/coding examples. Lerna isn’t required when you don’t need the git diffing and versioning facilites. What’s more Yarn Workspaces are a great lightweight tool to get up and running faster for simple Node.js monore ...
#node #lunrjs #hugo #meta #javascriptAdd Search to a Hugo site with Lunr.js and Node.jsHugo “The world’s fastest framework for building websites” is a great option for JAMStack (JavaScript, APIs, prebuild Markup) sites. Lunr.js is “A bit like Solr, but much smaller and not as bright”, it’s a pure JavaScript implementation of a Solr-lik ...
#javascript #jest #testing #nodeJest ignore or exclude file/function/statement from test coverageIn computer science, test coverage is a measure used to describe the degree to which the source code of a program is executed when a particular test suite runs. Code coverage - Wikipedia Code coverage is usually used as a quality metric for software eg. “Our code has to have 80% ...
#node #serverless #javascript #automation #deploymentSuper-powered newsletter content with Pocket and Netlify LambdaAn example Netlify Lambda to fetch all “newsletter” posts from Pocket. Pocket is an application and web service for managing a reading list of articles from the Internet. It’s quite widely used and tightly integrated into the Firefox browser. I find that I use it extensive ...
#javascript #jest #node #Testing #dateMocking/stubbing the current Date in Jest testsThere are situations where new Date() or Date.now is used in application code. That code needs to be tested, and it’s always a struggle to remember how to mock/stub or spy on Date.now/new Date with Jest. This post goes through multiple approaches to mocking, stubbing and spying o ...
#javascript #node #jest #testing #MongoDBAvoiding recursion pitfalls: MongoDB nested query clause addition and removalA case-study on where recursion can be useful for enterprise Node.js applications and how to avoid its common pitfalls like RangeError: Maximum call stack size exceeded. The full repository for this post is on GitHub: github.com/HugoDF/mongo-query-clause-modification We’ll ...