SlideShare a Scribd company logo
Node.js
Testing
Popular > Community >
Development easier
Supertest
• Mocha: test framework

• Chai.js: BDD / TDD assertion library

• Supertest: testing HTTP servers
Example
var expect = require('chai').expect;
describe('Math', function() {
describe('#abs()', function() {
it('should return positive value of given negative number', function() {
expect(Math.abs(-5)).to.be.equal(5);
});
it('should return positive value of given positive number', function() {
expect(Math.abs(3)).to.be.equal(3);
});
it('should return 0 given 0', function() {
expect(Math.abs(0)).to.be.equal(0);
});
});
});
Example 2

More Related Content

PDF
Ragel talk
elliando dias
 
DOCX
Practica54
Mûzâmîl ßâlõch
 
PDF
Simon labs
Jorge Ramirez
 
PPTX
利用Init connect做mysql clients stat 用户审计
Dehua Yang
 
PDF
Spark Jobserver
Yegor Andreenko
 
PPTX
Ft10 de smet
nkaluva
 
PDF
Unit tests in node.js
Rotem Tamir
 
Ragel talk
elliando dias
 
Simon labs
Jorge Ramirez
 
利用Init connect做mysql clients stat 用户审计
Dehua Yang
 
Spark Jobserver
Yegor Andreenko
 
Ft10 de smet
nkaluva
 
Unit tests in node.js
Rotem Tamir
 

What's hot (10)

PDF
Valerii Vasylkov Erlang. measurements and benefits.
Аліна Шепшелей
 
PDF
TestR: generating unit tests for R internals
Roman Tsegelskyi
 
PDF
Is writing performant code too expensive?
Tomasz Kowalczewski
 
PDF
Check whether an Array is sorted or not
Ravi Ranjan
 
PDF
RSpec matchers
rupicon
 
PDF
power-assert, mechanism and philosophy
Takuto Wada
 
PDF
The Ring programming language version 1.7 book - Part 38 of 196
Mahmoud Samir Fayed
 
PPTX
Writing and using Hamcrest Matchers
Shai Yallin
 
PDF
The CppCat Analyzer Checks TortoiseGit
Andrey Karpov
 
Valerii Vasylkov Erlang. measurements and benefits.
Аліна Шепшелей
 
TestR: generating unit tests for R internals
Roman Tsegelskyi
 
Is writing performant code too expensive?
Tomasz Kowalczewski
 
Check whether an Array is sorted or not
Ravi Ranjan
 
RSpec matchers
rupicon
 
power-assert, mechanism and philosophy
Takuto Wada
 
The Ring programming language version 1.7 book - Part 38 of 196
Mahmoud Samir Fayed
 
Writing and using Hamcrest Matchers
Shai Yallin
 
The CppCat Analyzer Checks TortoiseGit
Andrey Karpov
 
Ad

Recently uploaded (20)

PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Ad

Node.js testing

  • 2. Popular > Community > Development easier
  • 4. • Mocha: test framework • Chai.js: BDD / TDD assertion library • Supertest: testing HTTP servers
  • 5. Example var expect = require('chai').expect; describe('Math', function() { describe('#abs()', function() { it('should return positive value of given negative number', function() { expect(Math.abs(-5)).to.be.equal(5); }); it('should return positive value of given positive number', function() { expect(Math.abs(3)).to.be.equal(3); }); it('should return 0 given 0', function() { expect(Math.abs(0)).to.be.equal(0); }); }); });