Testing Non-Exported Functions in JavaScript

Testing Non-Exported Functions in JavaScript

Recently, I finally integrated unit testing into my startup project. I’ve settled with Jest, I’ll speak more about this in a separate journal entry. While writing my test, I ran into a bit of a dilemma of trying to write unit tests for non-exported functions 😖

Recently, I finally integrated unit testing into my startup project. I’ve settled with Jest, I’ll speak more about this in a separate journal entry. While writing my test, I ran into a bit of a dilemma of trying to write unit tests for non-exported functions 😖

Testing Exported Function

It’s super straightforward to test exported functions.

// utils.js
export function sayHi() {
  return '👋';
}

And a unit test could be something like this:

// utils.test.js

import { sayHi } from './utils.js';
describe('sayHi', () => {
  it('returns wave emoji', () => {
    expect(sayHi()).toBe('👋');
  });
});

testing startup javascript vuejs front-end-development

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Hire Dedicated VueJS Developers

Want to Hire VueJS Developer to develop an amazing app? **[Hire Dedicated VueJS Developers](https://hourlydeveloper.io/hire-dedicated-vue-js-developer/ "Hire Dedicated VueJS Developers")** on the contract (time/project) basis providing regular...

Tips for Better Front End Testing Quality

Front end testing is an important part of the software development lifecycle. According to research, 80% of the overall performance of a web application is dependent on the client-side code. If we are able to solve most of the problems in the front end, then we can cover most of the problems in a web application overall.

How to Master the Front-End Development

Learn how to focus your skills to become a master at front-end development. How to Master the Front-End Development. A few years back doing front-end work, especially on the web, was rather simple compared to the back-end where all the app logic used to reside. Nowadays, that has changed. Front-end development has evolved thanks to powerful frameworks and libraries supported by the evolution of the browsers and their respective APIs.

Top 6 Productivity Tools for Front-end Developers

Today I wanted to share with you the tools I daily use to increase my productivity as a front-end developer. 6 tools to increase your productivity as a Front-end developer.

Front-End Architecture: Tests

Before starting, it is important to remember the existence of a universe of Formatters and Linters, but I prefer to leave them for an article on standards, where we can talk about the choices that are the reason for which linters exists: reinforce patterns, either by convention, security or whatever technical reasons.