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
How to reduce spec runtime by 4400%
Search
Jimmy Ngu
April 04, 2017
How-to & DIY
0
170
How to reduce spec runtime by 4400%
How to monkey patch Capybara to avoid session reset
Jimmy Ngu
April 04, 2017
Tweet
Share
More Decks by Jimmy Ngu
See All by Jimmy Ngu
Ruby Runtime
jimmynguyc
0
60
Ruby 2.7preview1
jimmynguyc
0
47
The Original Immortal Game
jimmynguyc
0
32
Introduction to Ruby Hyperloop
jimmynguyc
0
120
Introduction to Machine Learning with Tensorflow.rb
jimmynguyc
0
120
Ruby's JIT
jimmynguyc
2
75
TRICK 2015
jimmynguyc
0
90
Hacking Rails
jimmynguyc
0
66
TRICK
jimmynguyc
0
68
Other Decks in How-to & DIY
See All in How-to & DIY
静岡県のお相撲さん20240509/sumo_wrestler_from_shizuoka_prefecture_20240509
nicepapa_hirano
0
280
グローバルAWSユーザー コミュニティとJAWS-UG - JAWS FESTA 2024 in Hiroshima
awsjcpm
0
4.8k
わたしと技術コミュニティとキャリア
kotomin_m
2
1.7k
JAWS-UGから学んだコミュニティの成功要因 (Success Factors)
awsjcpm
5
500
中指立てたか判定IoT #iotlt #p5js
n0bisuke2
0
300
How to create better speaker proposals
logico_jp
2
900
【技術カンファレンス運営の裏側】Iwaken Lab 技術好き学生の近況報告 & ことみんさんに技術カンファレンス運営の裏側を聞いちゃう会
kotomin_m
5
1.7k
How to Hire a Driver for Long Distance Travel?
greaterservice
0
170
AWSコミュニティプログラムとJAWS-UGアップデート / JAWS-UG函館 勉強会 vol.14
awsjcpm
2
130
3ヶ月でできる! 探査機自作ゼミ教材自作入門
sksat
6
2.6k
The Definitive? Guide To Locally Organizing RubyKaigi
sylph01
6
1.5k
LT(Lightning Talk)のドキドキ感を共有する IoT ぼっとを作った話
scbc1167
1
220
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
328
39k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
22k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
181
54k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
50
5.5k
Typedesign – Prime Four
hannesfritz
42
2.7k
Writing Fast Ruby
sferik
628
62k
Bash Introduction
62gerente
613
210k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
2.9k
Speed Design
sergeychernyshev
32
1k
Build The Right Thing And Hit Your Dates
maggiecrowley
36
2.8k
Transcript
Reducing RSpec Runtime by 4400% by @jimmynguyc
• Engineering Team Lead @ RapidRiver (rrsoft.co) • Specialized in
Rails • Remote First Teams • We’re Hiring!! :D
Outline • What is RSpec • What are Feature Specs
• What are scriptable, headless browsers • Why is it so f**king slow • How I fixed it
RSpec
None
Feature Specs • Feature specs are high-level tests meant to
exercise slices of functionality through an application. They should drive the application only via its external interface, usually web pages.
None
• Pages are rendered • Javascript executed • CSS are
applied • Images are loaded
Headless & Scriptable Browser Engines
Browser Engines KHTML
Popular RSpec HSBE • capybara-webkit • poltergeist with PhantomJS
Why Poltergeist? • Both based on WebKit • Better UI
simulation (e.g. overlapping element prevent clicks) • Can raise JS errors as test errors (js_errors: true) • Easier to install (standalone executable vs qt5 dependencies)
Setup https://github.com/teampoltergeist/poltergeist
https://github.com/teampoltergeist/poltergeist
But …
None
https://github.com/teampoltergeist/poltergeist#memory-leak
None
https://discuss.circleci.com/t/timeout-more-than-120-minutes/640
Why Slow AF? https://circleci.com/docs/1.0/test-metadata/
None
https://github.com/benzittlau/junit-xml-parser DEMO
None
DEBUGGING
https://github.com/LRDesign/rspec-steps
None
https://github.com/teamcapybara/capybara/pull/419
So Let’s DIY
spec/support/capybara.rb
spec/rails_helper.rb
spec/my_spec.rb spec/rails_helper.rb
• change before(:each) to before(:all) • turn let() variables to
instance variables
THANKS