狠狠撸

狠狠撸Share a Scribd company logo
JavaScript Testing—
Technically not a number…
Justin Obney, Front-End Dev
Gone are the days of old
Any application that can be
written in JavaScript, will be
written in JavaScript
-- Atwood’s
Law
JS is everywhere
That no one thinks they need to
actually learn how it works.
Looks like C or Java… How
hard could it be?
JavaScript is so
approachable
? The old way
? Frameworks
? The lies
? Where to start
? Tooling
? Who knows?
The Agenda
“Whenever you are tempted to
type something into a print
statement or a debugger
expression, write it as a test
instead.”
—Martin Fowler
When do I write a test?
Testing Frameworks
?A unit test is code that executes
part of your production code
with an expectation on the
result.
?Unit vs. Integration
?Mocking & Stubbing
?Vocabulary
But testing is 丑补谤诲…
But the DOM
Tooling
TEST’EM
I see you are on a Mac…
But what about Windows?
But does it scale?
In closing
Unit testing JS = SQLSat 324
Thank You
justinobney@gmail.com
twitter.com/justinobney
github.com/justinobney
apply@envoccareers.com

More Related Content

Unit testing JS = SQLSat 324

Editor's Notes

  1. Who am I Envoc .Net beginning now they pay me to write JavaScript The web is changing rapidly The good old days WEB FORMS: post a form let the server build 1/2 MB or html and then send it back to the client to change a radio button … Cue magic
  2. Some of you may still live there... Get out now… JavaScript on rise
  3. Atwood’s Law CodingHorror StackOverflow it runs everywhere The server Mobile apps TVs? PS4? Heard of the web.. it is here to stay.
  4. 0.1 + 0.2
  5. console.log has the nasty risk of introducing bugs all on its own. enter dev tools (`debugger;`)
  6. QUnit older, more support mocha can drop in any* assertion library jasmine headless browser support built in spies & mocks
  7. Vocabulary A unit test is code that executes part of your production code with an expectation on the result. Unit vs integration unit - should be able to trust they should all be green integration - sometimes fail due to circumstance/environment Mocking and stubbing Mocks - you expect to assert against value (1 per test) Stubs - fake calls out. can have many
  8. ----- Meeting Notes (4/8/14 20:43) ----- Gmail, Facebook, Twitter, Azure Management Portal Models, Controllers, Services, Smart Caching, DI -- All things that can live in the client now
  9. ----- Meeting Notes (4/8/14 20:48) ----- Most of the tooling you will find will run on NodeJS Node has made Windows a first class citizen. You can integrate it into most of your existing CI servers. The only thing stopping you is you.
  10. This is not library code. There is very little DOM manipulation going on here (SPA). This is application logic.