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
160
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
53
Ruby 2.7preview1
jimmynguyc
0
43
The Original Immortal Game
jimmynguyc
0
26
Introduction to Ruby Hyperloop
jimmynguyc
0
120
Introduction to Machine Learning with Tensorflow.rb
jimmynguyc
0
120
Ruby's JIT
jimmynguyc
2
69
TRICK 2015
jimmynguyc
0
84
Hacking Rails
jimmynguyc
0
56
TRICK
jimmynguyc
0
64
Other Decks in How-to & DIY
See All in How-to & DIY
スターバックスの黒板アートを生成AIで描かせてみたら...
scbc1167
0
220
ITエンジニアにおすすめのゲームFactorio御紹介
zembutsu
PRO
1
580
How to Start RP2040
kata0510
0
1.1k
俺とキャンプ
sat
PRO
1
210
Mini 4WD and Community
fukumay
0
640
今こそスマートハウス!
runrunsan
0
2.9k
LTのモチベーション
akrolayer
1
310
やがてカンファレンス登壇者になる
yumechi
1
170
ちょっと待てぃ!!ボタンをキーボード化 #M5Stack #M5JPTour2023 #相席食堂
n0bisuke2
0
410
にじさんじ格闘ゲーム制作プロジェクト
vfgpproject
0
7.1k
Last CoLab
yumechi
1
110
Chaos V-Ray Render Pool Manual [EN]
renderpool
0
180
Featured
See All Featured
Being A Developer After 40
akosma
56
580k
Large-scale JavaScript Application Architecture
addyosmani
503
110k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
6
990
Optimizing for Happiness
mojombo
369
69k
10 Git Anti Patterns You Should be Aware of
lemiorhan
645
57k
KATA
mclloyd
14
12k
Testing 201, or: Great Expectations
jmmastey
27
6.3k
Building a Scalable Design System with Sketch
lauravandoore
455
32k
Imperfection Machines: The Place of Print at Facebook
scottboms
258
12k
Stop Working from a Prison Cell
hatefulcrawdad
265
19k
Mobile First: as difficult as doing things right
swwweet
216
8.6k
The World Runs on Bad Software
bkeepers
PRO
61
6.7k
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