testing javascript apps with mocha and chai

Post on 22-Jun-2015

329 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

Testing code is very important and leads to more well-thought-out designs and more stable codebases. But how do we test javascript applications? Tools like Sinon.js, Mocha, and Chai can alleviate some of the pain as we try to bring testing benefits into our applications

TRANSCRIPT

1

CONFIDENTIAL

Andrew WinderSenior Software Engineer, Message Systems

Testing Javascript with Mocha and Friends

April 13, 2023

2

Why Testing?

3

What is a test?

expect(something).to.equal(something)

4

What is a test?

expect(something).to.equal(something)

The Subject

5

What is a test?

expect(something).to.equal(something)

The Assertion

6

What Kind of Testing?

7

How to test Javascript?

8

Simple Unit Testing

9

What about Async?

10

What about Async?

11

Mocking with Sinon & Proxyquire

• Use Mocks in unit testing for:• Stability• Speed• Accuracy

• Proxyquire for Mock Injection• Sinon for creating Mocks

12

Example of ProxyQuire & Sinon.JS

13

Demo & QuestionsTwitter: @awinder

andrew.winder@messagesystems.com

top related