MidwestJS – Minneapolis, MN – TDD



MidwestJS – Minneapolis, MN – TDD

0 0


midwestjs-review

A review of what I learned at midwestJS

On Github IlanaB / midwestjs-review

MidwestJS

Minneapolis, MN

Things that stood out

  • Frameworks
  • Seperation of HTML and Code Logic
  • Not everyone is excited about ES6

TDD

(test-driven development)

What is TDD?

Write a test that defines a new feature (or improvement) Write the minimum amount of code to make it pass Refactor the code

Why don't we do this?

https://s3.amazonaws.com/dailyjs/files/2014-survey-summary.pdf
  • Time and Estimation
  • Learning Curve
  • Company Culture

We SHOULD be writing tests

  • We want to stay competitive
  • We want to provide our clients with quality work
  • We have a lot of developers coming in and out of projects
  • We want to write better code

Types of Tests

  • Unit
  • Component Integration
  • Integration (Selenium)
  • Manual

Unit Testing Frameworks

  • Jasmine
  • Mocha
  • Karma
  • QUnit
  • Tape
  • Nodeunit

Let's see some examples...

Mocking

  • Spies
  • Stubs
  • Mocks

Considerations for Unit Testing

  • Encourages modular coding
  • Tests can act as documentation
  • Time considerations
  • Cost/benefit per test

Considerations for Integration Testing

  • Constant need for updates when UI changes
  • Flakiness of tests
  • Time to run tests
  • Cost/benefit per test

Test Driven Learning

Design a cash register drawer function that accepts purchase price as the first argument, payment as the second argument, and cash-in-drawer (cid) as the third argument.

cid is a 2d array listing available currency.

Return the string "Insufficient Funds" if cash-in-drawer is less than the change due. Return the string "Closed" if cash-in-drawer is equal to the change due.

Otherwise, return change in coin and bills, sorted in highest to lowest order.

Source

Sources

Readings

Thank you!

MidwestJS Minneapolis, MN