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
180
0
Share
How to reduce spec runtime by 4400%
How to monkey patch Capybara to avoid session reset
Jimmy Ngu
April 04, 2017
More Decks by Jimmy Ngu
See All by Jimmy Ngu
Ruby Runtime
jimmynguyc
0
72
Ruby 2.7preview1
jimmynguyc
0
53
The Original Immortal Game
jimmynguyc
0
45
Introduction to Ruby Hyperloop
jimmynguyc
0
130
Introduction to Machine Learning with Tensorflow.rb
jimmynguyc
0
130
Ruby's JIT
jimmynguyc
2
82
TRICK 2015
jimmynguyc
0
96
Hacking Rails
jimmynguyc
0
76
TRICK
jimmynguyc
0
77
Other Decks in How-to & DIY
See All in How-to & DIY
苦手の克服方法 / How to overcome weaknesses
toma_sm
0
390
JAWS-UG鹿児島2.0 reboot - JAWS-UG/AWS Communitiesのご紹介
awsjcpm
0
110
【ふりかえりワークショップ】Tryを決めるだけじゃない!感情にフォーカスした、ふりかえりを体験しよう!
scrummasudar
0
1.3k
私がカンファレンスのプロポーザルを書くときに考えていること
kotomin_m
1
740
フィールドエンジニア at 多摩川 / Field Engineer at Tamagawa
aokiplayer
0
220
家を建てて学ぶPjM
rinkei
0
140
Azure PortalのQoLを上げてたら Big Techに怒られた
horihiro
2
600
私の ダイエット トレーナー AIさんから 自己紹介が あります
itsukiisamu
0
110
Contributing to WPTV: A guide for WordPress TV Enthusiasts
ahmedabadwordpress
0
110
EmbeddingGemmaをDifyから使いたいけどAPI経由はつまらん #iotlt #gemma #dify
n0bisuke2
0
190
SoracomUG-Ishikawa-1.pdf
yukima77
0
210
Goカードゲームを 作ってみた!
senoue
0
250
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
225
10k
The Cost Of JavaScript in 2023
addyosmani
55
10k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.3k
Crafting Experiences
bethany
1
160
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
GitHub's CSS Performance
jonrohan
1033
470k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
390
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
160
Writing Fast Ruby
sferik
630
63k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
160
Testing 201, or: Great Expectations
jmmastey
46
8.2k
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