Skip to content

Commit 8ab384d

Browse files
committed
TIL Rails: RSpec Exclude Slow Tests
Capybara tests are slow especially if your app uses a lot of CSS and JS. To exclude capybara tests that running with Javascript, you can simply use ``` $ rspec -t ~js ``` You can also add it to your `rails_helper.rb` so that it will not run `js: true` or `slow: true` tests by default. ``` config.filter_run_excluding(:slow, :js) unless ENV['ALL'] ``` When you run `rspec` now, it will not run the test cases where `js: true` or `slow: true`. To run the full test, you can run `ALL=1 rspec`.
1 parent 4de56cf commit 8ab384d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

rails/rspec-exclude-slow-tests.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# RSpec Exclude Slow Tests
2+
3+
Capybara tests are slow especially if your app uses a lot of CSS and JS.
4+
5+
To exclude capybara tests that running with Javascript, you can simply use
6+
7+
```
8+
$ rspec -t ~js
9+
```
10+
11+
You can also add it to your `rails_helper.rb` so that it will not run `js: true` or `slow: true` tests by default.
12+
13+
```
14+
# rails_helper.rb
15+
config.filter_run_excluding(:slow, :js) unless ENV['ALL']
16+
```
17+
18+
When you run `rspec` now, it will not run the test cases where `js: true` or `slow: true`.
19+
To run the full test, you can run `ALL=1 rspec`.

0 commit comments

Comments
 (0)