In this project I write the test for several functions and used the TDD with Jest and JavaScript.

Overview

JavaScript-Testing-with-Jest

npm init -y

npm install --save-dev jest

  • Once installed, you should see it in already created Json file

  • Change Jest Script to 'jest' // jest --coverage

  • 'npm run test' will fail since there are no test files yet

  • Create a file with the same name with an extension 'test.js'

    test('test name', () => { expect(false).toBe(false); });

    const User = require('./user')

    test('test name', () => { const user = new User() expect(user.greeting()).toBe("Hello"); });

    if(name) { return Hello ${name}; } else { return 'Hello Stranger'; }

    //can be optimized to: return "Hello" + (name || "Stranger");

    let user; beforeEach(() => { user = new User(); });

    Arrange | Act | Assert

    jest --watch-all

You might also like...

Reference for How to Write an Open Source JavaScript Library - https://egghead.io/series/how-to-write-an-open-source-javascript-library

Reference for How to Write an Open Source JavaScript Library The purpose of this document is to serve as a reference for: How to Write an Open Source

Dec 24, 2022

This is ongoing project and it will has plan for several co-workers and friends.

This is ongoing project and it will has plan for several co-workers and friends.

MERN: Full-stack Chat Application Introduction The MERN stack which consists of Mongo DB, Express.js, Node.js, and React.js is a popular stack for bui

Dec 3, 2022

This repository serves as a starter kit for doing simple TDD exercise

This repository serves as a starter kit for doing simple TDD exercise

Feb 19, 2022

A jest reporter that shows test running stats using the HUD macOS app.

jest-hud-reporter A jest reporter that shows test running stats using the HUD macOS app. hud-jest.mp4 Installation This package is available as a NPM

Feb 26, 2022

Custom Vitest matchers to test the state of the DOM, forked from jest-dom.

vitest-dom Custom Vitest matchers to test the state of the DOM This library is a fork of @testing-library/jest-dom. It shares that library's implement

Dec 16, 2022

Several custom made and legacy icons, and icons collected all over the internet in 1 set, UI selectable.

Several custom made and legacy icons, and icons collected all over the internet in 1 set, UI selectable.

Custom icon library Several custom made and legacy icons, and icons collected all over the internet in 1 set, UI selectable. Upon each Material Design

Dec 12, 2022

Claim $ARB airdrop of several wallets at the same time and transfer all the tokens to one address

arbitrum-airdrop-claimer Claim $ARB airdrop of several wallets at the same time and transfer all tokens to one address You need to have Node.js instal

Mar 21, 2023

Metaschool is a virtual school that includes a set of several existing schools in society.

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Jul 9, 2022

Solid Forms provides several form control objects useful for making working with forms easier.

Solid Forms Solid Forms provides several form control objects useful for making working with forms easier. Demos and examples below. # solidjs yarn ad

Jan 2, 2023
Owner
Ben Kiboma Omayio
Full-Stack Software Developer with a love for python (django) and JavaScript. I do road trip on my free time. Open to new opportunities
Ben Kiboma Omayio
Repositório do curso de TDD do Manguinho (Node + TS + SOLID + TDD + Clean Architecture)

Curso Rodrigo Manguinho - NodeJs, Typescript, TDD, DDD, Clean Architecture e SOLID Curso tem como objetivo aprender de verdade a criar uma API complet

Glaucia Lemos 4 Dec 15, 2022
Learn GraphQL by building a blogging engine. Create resolvers, write schemas, write queries, design the database, test and also deploy.

GraphQL Blog graphqlblog.com Learn GraphQL by building a blogging engine. Create resolvers, write schemas, write queries, design the database, test an

GraphQLApps 6 Aug 17, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
This project displays the art collection using the Metropolitan Museum of Art API. For this project we used HTML, CSS, Javascript, Webpack and Jest.

Metropolitan Museum of Art This project displays the art collection using the Metropolitan Museum of Art API. For this project we used HTML, CSS, Java

David Vera Castillo 11 Dec 24, 2022
🥾 A simple way to do testing AWS Services and Jest or Serverless and Jest

jest-localstack-preset Install Install via yarn or npm $ yarn add https://github.com/thadeu/jest-localstack-preset.git or $ npm i https://github.com/t

thadeu 5 Oct 1, 2022
Functions Recipes is a library of examples to help you getting started with Salesforce Functions and get used to their main features.

Functions Recipes Introduction Salesforce Functions lets you use the Salesforce Platform for building event-driven, elastically scalable apps and expe

Trailhead Apps 172 Dec 29, 2022
Project developed in typescript with clean architecture + tdd for demonstration purposes.

Description Project developed in typescript with clean architecture + tdd for demonstration purposes in Usystem. Installation $ yarn Running the app #

USystem - Desenvolvimento Ágil de Softwares 1 Oct 5, 2022
This is my to-do list website built with html, css and JavaScript. In this project I used Webpack to bundle JavaScript and ES6 modules to write modular JavaScript.

To-Do-List App This is my to-do list website built with html, css and JavaScript. In this project I used Webpack to bundle JavaScript and ES6 modules

Samuel Mwape 18 Sep 20, 2022