capybara-dommy 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +47 -0
- data/lib/capybara/dommy/configuration.rb +6 -1
- data/lib/capybara/dommy/driver.rb +29 -1
- data/lib/capybara/dommy/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 79e1b015c05f0dea6b8e6d1081f023347ba49f5d6fa5ff0a1bad242116948596
|
|
4
|
+
data.tar.gz: a07065688fbaf41ed4661f5d3872021342310ec018a4d82d7001a1245288b679
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 609dbbccf830c63bf7122c7410380695ef7ca03c50eef1a623029585feabea5e3d5f5ee91811c33dcdae2ccdf13e4e85d3945689d20c9eec36e208eeec030532
|
|
7
|
+
data.tar.gz: 47f7ec672ceda6bb2c9cfa35b104ed9238f7479459270689902b0e753da9e03c456adc5b0f46399aba8b1e5c494d648934edd415030b250509a35ea1b2b28582
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.13.0 — 2026-09-23
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `Capybara::Dommy.configuration.raise_js_errors` (default `true`) fails an example on JavaScript the page left unhandled, at the next Capybara command, the way Capybara's own `raise_server_errors` fails one on a server exception. It affects only a `javascript: true` driver.
|
|
8
|
+
- `page.driver.allow_js_errors { ... }` suppresses that failure for a block.
|
|
9
|
+
- README: a "How this differs from a browser driver" section.
|
|
10
|
+
|
|
11
|
+
## 0.12.0 — 2026-09-22
|
|
12
|
+
|
|
13
|
+
Versioned in lockstep with [`dommy`](https://github.com/takahashim/dommy) 0.12.0.
|
|
14
|
+
No functional changes to capybara-dommy itself.
|
|
15
|
+
|
|
3
16
|
## 0.11.0 — 2026-09-11
|
|
4
17
|
|
|
5
18
|
### Added
|
data/README.md
CHANGED
|
@@ -46,6 +46,49 @@ By default, `execute_script`, `evaluate_script`, and
|
|
|
46
46
|
turn those calls into no-ops with configuration when migrating tests that call
|
|
47
47
|
JavaScript helpers incidentally.
|
|
48
48
|
|
|
49
|
+
## How this differs from a browser driver
|
|
50
|
+
|
|
51
|
+
Specs written against `capybara-dommy` use the ordinary Capybara DSL, so most
|
|
52
|
+
of them read the same as they would under selenium or cuprite. A few behaviours
|
|
53
|
+
underneath are genuinely different, and they are the ones worth knowing before
|
|
54
|
+
you port a suite.
|
|
55
|
+
|
|
56
|
+
**JavaScript errors fail the example.** A `javascript: true` driver fails on
|
|
57
|
+
anything the page's JavaScript left unhandled, at the next Capybara command, the
|
|
58
|
+
way Capybara's own `raise_server_errors` fails on a server exception. "Unhandled"
|
|
59
|
+
is the page's verdict: an error it cancels in `window.onerror` or in an
|
|
60
|
+
`unhandledrejection` listener never reaches the log, exactly as it never reaches
|
|
61
|
+
a browser console. A real browser driver reports nothing here, so this catches
|
|
62
|
+
breakage those drivers let through — usually a Dommy API the page needs and
|
|
63
|
+
Dommy does not implement yet. Turn it off with
|
|
64
|
+
`config.raise_js_errors = false`, or suppress it for one block with
|
|
65
|
+
`page.driver.allow_js_errors { ... }`.
|
|
66
|
+
|
|
67
|
+
**There are two clocks.** Dommy's timers run on a virtual clock that Capybara's
|
|
68
|
+
retry loop advances a frame at a time, so a debounce or a `setTimeout` resolves
|
|
69
|
+
in a few polls rather than in real time. Nothing advances it outside that loop:
|
|
70
|
+
`sleep` does not, and Rails' `travel_to` does not reach JavaScript's `Date`.
|
|
71
|
+
|
|
72
|
+
**The app runs in the test process.** There is no server thread and no port, so
|
|
73
|
+
`use_transactional_tests` works unchanged and an exception in the app is raised
|
|
74
|
+
directly in the test. In exchange, `Capybara.server` and anything built on a
|
|
75
|
+
separate app thread has no meaning here.
|
|
76
|
+
|
|
77
|
+
**There is no layout.** Visibility comes from HTML-level rules and stylesheet
|
|
78
|
+
`display` / `visibility` / `opacity`, never from geometry, so `obscured?`,
|
|
79
|
+
scroll position and element size are unavailable.
|
|
80
|
+
|
|
81
|
+
**Input is synthesised.** Events are dispatched from Ruby rather than by the OS,
|
|
82
|
+
so `isTrusted` is false and hover, drag and special keys are limited. An
|
|
83
|
+
unanswered `confirm` returns false rather than blocking.
|
|
84
|
+
|
|
85
|
+
**Frames are fetched, not live.** Switching to a frame re-requests its URL; the
|
|
86
|
+
frame's own scripts do not run.
|
|
87
|
+
|
|
88
|
+
**Failure artifacts are different.** `save_screenshot` raises (there is nothing
|
|
89
|
+
to paint). A failing example writes the page HTML and a trace bundle instead,
|
|
90
|
+
which `dommy-rails` wires up automatically.
|
|
91
|
+
|
|
49
92
|
## Installation
|
|
50
93
|
|
|
51
94
|
Add the gem to your application's Gemfile:
|
|
@@ -121,6 +164,7 @@ Capybara::Dommy.configure do |config|
|
|
|
121
164
|
config.max_redirects = 5
|
|
122
165
|
config.visibility = :html
|
|
123
166
|
config.raise_on_unsupported_js = true
|
|
167
|
+
config.raise_js_errors = true
|
|
124
168
|
end
|
|
125
169
|
```
|
|
126
170
|
|
|
@@ -136,6 +180,9 @@ Available options:
|
|
|
136
180
|
visible.
|
|
137
181
|
- `raise_on_unsupported_js`: when `true`, JavaScript methods raise
|
|
138
182
|
`Capybara::NotSupportedByDriverError`; when `false`, they return `nil`.
|
|
183
|
+
- `raise_js_errors`: when `true` (the default), a `javascript: true` driver
|
|
184
|
+
fails the example on JavaScript the page left unhandled. Has no effect on a
|
|
185
|
+
driver that runs no JavaScript. See "How this differs from a browser driver".
|
|
139
186
|
|
|
140
187
|
You can also override driver options per registration:
|
|
141
188
|
|
|
@@ -6,7 +6,7 @@ module Capybara
|
|
|
6
6
|
# when a keyword argument is omitted.
|
|
7
7
|
class Configuration
|
|
8
8
|
attr_accessor :default_host, :follow_redirects, :max_redirects, :visibility,
|
|
9
|
-
:raise_on_unsupported_js, :javascript
|
|
9
|
+
:raise_on_unsupported_js, :javascript, :raise_js_errors
|
|
10
10
|
|
|
11
11
|
def initialize
|
|
12
12
|
@default_host = "http://example.org"
|
|
@@ -15,6 +15,11 @@ module Capybara
|
|
|
15
15
|
@visibility = :html
|
|
16
16
|
@raise_on_unsupported_js = true
|
|
17
17
|
@javascript = false
|
|
18
|
+
# Fail an example on JavaScript the page left unhandled, the way
|
|
19
|
+
# Capybara's own raise_server_errors fails one on a server exception.
|
|
20
|
+
# Only a `javascript: true` driver has any JS to fail on, so this is
|
|
21
|
+
# invisible to a suite migrating from rack_test.
|
|
22
|
+
@raise_js_errors = true
|
|
18
23
|
end
|
|
19
24
|
end
|
|
20
25
|
|
|
@@ -49,7 +49,15 @@ module Capybara
|
|
|
49
49
|
# hosts (e.g. app_host / multi-server specs), so don't enforce origin.
|
|
50
50
|
enforce_same_origin: false
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
if @javascript
|
|
53
|
+
@session_options[:javascript] = true
|
|
54
|
+
# Everything Capybara does reaches the session through a checkpoint
|
|
55
|
+
# already — a query pumps the clock, a node interaction drains, and
|
|
56
|
+
# reset! disposes — so strictness needs no driver-side checks, just
|
|
57
|
+
# this flag. A JS error then surfaces at the next Capybara command,
|
|
58
|
+
# like a server error under raise_server_errors.
|
|
59
|
+
@session_options[:strict_js_errors] = config.raise_js_errors
|
|
60
|
+
end
|
|
53
61
|
# A JS session needs the virtual clock pumped inside Capybara's
|
|
54
62
|
# synchronize loop, so waiting expectations converge on timer/fetch
|
|
55
63
|
# driven updates. A host-installed pump (the documented seam) wins.
|
|
@@ -69,6 +77,17 @@ module Capybara
|
|
|
69
77
|
nil
|
|
70
78
|
end
|
|
71
79
|
|
|
80
|
+
# Suppress strict-mode failure for JS errors raised inside the block, for
|
|
81
|
+
# a spec that triggers one deliberately. Reaching for `page.driver` is the
|
|
82
|
+
# documented exception to keeping specs driver-agnostic: suppressing an
|
|
83
|
+
# error is inherently driver-specific. A page that handles its own errors
|
|
84
|
+
# (`window.onerror` + preventDefault) needs nothing here.
|
|
85
|
+
def allow_js_errors(&block)
|
|
86
|
+
return yield unless @javascript
|
|
87
|
+
|
|
88
|
+
rack_session.allow_js_errors(&block)
|
|
89
|
+
end
|
|
90
|
+
|
|
72
91
|
# The dommy-rack session. Named `rack_session` to avoid colliding with
|
|
73
92
|
# Capybara::Driver::Base#session (the owning Capybara::Session). Rebuilt
|
|
74
93
|
# when the effective host (Capybara app_host / default_host) changes so
|
|
@@ -273,8 +292,17 @@ module Capybara
|
|
|
273
292
|
|
|
274
293
|
private
|
|
275
294
|
|
|
295
|
+
# Advance the virtual clock a slice inside Capybara's retry loop, then
|
|
296
|
+
# report whatever the page's JavaScript left unhandled while it ran.
|
|
297
|
+
#
|
|
298
|
+
# The check belongs here rather than only in the session because a JS
|
|
299
|
+
# runtime may install its own pump (the documented `time_pump` seam), and
|
|
300
|
+
# that pump drives the runtime directly instead of going through
|
|
301
|
+
# `Session#advance_time` — so a timer that throws during a poll would
|
|
302
|
+
# otherwise sit in the ledger until some later command happened to check.
|
|
276
303
|
def pump!
|
|
277
304
|
@time_pump&.call
|
|
305
|
+
rack_session.check_js_errors! if @javascript
|
|
278
306
|
end
|
|
279
307
|
|
|
280
308
|
def frame_stack
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: capybara-dommy
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.13.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- takahashim
|
|
@@ -29,28 +29,28 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 0.
|
|
32
|
+
version: 0.13.0
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 0.
|
|
39
|
+
version: 0.13.0
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: dommy-rack
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
44
|
- - "~>"
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: 0.
|
|
46
|
+
version: 0.13.0
|
|
47
47
|
type: :runtime
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - "~>"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: 0.
|
|
53
|
+
version: 0.13.0
|
|
54
54
|
description: |
|
|
55
55
|
capybara-dommy is a Capybara driver backed by Dommy and dommy-rack. It drives
|
|
56
56
|
Rack/Rails apps through the Capybara DSL without a real browser or JavaScript,
|