percy-capybara 5.0.0.pre.5 → 5.0.1.pre.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/README.md +18 -1
- data/lib/percy/capybara.rb +45 -1
- data/lib/percy/version.rb +1 -1
- metadata +26 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ccaeb7accc5e9ccb209ad80416672ada2508a4614b43a0963b6e7b6c7a80d347
|
|
4
|
+
data.tar.gz: ab7f534fd22d02a567a60d1905b737ed1a0f2276d531de1a2186ae79b96b5176
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c1c5cb3a5024547f38d493a7571a73bdc43ae3a722865abce42fa6dc068c058a4326e4363c761f9f46cf8154ffeda1156b87eafee4e427118ff527ceeb6f6e97
|
|
7
|
+
data.tar.gz: f70fdedb5935a55025c068ace0dc6fcacfd4556c27be45584a97777107f405c85bcfc9aeec1465ba9631bb886344e0653663aa0074ae0a17f1f4bf5c93f5f2fc
|
data/README.md
CHANGED
|
@@ -66,10 +66,27 @@ $ percy exec -- [test command]
|
|
|
66
66
|
`page.snapshot(name[, options])`
|
|
67
67
|
|
|
68
68
|
- `name` (**required**) - The snapshot name; must be unique to each snapshot
|
|
69
|
-
- `options` - [See per-snapshot configuration options](https://
|
|
69
|
+
- `options` - [See per-snapshot configuration options](https://www.browserstack.com/docs/percy/take-percy-snapshots/overview#per-snapshot-configuration)
|
|
70
70
|
|
|
71
71
|
## Upgrading
|
|
72
72
|
|
|
73
|
+
### Automatically with `@percy/migrate`
|
|
74
|
+
|
|
75
|
+
We built a tool to help automate migrating to the new CLI toolchain! Migrating
|
|
76
|
+
can be done by running the following commands and following the prompts:
|
|
77
|
+
|
|
78
|
+
``` shell
|
|
79
|
+
$ npx @percy/migrate
|
|
80
|
+
? Are you currently using percy-capybara? Yes
|
|
81
|
+
? Install @percy/cli (required to run percy)? Yes
|
|
82
|
+
? Migrate Percy config file? Yes
|
|
83
|
+
? Upgrade SDK to percy-capybara@^5.0.0? Yes
|
|
84
|
+
? The Capybara API has breaking changes, automatically convert to the new API? Yes
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
This will automatically run the changes described below for you, with the
|
|
88
|
+
exception of changing the `require`.
|
|
89
|
+
|
|
73
90
|
### Manually
|
|
74
91
|
|
|
75
92
|
#### Require change
|
data/lib/percy/capybara.rb
CHANGED
|
@@ -22,9 +22,20 @@ module PercyCapybara
|
|
|
22
22
|
|
|
23
23
|
begin
|
|
24
24
|
page.evaluate_script(fetch_percy_dom)
|
|
25
|
+
|
|
26
|
+
# Readiness gate -- runs before serialize when CLI supports it.
|
|
27
|
+
# Uses evaluate_async_script with a callback signal so the SDK can block
|
|
28
|
+
# on PercyDOM.waitForReady. In-browser typeof guard makes this a no-op on
|
|
29
|
+
# older CLIs that lack waitForReady.
|
|
30
|
+
readiness_diagnostics = wait_for_ready(page, options)
|
|
31
|
+
|
|
25
32
|
dom_snapshot = page
|
|
26
33
|
.evaluate_script("(function() { return PercyDOM.serialize(#{options.to_json}) })()")
|
|
27
34
|
|
|
35
|
+
if readiness_diagnostics && dom_snapshot.is_a?(Hash)
|
|
36
|
+
dom_snapshot['readiness_diagnostics'] = readiness_diagnostics
|
|
37
|
+
end
|
|
38
|
+
|
|
28
39
|
response = fetch('percy/snapshot',
|
|
29
40
|
name: name,
|
|
30
41
|
url: page.current_url,
|
|
@@ -55,7 +66,7 @@ module PercyCapybara
|
|
|
55
66
|
log('You may be using @percy/agent ' \
|
|
56
67
|
'which is no longer supported by this SDK. ' \
|
|
57
68
|
'Please uninstall @percy/agent and install @percy/cli instead. ' \
|
|
58
|
-
'https://
|
|
69
|
+
'https://www.browserstack.com/docs/percy/migration/migrate-to-cli')
|
|
59
70
|
@percy_enabled = false
|
|
60
71
|
return false
|
|
61
72
|
end
|
|
@@ -85,6 +96,39 @@ module PercyCapybara
|
|
|
85
96
|
@percy_dom = response.body
|
|
86
97
|
end
|
|
87
98
|
|
|
99
|
+
# Readiness gate: runs PercyDOM.waitForReady before serialize.
|
|
100
|
+
#
|
|
101
|
+
# Returns diagnostics to attach to the domSnapshot, or nil.
|
|
102
|
+
# Config precedence: options[:readiness] / options['readiness'] > {} (the
|
|
103
|
+
# CLI applies its balanced preset default when passed {}). preset='disabled'
|
|
104
|
+
# skips the script entirely. Opt-in: only runs when the caller explicitly
|
|
105
|
+
# passes a `readiness` option -- keeps non-opting tests insulated from
|
|
106
|
+
# Capybara drivers that don't implement evaluate_async_script.
|
|
107
|
+
# Any StandardError is caught at debug level.
|
|
108
|
+
private def wait_for_ready(page, options)
|
|
109
|
+
return nil unless options.key?(:readiness) || options.key?('readiness')
|
|
110
|
+
|
|
111
|
+
readiness_config = options[:readiness] || options['readiness'] || {}
|
|
112
|
+
return nil if readiness_config.is_a?(Hash) && (
|
|
113
|
+
readiness_config[:preset] == 'disabled' || readiness_config['preset'] == 'disabled'
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
begin
|
|
117
|
+
page.evaluate_async_script(<<~JS)
|
|
118
|
+
var cfg = #{readiness_config.to_json};
|
|
119
|
+
var done = arguments[arguments.length - 1];
|
|
120
|
+
try {
|
|
121
|
+
if (typeof PercyDOM !== 'undefined' && typeof PercyDOM.waitForReady === 'function') {
|
|
122
|
+
PercyDOM.waitForReady(cfg).then(function(r){ done(r); }).catch(function(){ done(); });
|
|
123
|
+
} else { done(); }
|
|
124
|
+
} catch (e) { done(); }
|
|
125
|
+
JS
|
|
126
|
+
rescue StandardError => e
|
|
127
|
+
if PERCY_DEBUG then log("waitForReady failed, proceeding to serialize: #{e}") end
|
|
128
|
+
nil
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
88
132
|
private def log(msg)
|
|
89
133
|
puts "#{PERCY_LABEL} #{msg}"
|
|
90
134
|
end
|
data/lib/percy/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: percy-capybara
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.0.
|
|
4
|
+
version: 5.0.1.pre.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Perceptual Inc.
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-06-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: capybara
|
|
@@ -30,14 +30,28 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 4.0.0
|
|
33
|
+
version: 4.0.0
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 4.0.0
|
|
40
|
+
version: 4.0.0
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: geckodriver-bin
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 0.28.0
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 0.28.0
|
|
41
55
|
- !ruby/object:Gem::Dependency
|
|
42
56
|
name: bundler
|
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -84,16 +98,16 @@ dependencies:
|
|
|
84
98
|
name: capybara
|
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
|
86
100
|
requirements:
|
|
87
|
-
- - "
|
|
101
|
+
- - ">="
|
|
88
102
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '3
|
|
103
|
+
version: '3'
|
|
90
104
|
type: :development
|
|
91
105
|
prerelease: false
|
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
107
|
requirements:
|
|
94
|
-
- - "
|
|
108
|
+
- - ">="
|
|
95
109
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '3
|
|
110
|
+
version: '3'
|
|
97
111
|
- !ruby/object:Gem::Dependency
|
|
98
112
|
name: percy-style
|
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -125,7 +139,7 @@ licenses:
|
|
|
125
139
|
metadata:
|
|
126
140
|
bug_tracker_uri: https://github.com/percy/percy-capybara/issues
|
|
127
141
|
source_code_uri: https://github.com/percy/percy-capybara
|
|
128
|
-
post_install_message:
|
|
142
|
+
post_install_message:
|
|
129
143
|
rdoc_options: []
|
|
130
144
|
require_paths:
|
|
131
145
|
- lib
|
|
@@ -140,8 +154,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
140
154
|
- !ruby/object:Gem::Version
|
|
141
155
|
version: 1.3.1
|
|
142
156
|
requirements: []
|
|
143
|
-
rubygems_version: 3.
|
|
144
|
-
signing_key:
|
|
157
|
+
rubygems_version: 3.1.6
|
|
158
|
+
signing_key:
|
|
145
159
|
specification_version: 4
|
|
146
160
|
summary: Percy visual testing for Capybara
|
|
147
161
|
test_files: []
|