Slide 1

Slide 1 text

Javascript As A Programming Language

Slide 2

Slide 2 text

Javascript As A Programming Language Versioning, Test Driven Development & Continuous Integration IS

Slide 3

Slide 3 text

Javascript As A Programming Language Versioning, Test Driven Development & Continuous Integration IS

Slide 4

Slide 4 text

Hello, who’s speaking?

Slide 5

Slide 5 text

Hello, who’s speaking? Marco Cedaro @cedmax

Slide 6

Slide 6 text

They said I am a... Frontend Cowboy Nicola Vitto Jr. Javascript Pervert Roberto Felter Perfect Stranger basically anyone else Hello, who’s speaking? Marco Cedaro @cedmax

Slide 7

Slide 7 text

Actually I am: a Frontend Developer at Spreaker.com Hello, who’s speaking? Marco Cedaro @cedmax

Slide 8

Slide 8 text

Actually I am: a Frontend Developer at Spreaker.com a conference organizer with From The Front Hello, who’s speaking? Marco Cedaro @cedmax

Slide 9

Slide 9 text

Actually I am: a Frontend Developer at Spreaker.com a conference organizer with From The Front and a javascript pervert Hello, who’s speaking? Marco Cedaro @cedmax

Slide 10

Slide 10 text

Bologna, Italy

Slide 11

Slide 11 text

something in common with Robert Nyman

Slide 12

Slide 12 text

something in common with Robert Nyman

Slide 13

Slide 13 text

I believe I can fly

Slide 14

Slide 14 text

I believe I can fly

Slide 15

Slide 15 text

I believe I can fly Be brave. Take risks. Nothing can substitute experience. Paulo Coelho

Slide 16

Slide 16 text

once upon a time

Slide 17

Slide 17 text

we had no control once upon a time

Slide 18

Slide 18 text

we had no control javascript was the land of the brave once upon a time

Slide 19

Slide 19 text

we had no control javascript was the land of the brave we were fearless and unconscious once upon a time

Slide 20

Slide 20 text

we had no control javascript was the land of the brave we were fearless and unconscious we were proud of being like that once upon a time

Slide 21

Slide 21 text

just like them

Slide 22

Slide 22 text

kitty hawk

Slide 23

Slide 23 text

but life goes on

Slide 24

Slide 24 text

web engineer had a very bad opinion of us once upon a time

Slide 25

Slide 25 text

but it wasn't fair

Slide 26

Slide 26 text

we didn't have IDEs & tools they did but it wasn't fair

Slide 27

Slide 27 text

we didn't have IDEs & tools they did actually it was our own fault but it wasn't fair

Slide 28

Slide 28 text

we didn't have IDEs & tools they did actually it was our own fault we were not ready but it wasn't fair

Slide 29

Slide 29 text

we didn't have IDEs & tools they did actually it was our own fault we were not ready and javascript was neither but it wasn't fair

Slide 30

Slide 30 text

but, again, life goes on...

Slide 31

Slide 31 text

...and on...

Slide 32

Slide 32 text

and on..

Slide 33

Slide 33 text

it's not about the language itself

Slide 34

Slide 34 text

GREAT POWERS...

Slide 35

Slide 35 text

Frontend developers have to claim their role in development roadmap and business strategy

Slide 36

Slide 36 text

Javascript is a serious business

Slide 37

Slide 37 text

how serious?

Slide 38

Slide 38 text

something we can achieve less bandwidth and server load loading resources and content when needed

Slide 39

Slide 39 text

something we can achieve less bandwidth and server load loading resources and content when needed performance boosts that can lead to better conversion rates

Slide 40

Slide 40 text

something we can achieve less bandwidth and server load loading resources and content when needed performance boosts that can lead to better conversion rates cross platform development: less maintenance costs

Slide 41

Slide 41 text

less bandwidth and server load loading resources and content when needed performance boosts that can lead to better conversion rates cross platform development: less maintenance costs money

Slide 42

Slide 42 text

how serious?

Slide 43

Slide 43 text

this serious

Slide 44

Slide 44 text

what's missing?

Slide 45

Slide 45 text

what's missing?

Slide 46

Slide 46 text

what's missing? If I had nine of my fingers missing I wouldn't type any slower. Mitch Hedberg

Slide 47

Slide 47 text

IDEs & Tools

Slide 48

Slide 48 text

the attitude

Slide 49

Slide 49 text

a strategy

Slide 50

Slide 50 text

the small web agency The designer introduces a slider on some websites: ”it’s cool on apple store”. The developer gets a jQuery plugin online

Slide 51

Slide 51 text

the small web agency The designer introduces a slider on some websites: ”it’s cool on apple store”. The developer gets a jQuery plugin online Major release of the most used browser. A small fix has been released, they have to change 5 files in 5 different projects.

Slide 52

Slide 52 text

the small web agency The designer introduces a slider on some websites: ”it’s cool on apple store”. The developer gets a jQuery plugin online Major release of the most used browser. A small fix has been released, they have to change 5 files in 5 different projects. Oh damn! There’s no mouse wheel integration! should they ask for support or should they change the library by themself?

Slide 53

Slide 53 text

am I the only one or there’s something wrong?

Slide 54

Slide 54 text

the big corp The client-side architecture has been built on the most known and supported framework 2006

Slide 55

Slide 55 text

the big corp The client-side architecture has been built on the most known and supported framework 2006 Everything seems to be fine, except that the well known framework was being replaced by a powerful new one 2008 - 2010

Slide 56

Slide 56 text

the big corp The client-side architecture has been built on the most known and supported framework 2006 Everything seems to be fine, except that the well known framework was being replaced by a powerful new one 2008 - 2010 They were forced to change the whole codebase at once to reduce maintenance and development costs 2011

Slide 57

Slide 57 text

here we are again

Slide 58

Slide 58 text

attitude, strategy...

Slide 59

Slide 59 text

...and foresight

Slide 60

Slide 60 text

WARNING!

Slide 61

Slide 61 text

continuous integration

Slide 62

Slide 62 text

continuous integration

Slide 63

Slide 63 text

continuous integration A software development practice where members of a team integrate their work frequently [...] to detect integration errors as quickly as possible. Martin Fowler

Slide 64

Slide 64 text

I Build So Consistently

Slide 65

Slide 65 text

I Build So Consistently identify

Slide 66

Slide 66 text

I Build So Consistently identify write a build script

Slide 67

Slide 67 text

I Build So Consistently share identify write a build script

Slide 68

Slide 68 text

I Build So Consistently share identify write a build script make it continuous

Slide 69

Slide 69 text

How can we take advantages from a continuous integration process?

Slide 70

Slide 70 text

rationalize your workflow

Slide 71

Slide 71 text

deploy stable versions

Slide 72

Slide 72 text

Separate the codebase

Slide 73

Slide 73 text

unit test your code

Slide 74

Slide 74 text

basically

Slide 75

Slide 75 text

basically

Slide 76

Slide 76 text

basically ie7

Slide 77

Slide 77 text

choose your tools

Slide 78

Slide 78 text

choose your tools

Slide 79

Slide 79 text

choose your tools A man cannot be too careful in the choice of his enemies Oscar Wilde

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

JSHINT

Slide 82

Slide 82 text

a code quality tool

Slide 83

Slide 83 text

like Douglas Crockford's JSLint a code quality tool

Slide 84

Slide 84 text

like Douglas Crockford's JSLint but a code quality tool

Slide 85

Slide 85 text

like Douglas Crockford's JSLint but customizable a code quality tool

Slide 86

Slide 86 text

a tool for stupid?

Slide 87

Slide 87 text

JS HINT

Slide 88

Slide 88 text

JS TEST DRIVER JS HINT

Slide 89

Slide 89 text

once upon a time

Slide 90

Slide 90 text

jsTestDriver

Slide 91

Slide 91 text

jsTestDriver works from console

Slide 92

Slide 92 text

jsTestDriver works from console runs a server

Slide 93

Slide 93 text

jsTestDriver works from console runs a server opens browsers

Slide 94

Slide 94 text

jsTestDriver works from console runs a server opens browsers runs test suites

Slide 95

Slide 95 text

jsTestDriver works from console runs a server opens browsers runs test suites retrieves results in console

Slide 96

Slide 96 text

build server

Slide 97

Slide 97 text

build server

Slide 98

Slide 98 text

build server

Slide 99

Slide 99 text

how does testing works?

Slide 100

Slide 100 text

have you seen Lost?

Slide 101

Slide 101 text

how does it work?

Slide 102

Slide 102 text

how does it work? write a test

Slide 103

Slide 103 text

how does it work? write a test let it fail

Slide 104

Slide 104 text

how does it work? write a test let it fail write the code

Slide 105

Slide 105 text

how does it work? write a test let it fail write the code run the test again

Slide 106

Slide 106 text

how does it work? write a test let it fail write the code run the test again refactor

Slide 107

Slide 107 text

the environment

Slide 108

Slide 108 text

It's the browser, baby

Slide 109

Slide 109 text

It's the browser, baby

Slide 110

Slide 110 text

The curious case of Javascript unit testing Unit testing is supposed to test a single atomic “unit” of functionality without dependencies on anything else

Slide 111

Slide 111 text

The curious case of Javascript unit testing Unit testing is supposed to test a single atomic “unit” of functionality without dependencies on anything else This is where you start to run into serious dependency problems due to the interrelation with HTML and CSS

Slide 112

Slide 112 text

The curious case of Javascript unit testing Unit testing is supposed to test a single atomic “unit” of functionality without dependencies on anything else This is where you start to run into serious dependency problems due to the interrelation with HTML and CSS What do you test? Usually how the user interface responds to user input. Actually, the realm of functional testing

Slide 113

Slide 113 text

keep it real

Slide 114

Slide 114 text

keep it real

Slide 115

Slide 115 text

keep it real To all my homies working on the 9 to 5 Shaggy

Slide 116

Slide 116 text

#140bytes

Slide 117

Slide 117 text

I used to work with these guys

Slide 118

Slide 118 text

_$ = (function() { var registered = {}; return { ! ! pub: function(event, memo) { ! ! ! if (registered[event] instanceof Array){ ! ! ! ! var handlers = [].concat(registered[event]); ! ! ! ! for (var i=0, h; (h = handlers[i]); i++){ ! ! ! ! ! h.call(this, memo); ! ! ! ! } ! ! ! } ! ! }, ! ! sub: function(event, handler) { ! ! ! if (typeof registered[event] === "undefined"){ ! ! ! ! registered[event] = []; ! ! ! } ! ! ! registered[event].push(handler); ! ! } }; })();

Slide 119

Slide 119 text

_$ = (function() { var registered = {}; return { ! ! pub: function(event, memo) { ! ! ! if (registered[event] instanceof Array){ ! ! ! ! var handlers = [].concat(registered[event]); ! ! ! ! for (var i=0, h; (h = handlers[i]); i++){ ! ! ! ! ! h.call(this, memo); ! ! ! ! } ! ! ! } ! ! }, ! ! sub: function(event, handler) { ! ! ! if (typeof registered[event] === "undefined"){ ! ! ! ! registered[event] = []; ! ! ! } ! ! ! registered[event].push(handler); ! ! } }; })();

Slide 120

Slide 120 text

_$.sub("customEvent", function(obj) { ! //DO STUFF }); _$.pub("customEvent"); _$.pub("customEvent", { prop : "value" });

Slide 121

Slide 121 text

_$.sub("customEvent", function(obj) { ! //DO STUFF }); _$.pub("customEvent"); _$.pub("customEvent", { prop : "value" });

Slide 122

Slide 122 text

_$.sub("customEvent", function(obj) { ! //DO STUFF }); _$.pub("customEvent"); _$.pub("customEvent", { prop : "value" });

Slide 123

Slide 123 text

_$ = (function() { var registered = {}; return { ! ! pub: function(event, memo) { ! ! ! if (registered[event] instanceof Array){ ! ! ! ! var handlers = [].concat(registered[event]); ! ! ! ! for (var i=0, h; (h = handlers[i]); i++){ ! ! ! ! ! h.call(this, memo); ! ! ! ! } ! ! ! } ! ! }, ! ! sub: function(event, handler) { ! ! ! if (typeof registered[event] === "undefined"){ ! ! ! ! registered[event] = []; ! ! ! } ! ! ! registered[event].push(handler); ! ! } }; })();

Slide 124

Slide 124 text

_$ = (function (_) { ! return { ! ! pub: function(a, b, c, d) { ! ! ! for (d=-1, c=[].concat(_[a]); c[++d];) c[d](b) ! ! }, ! ! sub: function(a, b) { ! ! ! (_[a] || (_[a] = [])).push(b) ! ! } ! } })({})

Slide 125

Slide 125 text

_$ = (function (_) { ! return { ! ! pub: function(a, b, c, d) { ! ! ! for (d=-1, c=[].concat(_[a]); c[++d];) c[d](b) ! ! }, ! ! sub: function(a, b) { ! ! ! (_[a] || (_[a] = [])).push(b) ! ! } ! } })({}) #140bytes

Slide 126

Slide 126 text

_$ = (function() { var registered = {}; return { ! ! pub: function(event, memo) { ! ! ! if (registered[event] instanceof Array){ ! ! ! ! var handlers = [].concat(registered[event]); ! ! ! ! for (var i=0, h; (h = handlers[i]); i++){ ! ! ! ! ! h.call(this, memo); ! ! ! ! } ! ! ! } ! ! }, ! ! sub: function(event, handler) { ! ! ! if (typeof registered[event] === "undefined"){ ! ! ! ! registered[event] = []; ! ! ! } ! ! ! registered[event].push(handler); ! ! } }; })();

Slide 127

Slide 127 text

_$ = (function (_) { ! return { ! ! pub: function(a, b, c, d) { ! ! ! for (d=-1, c=[].concat(_[a]); c[++d];) c[d](b) ! ! }, ! ! sub: function(a, b) { ! ! ! (_[a] || (_[a] = [])).push(b) ! ! } ! } })({}) #140bytes

Slide 128

Slide 128 text

_$ = (function() { var registered = {}; return { ! ! pub: function(event, memo) { ! ! ! if (registered[event] instanceof Array){ ! ! ! ! var handlers = [].concat(registered[event]); ! ! ! ! for (var i=0, h; (h = handlers[i]); i++){ ! ! ! ! ! h.call(this, memo); ! ! ! ! } ! ! ! } ! ! }, ! ! sub: function(event, handler) { ! ! ! if (typeof registered[event] === "undefined"){ ! ! ! ! registered[event] = []; ! ! ! } ! ! ! registered[event].push(handler); ! ! } }; })();

Slide 129

Slide 129 text

_$ = (function (_) { ! return { ! ! pub: function(a, b, c, d) { ! ! ! for (d=-1, c=[].concat(_[a]); c[++d];) c[d](b) ! ! }, ! ! sub: function(a, b) { ! ! ! (_[a] || (_[a] = [])).push(b) ! ! } ! } })({}) #140bytes

Slide 130

Slide 130 text

_$ = (function (_) { ! return { ! ! pub: function(a, b, c, d) { ! ! ! for (d=-1, c=[].concat(_[a]); c[++d];) c[d](b) ! ! }, ! ! sub: function(a, b) { ! ! ! (_[a] || (_[a] = [])).push(b) ! ! } ! } })({}) #140bytes

Slide 131

Slide 131 text

[...] testPub: function(){! ! ! ! var a = 0;! ! ! _$.sub('testNotify', function(){ a = 1; }); ! ! _$.pub('testNotify'); ! ! assertEquals(1, a); ! }, ! ! ! ! testNotifyWithMemo: function(){!! ! ! var a = 0 ;! ! ! _$.sub('testNotify', function(memo){ ! ! ! ! a = memo.test; ! ! }); ! ! _$.pub('testNotify', {test: 1}); ! ! assertEquals(1, a); ! }, [...]

Slide 132

Slide 132 text

[...] testPub: function(){! ! ! ! var a = 0;! ! ! _$.sub('testNotify', function(){ a = 1; }); ! ! _$.pub('testNotify'); ! ! assertEquals(1, a); ! }, ! ! ! ! testNotifyWithMemo: function(){!! ! ! var a = 0 ;! ! ! _$.sub('testNotify', function(memo){ ! ! ! ! a = memo.test; ! ! }); ! ! _$.pub('testNotify', {test: 1}); ! ! assertEquals(1, a); ! }, [...]

Slide 133

Slide 133 text

[...] testPub: function(){! ! ! ! var a = 0;! ! ! _$.sub('testNotify', function(){ a = 1; }); ! ! _$.pub('testNotify'); ! ! assertEquals(1, a); ! }, ! ! ! ! testNotifyWithMemo: function(){!! ! ! var a = 0 ;! ! ! _$.sub('testNotify', function(memo){ ! ! ! ! a = memo.test; ! ! }); ! ! _$.pub('testNotify', {test: 1}); ! ! assertEquals(1, a); ! }, [...]

Slide 134

Slide 134 text

[...] testPub: function(){! ! ! ! var a = 0;! ! ! _$.sub('testNotify', function(){ a = 1; }); ! ! _$.pub('testNotify'); ! ! assertEquals(1, a); ! }, ! ! ! ! testNotifyWithMemo: function(){!! ! ! var a = 0 ;! ! ! _$.sub('testNotify', function(memo){ ! ! ! ! a = memo.test; ! ! }); ! ! _$.pub('testNotify', {test: 1}); ! ! assertEquals(1, a); ! }, [...]

Slide 135

Slide 135 text

[...] testPub: function(){! ! ! ! var a = 0;! ! ! _$.sub('testNotify', function(){ a = 1; }); ! ! _$.pub('testNotify'); ! ! assertEquals(1, a); ! }, ! ! ! ! testNotifyWithMemo: function(){!! ! ! var a = 0 ;! ! ! _$.sub('testNotify', function(memo){ ! ! ! ! a = memo.test; ! ! }); ! ! _$.pub('testNotify', {test: 1}); ! ! assertEquals(1, a); ! }, [...]

Slide 136

Slide 136 text

[...] testPub: function(){! ! ! ! var a = 0;! ! ! _$.sub('testNotify', function(){ a = 1; }); ! ! _$.pub('testNotify'); ! ! assertEquals(1, a); ! }, ! ! ! ! testNotifyWithMemo: function(){!! ! ! var a = 0 ; ! ! _$.sub('testNotify', function(memo){ ! ! ! ! a = memo.test; ! ! }); ! ! _$.pub('testNotify', {test: 1}); ! ! assertEquals(1, a); ! }, [...]

Slide 137

Slide 137 text

[...] testPub: function(){! ! ! ! var a = 0;! ! ! _$.sub('testNotify', function(){ a = 1; }); ! ! _$.pub('testNotify'); ! ! assertEquals(1, a); ! }, ! ! ! ! testNotifyWithMemo: function(){!! ! ! var a = 0 ;! ! ! _$.sub('testNotify', function(memo){ ! ! ! ! a = memo.test; ! ! }); ! ! _$.pub('testNotify', {test: 1}); ! ! assertEquals(1, a); ! }, [...]

Slide 138

Slide 138 text

easy, uh?

Slide 139

Slide 139 text

you will, eventually

Slide 140

Slide 140 text

JS TEST DRIVER JS HINT

Slide 141

Slide 141 text

JS TEST DRIVER SINON.JS JS HINT

Slide 142

Slide 142 text

a mock library

Slide 143

Slide 143 text

a mock library SPIES a function that records arguments, return value, the value of this and exception thrown (if any) for all its calls.

Slide 144

Slide 144 text

a mock library SPIES a function that records arguments, return value, the value of this and exception thrown (if any) for all its calls. STUBS functions (spies) with pre-programmed behavior.

Slide 145

Slide 145 text

a mock library SPIES a function that records arguments, return value, the value of this and exception thrown (if any) for all its calls. STUBS functions (spies) with pre-programmed behavior. MOCKS functions (spies) with pre-programmed behavior (stubs) as well as pre-programmed expectations.

Slide 146

Slide 146 text

[...] testMyLibRegistersToSystemOnEvent: function(){! ! ! ! var spy = sinon.spy(_$, 'watch');! ! ! //DO STUFF TO INIT YOUR LIB ! ! assertTrue(spy.calledWith('SysyemOn')); ! }, ! ! ! ! testMyLibLoggedNotLogged: function(){!! ! ! var stub = sinon.stub(User, 'isLogged');! ! ! stub.returns(true); ! ! //DO STUFF && ASSERTIONS ! ! stub.returns(false); ! ! //DO STUFF && ASSERTIONS ! }, [...]

Slide 147

Slide 147 text

[...] testMyLibRegistersToSystemOnEvent: function(){! ! ! ! var spy = sinon.spy(_$, 'watch');! ! ! //DO STUFF TO INIT YOUR LIB ! ! assertTrue(spy.calledWith('SystemOn')); ! }, ! ! ! ! testMyLibLoggedNotLogged: function(){!! ! ! var stub = sinon.stub(User, 'isLogged');! ! ! stub.returns(true); ! ! //DO STUFF && ASSERTIONS ! ! stub.returns(false); ! ! //DO STUFF && ASSERTIONS ! }, [...] SPY

Slide 148

Slide 148 text

[...] testMyLibRegistersToSystemOnEvent: function(){! ! ! ! var spy = sinon.spy(_$, 'watch');! ! ! //DO STUFF TO INIT YOUR LIB ! ! assertTrue(spy.calledWith('SystemOn')); ! }, ! ! ! ! testMyLibLoggedNotLogged: function(){!! ! ! var stub = sinon.stub(User, 'isLogged');! ! ! stub.returns(true); ! ! //DO STUFF && ASSERTIONS ! ! stub.returns(false); ! ! //DO STUFF && ASSERTIONS ! }, [...] SPY

Slide 149

Slide 149 text

[...] testMyLibRegistersToSystemOnEvent: function(){! ! ! ! var spy = sinon.spy(_$, 'watch');! ! ! //DO STUFF TO INIT YOUR LIB ! ! assertTrue(spy.calledWith('SystemOn')); ! }, ! ! ! ! testMyLibLoggedNotLogged: function(){!! ! ! var stub = sinon.stub(User, 'isLogged');! ! ! stub.returns(true); ! ! //DO STUFF && ASSERTIONS ! ! stub.returns(false); ! ! //DO STUFF && ASSERTIONS ! }, [...] SPY

Slide 150

Slide 150 text

[...] testMyLibRegistersToSystemOnEvent: function(){! ! ! ! var spy = sinon.spy(_$, 'watch');! ! ! //DO STUFF TO INIT YOUR LIB ! ! assertTrue(spy.calledWith('SystemOn')); ! }, ! ! ! ! testMyLibLoggedNotLogged: function(){!! ! ! var stub = sinon.stub(User, 'isLogged');! ! ! stub.returns(true); ! ! //DO STUFF && ASSERTIONS ! ! stub.returns(false); ! ! //DO STUFF && ASSERTIONS ! }, [...] SPY

Slide 151

Slide 151 text

[...] testMyLibRegistersToSystemOnEvent: function(){! ! ! ! var spy = sinon.spy(_$, 'watch');! ! ! //DO STUFF TO INIT YOUR LIB ! ! assertTrue(spy.calledWith('SystemOn')); ! }, ! ! ! ! testMyLibLoggedNotLogged: function(){!! ! ! var stub = sinon.stub(User, 'isLogged');! ! ! stub.returns(true); ! ! //DO STUFF && ASSERTIONS ! ! stub.returns(false); ! ! //DO STUFF && ASSERTIONS ! }, [...] STUB

Slide 152

Slide 152 text

[...] testMyLibRegistersToSystemOnEvent: function(){! ! ! ! var spy = sinon.spy(_$, 'watch');! ! ! //DO STUFF TO INIT YOUR LIB ! ! assertTrue(spy.calledWith('SystemOn')); ! }, ! ! ! ! testMyLibLoggedNotLogged: function(){!! ! ! var stub = sinon.stub(User, 'isLogged');! ! ! stub.returns(true); ! ! //DO STUFF && ASSERTIONS ! ! stub.returns(false); ! ! //DO STUFF && ASSERTIONS ! }, [...] STUB

Slide 153

Slide 153 text

[...] testMyLibRegistersToSystemOnEvent: function(){! ! ! ! var spy = sinon.spy(_$, 'watch');! ! ! //DO STUFF TO INIT YOUR LIB ! ! assertTrue(spy.calledWith('SystemOn')); ! }, ! ! ! ! testMyLibLoggedNotLogged: function(){!! ! ! var stub = sinon.stub(User, 'isLogged');! ! ! stub.returns(true); ! ! //DO STUFF && ASSERTIONS ! ! stub.returns(false); ! ! //DO STUFF && ASSERTIONS ! }, [...] STUB

Slide 154

Slide 154 text

[...] testMyLibRegistersToSystemOnEvent: function(){! ! ! ! var spy = sinon.spy(_$, 'watch');! ! ! //DO STUFF TO INIT YOUR LIB ! ! assertTrue(spy.calledWith('SystemOn')); ! }, ! ! ! ! testMyLibLoggedNotLogged: function(){!! ! ! var stub = sinon.stub(User, 'isLogged');! ! ! stub.returns(true); ! ! //DO STUFF && ASSERTIONS ! ! stub.returns(false); ! ! //DO STUFF && ASSERTIONS ! }, [...] STUB

Slide 155

Slide 155 text

[...] testMyLibRegistersToSystemOnEvent: function(){! ! ! ! var spy = sinon.spy(_$, 'watch');! ! ! //DO STUFF TO INIT YOUR LIB ! ! assertTrue(spy.calledWith('SystemOn')); ! }, [...] MOCK

Slide 156

Slide 156 text

[...] //testMyLibRegistersToSystemOnEvent: function(){! ! ! ! //var spy = sinon.spy(_$, 'watch');! ! ! //DO STUFF TO INIT YOUR LIB ! ! //assertTrue(spy.calledWith('SysyemOn')); ! //}, ! ! testMyLibRegistersToSystemOnEvent: function(){! ! ! ! var mock = sinon.mock(_$); ! ! mock.expect('watch').calledWith('SysyemOn'); ! ! //DO STUFF TO INIT YOUR LIB ! ! mock.verify(); ! }, [...] MOCK

Slide 157

Slide 157 text

[...] //testMyLibRegistersToSystemOnEvent: function(){! ! ! ! //var spy = sinon.spy(_$, 'watch');! ! ! //DO STUFF TO INIT YOUR LIB ! ! //assertTrue(spy.calledWith('SysyemOn')); ! //}, ! ! testMyLibRegistersToSystemOnEvent: function(){! ! ! ! var mock = sinon.mock(_$); ! ! mock.expect('watch').calledWith('SysyemOn'); ! ! //DO STUFF TO INIT YOUR LIB ! ! mock.verify(); ! }, [...] MOCK

Slide 158

Slide 158 text

[...] //testMyLibRegistersToSystemOnEvent: function(){! ! ! ! //var spy = sinon.spy(_$, 'watch');! ! ! //DO STUFF TO INIT YOUR LIB ! ! //assertTrue(spy.calledWith('SysyemOn')); ! //}, ! ! testMyLibRegistersToSystemOnEvent: function(){! ! ! ! var mock = sinon.mock(_$); ! ! mock.expect('watch').calledWith('SysyemOn'); ! ! //DO STUFF TO INIT YOUR LIB ! ! mock.verify(); ! }, [...] MOCK

Slide 159

Slide 159 text

[...] testOnSuccessCallback: function(){! ! var server = sinon.useFakeServer(); server.respondWith("GET", "/art/12/comments.json", [200, {"Content-Type":"application/json"}, "[{ id:12, text:'Hello'}]"]); ! ! var spy = sinon.spy(); ! ! myLib.getCommentsFor("/art/12", spy); ! ! server.respond(); ! ! assert(spy.calledWith([{ id:12, text:"Hello"}])); ! }, [...] AJAX CALL

Slide 160

Slide 160 text

[...] testOnSuccessCallback: function(){! ! var server = sinon.useFakeServer(); server.respondWith("GET", "/art/12/comments.json", [200, {"Content-Type":"application/json"}, "[{ id:12, text:'Hello'}]"]); ! ! var spy = sinon.spy(); ! ! myLib.getCommentsFor("/art/12", spy); ! ! server.respond(); ! ! assert(spy.calledWith([{ id:12, text:"Hello"}])); ! }, [...] AJAX CALL

Slide 161

Slide 161 text

[...] testOnSuccessCallback: function(){! ! var server = sinon.useFakeServer(); server.respondWith("GET", "/art/12/comments.json", [200, {"Content-Type":"application/json"}, "[{ id:12, text:'Hello'}]"]); ! ! var spy = sinon.spy(); ! ! myLib.getCommentsFor("/art/12", spy); ! ! server.respond(); ! ! assert(spy.calledWith([{ id:12, text:"Hello"}])); ! }, [...] AJAX CALL

Slide 162

Slide 162 text

[...] testOnSuccessCallback: function(){! ! var server = sinon.useFakeServer(); server.respondWith("GET", "/art/12/comments.json", [200, {"Content-Type":"application/json"}, "[{ id:12, text:'Hello'}]"]); ! ! var spy = sinon.spy(); ! ! myLib.getCommentsFor("/art/12", spy); ! ! server.respond(); ! ! assert(spy.calledWith([{ id:12, text:"Hello"}])); ! }, [...] AJAX CALL

Slide 163

Slide 163 text

[...] testOnSuccessCallback: function(){! ! var server = sinon.useFakeServer(); server.respondWith("GET", "/art/12/comments.json", [200, {"Content-Type":"application/json"}, "[{ id:12, text:'Hello'}]"]); ! ! var spy = sinon.spy(); ! ! myLib.getCommentsFor("/art/12", spy); ! ! server.respond(); ! ! assert(spy.calledWith([{ id:12, text:"Hello"}])); ! }, [...] AJAX CALL

Slide 164

Slide 164 text

[...] testOnSuccessCallback: function(){! ! var server = sinon.useFakeServer(); server.respondWith("GET", "/art/12/comments.json", [200, {"Content-Type":"application/json"}, "[{ id:12, text:'Hello'}]"]); ! ! var spy = sinon.spy(); ! ! myLib.getCommentsFor("/art/12", spy); ! ! server.respond(); ! ! assert(spy.calledWith([{ id:12, text:"Hello"}])); ! }, [...] AJAX CALL

Slide 165

Slide 165 text

[...] testOnSuccessCallback: function(){! ! var server = sinon.useFakeServer(); server.respondWith("GET", "/art/12/comments.json", [200, {"Content-Type":"application/json"}, "[{ id:12, text:'Hello'}]"]); ! ! var spy = sinon.spy(); ! ! myLib.getCommentsFor("/art/12", spy); ! ! server.respond(); ! ! assert(spy.calledWith([{ id:12, text:"Hello"}])); ! }, [...] AJAX CALL

Slide 166

Slide 166 text

[...] testOnSuccessCallback: function(){! ! var server = sinon.useFakeServer(); server.respondWith("GET", "/art/12/comments.json", [200, {"Content-Type":"application/json"}, "[{ id:12, text:'Hello'}]"]); ! ! var spy = sinon.spy(); ! ! myLib.getCommentsFor("/art/12", spy); ! ! server.respond(); ! ! assert(spy.calledWith([{ id:12, text:"Hello"}])); ! }, [...] AJAX CALL

Slide 167

Slide 167 text

[...] testOnSuccessCallback: function(){! ! var server = sinon.useFakeServer(); server.respondWith("GET", "/art/12/comments.json", [200, {"Content-Type":"application/json"}, "[{ id:12, text:'Hello'}]"]); ! ! var spy = sinon.spy(); ! ! myLib.getCommentsFor("/art/12", spy); ! ! server.respond(); ! ! assert(spy.calledWith([{ id:12, text:"Hello"}])); ! }, [...] AJAX CALL

Slide 168

Slide 168 text

[...] testOnSuccessCallback: function(){! ! var server = sinon.useFakeServer(); server.respondWith("GET", "/art/12/comments.json", [200, {"Content-Type":"application/json"}, "[{ id:12, text:'Hello'}]"]); ! ! var spy = sinon.spy(); ! ! myLib.getCommentsFor("/art/12", spy); ! ! server.respond(); ! ! assert(spy.calledWith([{ id:12, text:"Hello"}])); ! }, [...] AJAX CALL

Slide 169

Slide 169 text

[...] testOnSuccessCallback: function(){! ! var server = sinon.useFakeServer(); server.respondWith("GET", "/art/12/comments.json", [200, {"Content-Type":"application/json"}, "[{ id:12, text:'Hello'}]"]); ! ! var spy = sinon.spy(); ! ! myLib.getCommentsFor("/art/12", spy); ! ! server.respond(); ! ! assert(spy.calledWith([{ id:12, text:"Hello"}])); ! }, [...] AJAX CALL

Slide 170

Slide 170 text

JS TEST DRIVER SINON.JS JS HINT

Slide 171

Slide 171 text

JS TEST DRIVER SINON.JS JS HINT YUI COMPRESSOR

Slide 172

Slide 172 text

Everyone should be happy

Slide 173

Slide 173 text

in the wild

Slide 174

Slide 174 text

in the wild

Slide 175

Slide 175 text

IN THE WILD In the wild, there is no health care. Dwight Schrute (the office)

Slide 176

Slide 176 text

drawbacks at the beginning

Slide 177

Slide 177 text

cost of change

Slide 178

Slide 178 text

LOOKING FORWARD

Slide 179

Slide 179 text

LOOKING FORWARD

Slide 180

Slide 180 text

LOOKING FORWARD

Slide 181

Slide 181 text

LOOKING FORWARD

Slide 182

Slide 182 text

LOOKING FORWARD

Slide 183

Slide 183 text

the further we look at, the more control we need LOOKING FORWARD

Slide 184

Slide 184 text

the further we look at, the more control we need LOOKING FORWARD

Slide 185

Slide 185 text

the further we look at, the more control we need LOOKING FORWARD let's get ready

Slide 186

Slide 186 text

the further we look at, the more control we need LOOKING FORWARD let's get ready javascript is a programming language

Slide 187

Slide 187 text

the further we look at, the more control we need LOOKING FORWARD let's get ready javascript is a programming language javascript is a serious business.

Slide 188

Slide 188 text

the further we look at, the more control we need LOOKING FORWARD let's get ready javascript is a programming language javascript is a serious business. and, most of all...

Slide 189

Slide 189 text

javascript kicks asses

Slide 190

Slide 190 text

javascript kicks asses http://spkr8.com/t/8718 http://cedmax.com @cedmax any question?