tdc 2016 floripa - testando apis rest com supertest e promises

20
Globalcode – Open4education Testando APIs REST com Supertest e Promises Stefan Teixeira [email protected] / stefanteixeira.com.br

Upload: stefan-teixeira

Post on 10-Feb-2017

398 views

Category:

Software


3 download

TRANSCRIPT

Page 1: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

Globalcode – Open4education

Testando APIs REST com Supertest e Promises

Stefan [email protected] / stefanteixeira.com.br

Page 2: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

• QA Automation Engineer • Entusiasta de Automação de Testes, Agile Testing e DevOps • Blogs técnicos: stefanteixeira.com.br (pt-br) /

stefanteixeira.com (en)

Contatos: • E-mail: [email protected] • Twitter: twitter.com/stefan_teixeira • LinkedIn: linkedin.com/in/stefanteixeira • GitHub: github.com/stefanteixeira • SlideShare: slideshare.net/stefanteixeira

Sobre

Page 3: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

Vocês testam suas APIs REST?

Page 4: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

Testando APIs REST

Page 5: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

Qual lib usar?

Page 6: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

Qual lib usar?

Page 7: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

Qual lib usar?

Page 8: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

Supertest

• Criado pelo TJ Holowaychuk

https://www.npmjs.com/package/supertest | https://github.com/visionmedia/supertest

Page 9: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

Supertest

• Criado pelo TJ Holowaychuk

• MUITO simples

https://www.npmjs.com/package/supertest | https://github.com/visionmedia/supertest

Page 10: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

Supertest

• Criado pelo TJ Holowaychuk

• MUITO simples

• Independente de runner (Jasmine, Mocha, etc)

https://www.npmjs.com/package/supertest | https://github.com/visionmedia/supertest

Page 11: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

Exemplos

Page 12: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

GET

Page 13: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

POST

Page 14: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

E com testes mais complexos?

Page 15: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

Callback Hell 🔥

Page 16: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

Promises!

Page 17: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

supertest-as-promised

https://www.npmjs.com/package/supertest-as-promised https://github.com/WhoopInc/supertest-as-promised

Page 18: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

E o teste com Promises?

Page 19: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

Projeto de exemplo

https://github.com/stefanteixeira/demo-supertest

Page 20: TDC 2016 Floripa - Testando APIs REST com Supertest e Promises

Globalcode – Open4education

Stefan Teixeira @stefan_teixeira

[email protected] stefanteixeira.com.br

stefanteixeira.com

Obrigado!