SlideShare a Scribd company logo
TDD
Node.js
SPOOKY

Programmer
DevOps
Team Leader
Java 6 years
Javascript 1.5 years



smlsun@facebook
trunk-studio.com
blog.trunk-studio.com
• Why we needTDD
• How to startTDD
• Conclusion
OUTLINE
TDD
• Programmer
•
•
• DevOps
•
•
•
• Team Leader
• Member
• Member
•
• Member
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
TEST
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
DeveloperQA
TEST SPEC
/
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
FAIL
Edge of Tomorrow
LEAN & AGILE
•
•
•
•
...
TDD
TEST CODE
TDD
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
XTEST vs OTEST
-4
-2
-60
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
TDD
NODEJS
Package

Library
Application
Server
LOGIN
• 3 step Login
INITIAL
var liftApp = async () => {
await models.sequelize.sync({
force: config.connection.force
});
await bootstrap();
app.listen(config.port);
return app;
}
if (env !== 'test') liftApp();
module.exports = liftApp
import chai from 'chai';
import request from 'supertest';
import sinon from 'sinon';
import liftApp from '../../server';
chai.should();
global.sinon = sinon;
before(async (done) => {
let app = await liftApp();
global.app = app;
global.request =
request.agent(app.listen());
done();
});
AP

start
test framework

start
SPECdescribe('auth login spec', () => {
before(async (done) => {
let testUser = {'username': 'test', 'password': 'test'}
await models.User.create(testUser);
done();
});
it('login should be success.', async (done) => {
let loginUserFormData = {
'username': ‘test',
'password': ‘test'
};
request.post(‘/auth/login')
.send(loginUserFormData).expect(200)
.end((error, res) => {
if (error) done(error);
let loginResult = res.body;
loginResult.success.should.be.true;
done();
})
}
• Mocha test framework
• Supertest API
• Should or Chai spec
MOCK


EX
API

OR
• sinon 

Mock
Source code
Mock code
Spec
SPEC
SA/SD


/
SPEC
CI / CD
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
–
“ ”
JSDC 2015 - TDD 的開發哲學,以 Node.js 為例
•
•
•
•
• from Clean Code
TDD
THANKS!
• http://qualitycoding.org/tdd-testimonial/
• http://gamesfromwithin.com/backwards-is-forward-
making-better-games-with-test-driven-development
• http://punnode.com/archives/18016
• http://teddy-chen-tw.blogspot.tw/2014/09/blog-
post_22.html

More Related Content

What's hot (20)

PPTX
Report portal
COMAQA.BY
 
PPTX
Володимир Дубенко "Node.js for desktop development (based on Electron library)"
Fwdays
 
PDF
Testing as a container
Irfan Ahmad
 
PDF
Drupal contrib module maintaining
Andrii Podanenko
 
PDF
CIbox - OpenSource solution for making your #devops better
Andrii Podanenko
 
PDF
DrupalCon Los Angeles - Continuous Integration Toolbox
Andrii Podanenko
 
PDF
[English][Test Girls] Zero to Hero: Start Test automation with Cypress
Test Girls
 
PDF
Супер быстрая автоматизация тестирования на iOS
SQALab
 
PDF
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
Gavin Pickin
 
PDF
Docker for Integration Testing
Wouter Danes
 
PDF
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
Fwdays
 
PPTX
Grooving with Jenkins
Anton Weiss
 
PDF
Ci For The Web 2.0 Guy Or Gal
Chad Woolley
 
PPT
Dockerizing BDD : Ruby-Cucumber Example
Shashikant Jagtap
 
PDF
Docker Best Practices Workshop
Ahmed AbouZaid
 
PPTX
MoldCamp - multidimentional testing workflow. CIBox.
Andrii Podanenko
 
PDF
Capybara testing
Futureworkz
 
PDF
Automate Thyself
Ortus Solutions, Corp
 
PPTX
Why you should switch to Cypress for modern web testing?
Shivam Bharadwaj
 
PPTX
Automated Testing with Cucumber, PhantomJS and Selenium
Dev9Com
 
Report portal
COMAQA.BY
 
Володимир Дубенко "Node.js for desktop development (based on Electron library)"
Fwdays
 
Testing as a container
Irfan Ahmad
 
Drupal contrib module maintaining
Andrii Podanenko
 
CIbox - OpenSource solution for making your #devops better
Andrii Podanenko
 
DrupalCon Los Angeles - Continuous Integration Toolbox
Andrii Podanenko
 
[English][Test Girls] Zero to Hero: Start Test automation with Cypress
Test Girls
 
Супер быстрая автоматизация тестирования на iOS
SQALab
 
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
Gavin Pickin
 
Docker for Integration Testing
Wouter Danes
 
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
Fwdays
 
Grooving with Jenkins
Anton Weiss
 
Ci For The Web 2.0 Guy Or Gal
Chad Woolley
 
Dockerizing BDD : Ruby-Cucumber Example
Shashikant Jagtap
 
Docker Best Practices Workshop
Ahmed AbouZaid
 
MoldCamp - multidimentional testing workflow. CIBox.
Andrii Podanenko
 
Capybara testing
Futureworkz
 
Automate Thyself
Ortus Solutions, Corp
 
Why you should switch to Cypress for modern web testing?
Shivam Bharadwaj
 
Automated Testing with Cucumber, PhantomJS and Selenium
Dev9Com
 

Similar to JSDC 2015 - TDD 的開發哲學,以 Node.js 為例 (20)

PPTX
Understanding TDD - theory, practice, techniques and tips.
Malinda Kapuruge
 
PDF
Fearless Coding with Test Driven Development
Roberto Allende
 
PPTX
How to write test in node.js
Jason Lin
 
PDF
An Introduction to the World of Testing for Front-End Developers
FITC
 
PDF
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
Haris Mahmood
 
PDF
Intro To JavaScript Unit Testing - Ran Mizrahi
Ran Mizrahi
 
PDF
BDD Testing and Automating from the trenches - Presented at Into The Box June...
Gavin Pickin
 
PDF
ITB2016 -BDD testing and automation from the trenches
Ortus Solutions, Corp
 
PPTX
REST API-LEVEL TDD With Nodejs
Dang Viet Ha (Tony)
 
PPTX
REST API level TDD with NodeJS
Dang Viet Ha (Tony)
 
PDF
Test box bdd
ColdFusionConference
 
PDF
How do I write testable javascript?
devObjective
 
PDF
How do I write Testable Javascript?
Gavin Pickin
 
PDF
How do I write Testable Javascript
ColdFusionConference
 
PPTX
Test Driven Development - a Practitioner’s Perspective
Malinda Kapuruge
 
PPTX
TDD in the wild
Brainhub
 
PDF
Testing Node.js.pdf
Ahmed Hassan
 
PDF
Adopting tdd in the workplace
Donny Wals
 
PDF
Adopting tdd in the workplace
Donny Wals
 
PDF
TDD super mondays-june-2014
Alex Kavanagh
 
Understanding TDD - theory, practice, techniques and tips.
Malinda Kapuruge
 
Fearless Coding with Test Driven Development
Roberto Allende
 
How to write test in node.js
Jason Lin
 
An Introduction to the World of Testing for Front-End Developers
FITC
 
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
Haris Mahmood
 
Intro To JavaScript Unit Testing - Ran Mizrahi
Ran Mizrahi
 
BDD Testing and Automating from the trenches - Presented at Into The Box June...
Gavin Pickin
 
ITB2016 -BDD testing and automation from the trenches
Ortus Solutions, Corp
 
REST API-LEVEL TDD With Nodejs
Dang Viet Ha (Tony)
 
REST API level TDD with NodeJS
Dang Viet Ha (Tony)
 
Test box bdd
ColdFusionConference
 
How do I write testable javascript?
devObjective
 
How do I write Testable Javascript?
Gavin Pickin
 
How do I write Testable Javascript
ColdFusionConference
 
Test Driven Development - a Practitioner’s Perspective
Malinda Kapuruge
 
TDD in the wild
Brainhub
 
Testing Node.js.pdf
Ahmed Hassan
 
Adopting tdd in the workplace
Donny Wals
 
Adopting tdd in the workplace
Donny Wals
 
TDD super mondays-june-2014
Alex Kavanagh
 
Ad

Recently uploaded (20)

PDF
Internet Governance and its role in Global economy presentation By Shreedeep ...
Shreedeep Rayamajhi
 
PDF
Apple_Environmental_Progress_Report_2025.pdf
yiukwong
 
PPT
introductio to computers by arthur janry
RamananMuthukrishnan
 
PDF
The-Hidden-Dangers-of-Skipping-Penetration-Testing.pdf.pdf
naksh4thra
 
PPTX
英国假毕业证诺森比亚大学成绩单GPA修改UNN学生卡网上可查学历成绩单
Taqyea
 
PPT
Agilent Optoelectronic Solutions for Mobile Application
andreashenniger2
 
PDF
𝐁𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓
hokimamad0
 
PPTX
一比一原版(SUNY-Albany毕业证)纽约州立大学奥尔巴尼分校毕业证如何办理
Taqyea
 
PDF
DevOps Design for different deployment options
henrymails
 
PPTX
unit 2_2 copy right fdrgfdgfai and sm.pptx
nepmithibai2024
 
PPTX
Optimization_Techniques_ML_Presentation.pptx
farispalayi
 
PPTX
Template Timeplan & Roadmap Product.pptx
ImeldaYulistya
 
PPTX
internet básico presentacion es una red global
70965857
 
PDF
Azure_DevOps introduction for CI/CD and Agile
henrymails
 
PDF
Web Hosting for Shopify WooCommerce etc.
Harry_Phoneix Harry_Phoneix
 
PDF
AI_MOD_1.pdf artificial intelligence notes
shreyarrce
 
PPT
Computer Securityyyyyyyy - Chapter 2.ppt
SolomonSB
 
PDF
Digital Security in 2025 with Adut Angelina
The ClarityDesk
 
PPTX
本科硕士学历佛罗里达大学毕业证(UF毕业证书)24小时在线办理
Taqyea
 
PPTX
PE introd.pptxfrgfgfdgfdgfgrtretrt44t444
nepmithibai2024
 
Internet Governance and its role in Global economy presentation By Shreedeep ...
Shreedeep Rayamajhi
 
Apple_Environmental_Progress_Report_2025.pdf
yiukwong
 
introductio to computers by arthur janry
RamananMuthukrishnan
 
The-Hidden-Dangers-of-Skipping-Penetration-Testing.pdf.pdf
naksh4thra
 
英国假毕业证诺森比亚大学成绩单GPA修改UNN学生卡网上可查学历成绩单
Taqyea
 
Agilent Optoelectronic Solutions for Mobile Application
andreashenniger2
 
𝐁𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓
hokimamad0
 
一比一原版(SUNY-Albany毕业证)纽约州立大学奥尔巴尼分校毕业证如何办理
Taqyea
 
DevOps Design for different deployment options
henrymails
 
unit 2_2 copy right fdrgfdgfai and sm.pptx
nepmithibai2024
 
Optimization_Techniques_ML_Presentation.pptx
farispalayi
 
Template Timeplan & Roadmap Product.pptx
ImeldaYulistya
 
internet básico presentacion es una red global
70965857
 
Azure_DevOps introduction for CI/CD and Agile
henrymails
 
Web Hosting for Shopify WooCommerce etc.
Harry_Phoneix Harry_Phoneix
 
AI_MOD_1.pdf artificial intelligence notes
shreyarrce
 
Computer Securityyyyyyyy - Chapter 2.ppt
SolomonSB
 
Digital Security in 2025 with Adut Angelina
The ClarityDesk
 
本科硕士学历佛罗里达大学毕业证(UF毕业证书)24小时在线办理
Taqyea
 
PE introd.pptxfrgfgfdgfdgfgrtretrt44t444
nepmithibai2024
 
Ad

JSDC 2015 - TDD 的開發哲學,以 Node.js 為例