Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Testing modern-day JavaScript Applications
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Remon Oldenbeuving
September 09, 2015
Programming
0
34
Testing modern-day JavaScript Applications
Remon Oldenbeuving
September 09, 2015
Tweet
Share
More Decks by Remon Oldenbeuving
See All by Remon Oldenbeuving
Groningen.rb RailsConf 2015 recap
rso
0
41
Other Decks in Programming
See All in Programming
Oxlint JS plugins
kazupon
1
740
なるべく楽してバックエンドに型をつけたい!(楽とは言ってない)
hibiki_cube
0
140
Patterns of Patterns
denyspoltorak
0
1.4k
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
200
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
380
Amazon Bedrockを活用したRAGの品質管理パイプライン構築
tosuri13
4
250
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
Basic Architectures
denyspoltorak
0
660
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
2
1.8k
今から始めるClaude Code超入門
448jp
7
8.4k
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
240
「ブロックテーマでは再現できない」は本当か?
inc2734
0
410
Featured
See All Featured
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
A better future with KSS
kneath
240
18k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
97
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
170
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.8k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
130
Building AI with AI
inesmontani
PRO
1
680
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
The Language of Interfaces
destraynor
162
26k
The Cult of Friendly URLs
andyhume
79
6.8k
The Cost Of JavaScript in 2023
addyosmani
55
9.5k
Transcript
Build for the web: Karma/Webpack
Build for the web: Karma/Webpack
Testing modern-day JavaScript applications
Who is I? Remon Oldenbeuving https://twitter.com/R51 https://github.com/RSO Software Engineer @
HackerOne
hackerone $ git log —reverse | head -6 commit 450099be9115481241edda6aec3968419ea39e2f
Author: Remon Oldenbeuving <
[email protected]
> Date: Fri Dec 14 03:29:34 2012 -0800 Initial commit
hackerone $ git log —reverse | head -6 commit 450099be9115481241edda6aec3968419ea39e2f
Author: Remon Oldenbeuving <
[email protected]
> Date: Fri Dec 14 03:29:34 2012 -0800 Initial commit
Who is I? Remon Oldenbeuving https://twitter.com/R51 https://github.com/RSO Software Engineer @
HackerOne
Testing modern-day JavaScript applications
“Writing frontend tests should be as obvious as writing backend
tests” Me, just now
hackerone $ bundle exec spec spec/integration ............................................. 5236 examples, 0
failures real 6m34.734s hackerone $ bundle exec teaspoon ............................................. 559 examples, 0 failures real 1m55.100s
None
Why? • Harder to write (good) JavaScript tests • Culture
• All objects defined in global scope • Slow (?)
None
Where we at? • Everything is defined on the window
• Mocha • SinonJS • ChaiJS • Teaspoon
Where do we want to go? • Modules (both internal
and external) • Split frontend from Rails • Sauce Labs
Modules • Browserify • Modular (haha) approach • Lots of
plugins • Webpack • Ability to bundle all assets
Mocking modules • A good way to scope your test
• Could help with keeping the DOM of the testsuite clean • But where to stop?
Mocking modules • Browserify: proxyquireify (WTF) # component.js var link
= require(‘link’); # component.test.js var proxyquire = require(‘proxyquireify’)(require); var stubs = { link: function() {} }; var component = proxyquire(‘component’, stubs);
Mocking modules • Webpack: rewire # component.js var link =
require(‘link’); # component.test.js var rewire = require(‘rewire’); var component = rewire(‘component’); component.__set__(‘link’, function() {});
Test runners • Zuul • Mocha • Karma • Jest
Test runners: Zuul
Test runners: Mocha • Test framework-gone-runner • Command line tool
runs tests in Node, requires JSDOM • No support for Sauce Labs • Too simple for what we need
Test runners: Karma • Created by the Angular team •
Modular • Big community
Test runners: Jest • Created by Facebook, used by React
• Automagic mocking of external dependencies • No choice in framework (Jasmine over Mocha) • Runs tests in parallel • Fake DOM (JSDOM) • No support for Sauce Labs
None
Karma/Webpack • Pro: • Probably the most mainstream approach •
Two powerful communities • Con: • Either run all tests all the times, or create a separate bundle for every test
Demo time?
Questions?