Javascript & browsers have been for years a complex and unsafe environment for a web developer, now we have the right tools to gain control on what we are distributing in our web applications. During the workshop you will learn first-hand basic Javascript Test Driven Development practices including testing, refactoring and related agile practices such as continuous integration and pair programming.
presented at italian Back To The Front conference /w @sirLisko
2. Who are we?
Marco Cedaro Luca Lischetti
javascript pirate, arr 8-bit lover and super hero
Spreaker Frontend Developer (almost) Shazam Frontend Developer
3. Who are we?
Marco Cedaro Luca Lischetti
javascript pirate, arr 8-bit lover and super hero
Spreaker Frontend Developer (almost) Shazam Frontend Developer
The content of this workshop do not necessarily reflect the opinion of authors employers
4. Who are we?
Marco Cedaro Luca Lischetti
javascript pirate, arr 8-bit lover and super hero
Spreaker Frontend Developer (almost) Shazam Frontend Developer
The content of this workshop do not necessarily reflect the opinion of authors employers
Authors employers are not responsible in any way of authors bad coding and funny spoken english
16. Unit testing is
supposed to test a
single atomic “unit”
of functionality
without
dependencies on
anything else
17. Unit testing is
This is where you
supposed to test a
start to run into
single atomic “unit”
serious dependency
of functionality
problems due to the
without
interrelation HTML
dependencies on
and CSS
anything else
18. Unit testing is
This is where you What do you test?
supposed to test a
start to run into Usually how the user
single atomic “unit”
serious dependency interface responds
of functionality
problems due to the to user input.
without
interrelation HTML Actually, the realm of
dependencies on
and CSS functional testing
anything else
80. Spies
a function that
records arguments,
return value, the
value of this and
exception thrown (if
any) for all its calls.
81. Spies Stub
a function that functions (spies) with
records arguments, pre-programmed
return value, the behavior.
value of this and
exception thrown (if
any) for all its calls.
82. Spies Stub Mock
a function that functions (spies) with functions (spies) with
records arguments, pre-programmed pre-programmed
return value, the behavior. behavior (stubs) as
value of this and well as pre-
exception thrown (if programmed
any) for all its calls. expectations.
104. A simple modular event driven app
a javascript code highlighter with 3 components:
syntax highlighter
selected word highlighter
finder
105. First step - syntax
watch a SRC_LOADED event with the memo {file:'{{FILE_SRC}}'}
highlight (wrap in a span with the keyword itself as classname)
function => <span class="function">function</span>
var, if ... else, for, return, ...
notify SRC_READY with the memo {file:'{{EDITED_SRC}}'}
106. Second step - append
watch previous SRC_READY
create a div[id="src_container"] and fill it with the source
append to document
llisten dblclick event and notify SRC_HIGHLIGHT with this memo:
{keyword:'{{HIGHLIGHTED_WORD}}'}
manage the SRC_HIGHLIGHT notification
<span class="highlight">{{HIGHLIGHTED_KEYWORKD}}</span>
107. Third step - find
watch to SRC_READY
create a div[id=form] and append inside of it
input[type=text][id=search]
input[type=button][id=submitBtn][value=Search]
append the div to the document
on click on submit notify a SRC_HIGHLIGHT event with memo
{keyword:"{{SEARCHED_TEXT}}"}