capybara-simulated 0.0.5 → 0.0.7
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/README.md +25 -10
- data/lib/capybara/simulated/version.rb +1 -1
- data/vendor/js/csim.bundle.js +4198 -13653
- data/vendor/js/entry.mjs +20 -5
- data/vendor/js/prelude.js +4 -0
- data/vendor/js/runtime.js +53 -121
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3d7b5f908d1c75a41fabf90b90c779ae21813de6a4620a7b574e4dfca69134cf
|
|
4
|
+
data.tar.gz: 57ddffb46aca509cd981106c4ac0ad421d38956c52fba5d439add59ae2e10aab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 576d88b9d8fe7d0c480e8ad7309e7861d9be563a95ab992f6d870f66c06a12d0255f779622ac25e7bab19aa7c6868bf929593e31fe146b4b3fe4d01e3447a37b
|
|
7
|
+
data.tar.gz: 8cfe9a00eff04e4df4d8aa3b1938f122001a00bc7e15f0f3c5b92975fd51c82b2d115aa9b5031ead063a236e4b4c81159ec9d947ea7e5df948e165d5047f3055
|
data/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
A lightweight Capybara driver that runs JavaScript in a long-lived
|
|
4
4
|
[mini_racer](https://github.com/rubyjs/mini_racer) V8 context against a
|
|
5
5
|
[happy-dom](https://github.com/capricorn86/happy-dom) DOM. XPath queries
|
|
6
|
-
are powered by [
|
|
6
|
+
are powered by [Wicked Good XPath](https://github.com/google/wicked-good-xpath).
|
|
7
7
|
|
|
8
8
|
The goal is the middle ground between `rack-test` (zero JS) and full
|
|
9
9
|
headless browsers like cuprite/selenium: in-process tests, no Chrome,
|
|
@@ -16,17 +16,18 @@ Used in production by a Rails 8 app to run ~200 `js: true` system specs
|
|
|
16
16
|
without spawning a headless Chrome.
|
|
17
17
|
|
|
18
18
|
Against Capybara 3.40's shared `Capybara::SpecHelper.spec` suite the
|
|
19
|
-
driver passes **
|
|
20
|
-
capability tags `about_scheme`, `css`, `download`,
|
|
21
|
-
`screenshot`, `scroll`, `server`, `spatial`, `windows`
|
|
22
|
-
The
|
|
23
|
-
does not implement:
|
|
19
|
+
driver passes **1335 / 1357 examples** with 0 failures and 22 pending,
|
|
20
|
+
once the unsupported-capability tags `about_scheme`, `css`, `download`,
|
|
21
|
+
`frames`, `hover`, `screenshot`, `scroll`, `server`, `spatial`, `windows`
|
|
22
|
+
are filtered out. The 22 pending all need capabilities the driver
|
|
23
|
+
intentionally does not implement:
|
|
24
24
|
|
|
25
25
|
- 19 `#drag_to` tests — Dragula / SortableJS / jsTree resolve drop
|
|
26
26
|
targets through `elementFromPoint(clientX, clientY)`, which needs a
|
|
27
27
|
real layout engine with stacking-context awareness.
|
|
28
28
|
- 1 `#click should not retry clicking when wait is disabled` — depends
|
|
29
29
|
on the same `elementFromPoint`-based obscured-element detection.
|
|
30
|
+
- 2 unrelated upstream-pending specs.
|
|
30
31
|
|
|
31
32
|
`evaluate_async_script` is supported by polling the Ruby↔V8 bridge while
|
|
32
33
|
draining the virtual clock until the user callback fires (or
|
|
@@ -75,6 +76,15 @@ out of the box:
|
|
|
75
76
|
swapped `<turbo-frame>`. We patch `MutationObserver.prototype.observe`
|
|
76
77
|
per Window to swap each WeakRef out for a strong-reference shim with
|
|
77
78
|
the same `.deref()` shape, so listeners survive the next GC.
|
|
79
|
+
- happy-dom 20's `Attr` class doesn't override `Node.nodeValue`, which
|
|
80
|
+
the [DOM spec](https://dom.spec.whatwg.org/#dom-node-nodevalue)
|
|
81
|
+
defines as the attribute's `value`. The default getter inherited
|
|
82
|
+
from `Node` returns `null`, so any XPath engine reading attribute
|
|
83
|
+
string-values via `nodeValue` (wgxpath included) collapses every
|
|
84
|
+
attribute compare to `"null" === "null"` and predicates like
|
|
85
|
+
`[@id = //label/@for]` match every element with any `@id`. We install
|
|
86
|
+
a per-Window `Attr.prototype.nodeValue` getter / setter that mirrors
|
|
87
|
+
`value`.
|
|
78
88
|
|
|
79
89
|
WebSocket, frames and multi-window remain explicitly out of scope — they
|
|
80
90
|
need a real browser (Selenium / Cuprite) or a separate transport that
|
|
@@ -88,7 +98,7 @@ torn down between specs. This keeps `reset!` cheap.
|
|
|
88
98
|
|
|
89
99
|
```
|
|
90
100
|
npm install
|
|
91
|
-
npm run build # produces vendor/js/csim.bundle.js (~
|
|
101
|
+
npm run build # produces vendor/js/csim.bundle.js (~2.9MB)
|
|
92
102
|
bundle install
|
|
93
103
|
bundle exec rspec
|
|
94
104
|
```
|
|
@@ -202,12 +212,17 @@ puts page.text
|
|
|
202
212
|
- `vendor/js/prelude.js` — minimal Web Platform polyfills (TextEncoder,
|
|
203
213
|
atob/btoa, crypto.getRandomValues, performance, timers, process).
|
|
204
214
|
- `vendor/js/csim.bundle.js` — bundled happy-dom + whatwg-url +
|
|
205
|
-
|
|
206
|
-
Node built-ins happy-dom imports (`url`, `buffer`, `vm`,
|
|
215
|
+
Wicked Good XPath. Built via `build.mjs` with esbuild, with shims
|
|
216
|
+
for the Node built-ins happy-dom imports (`url`, `buffer`, `vm`,
|
|
217
|
+
`path`, etc.).
|
|
207
218
|
- `vendor/js/runtime.js` — driver glue exposed on `globalThis.__csim`.
|
|
208
219
|
Manages the active happy-dom `Window`, an integer→DOM-node handle
|
|
209
220
|
table, modal capture, form serialization, click/submit dispatch, and
|
|
210
|
-
XPath
|
|
221
|
+
XPath through `document.evaluate` (installed by wgxpath). Fast-paths
|
|
222
|
+
Capybara's hot xpath shapes (`:option`, `:select`, `:link_or_button`)
|
|
223
|
+
to native `querySelectorAll` + `getElementById`.
|
|
224
|
+
- `vendor/esbuild-wasm/` — vendored copy of esbuild-wasm so the gem can
|
|
225
|
+
bundle Rails importmap modules without a runtime npm dependency.
|
|
211
226
|
- `lib/capybara/simulated/browser.rb` — owns the `MiniRacer::Context`,
|
|
212
227
|
drives HTTP via `Rack::MockRequest`, fetches `<script src>` inline,
|
|
213
228
|
and routes form submissions back through Rack.
|