Skip to content

Commit 463661e

Browse files
princejosephclaude
andcommitted
fix prop-type test assertions for React 18 console.error format change
React 18 changed prop-type warnings from: console.error("Warning: Failed prop type: " + message) to format-string style: console.error("Warning: Failed %s type: %s%s", "prop", message, stack) Chrome captures the format string literally, so the old regex /Warning: Failed prop( type|Type): In component.../ no longer matches. Update assertions to match the error message content directly instead of the React-version-specific prefix format. Also change goog:loggingPrefs from 'ALL' to 'SEVERE' to avoid capturing noisy console.log initialization messages (requires, React DevTools prompt) which would cause the 'no spurious warnings' test to fail. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 569bfae commit 463661e

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

ruby/hyper-component/spec/client_features/component_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ class Lorem; end
543543
Hyperstack::Component::ReactTestUtils.render_component_into_document(Foo, bar: 10, lorem: Lorem.new)
544544
end
545545
expect(page.driver.browser.logs.get(:browser).map { |m| m.message.gsub(/\\n/, "\n") }.to_a.join("\n"))
546-
.to match(/Warning: Failed prop( type|Type): In component `Foo`\nRequired prop `foo` was not specified\nProvided prop `bar` could not be converted to String/)
546+
.to match(/In component `Foo`\nRequired prop `foo` was not specified\nProvided prop `bar` could not be converted to String/)
547547
end
548548

549549
it 'should not log anything if validation pass' do

ruby/hyper-component/spec/client_features/param_declaration_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class Foo < Hyperloop::Component
126126
end
127127
expect(page.body[-60..-19]).to include('<div>12-string</div>')
128128
expect(page.driver.browser.logs.get(:browser).map { |m| m.message.gsub(/\\n/, "\n") }.to_a.join("\n"))
129-
.to match(/Warning: Failed prop( type|Type): In component `Foo`\nProvided prop `foo1` could not be converted to String/)
129+
.to match(/In component `Foo`\nProvided prop `foo1` could not be converted to String/)
130130
end
131131

132132
it "will properly handle params named class" do
@@ -156,7 +156,7 @@ class Foo2 < Hyperloop::Component
156156
Hyperstack::Component::ReactTestUtils.render_component_into_document(Foo2, bar: 10, lorem: Lorem.new)
157157
end
158158
expect(page.driver.browser.logs.get(:browser).map { |m| m.message.gsub(/\\n/, "\n") }.to_a.join("\n"))
159-
.to match(/Warning: Failed prop( type|Type): In component `Foo2`\nRequired prop `foo` was not specified\nProvided prop `bar` could not be converted to String/)
159+
.to match(/In component `Foo2`\nRequired prop `foo` was not specified\nProvided prop `bar` could not be converted to String/)
160160
end
161161

162162
it 'should not log anything if validation passes' do
@@ -192,7 +192,7 @@ class Foo < Hyperloop::Component
192192
end
193193
end
194194
expect(page.driver.browser.logs.get(:browser).map { |m| m.message.gsub(/\\n/, "\n") }.to_a.join("\n"))
195-
.to match(/Warning: Failed prop( type|Type): In component `Foo`\nProvided prop `foo` could not be converted to Array/)
195+
.to match(/In component `Foo`\nProvided prop `foo` could not be converted to Array/)
196196
end
197197

198198
it "can use the [xxx] notation for arrays of a specific type" do
@@ -203,7 +203,7 @@ class Foo < Hyperloop::Component
203203
end
204204
end
205205
expect(page.driver.browser.logs.get(:browser).map { |m| m.message.gsub(/\\n/, "\n") }.to_a.join("\n"))
206-
.to match(/Warning: Failed prop( type|Type): In component `Foo`\nProvided prop `foo`\[0\] could not be converted to String/)
206+
.to match(/In component `Foo`\nProvided prop `foo`\[0\] could not be converted to String/)
207207
end
208208

209209
it "can convert a json hash to a type" do
@@ -228,7 +228,7 @@ def self._react_param_conversion(json, validate_only)
228228
end
229229
expect(page.body[-60..-19]).to include('<span>1, 2</span>')
230230
expect(page.driver.browser.logs.get(:browser).map { |m| m.message.gsub(/\\n/, "\n") }.to_a.join("\n"))
231-
.to match(/Warning: Failed prop( type|Type): In component `Foo`\nProvided prop `foo` could not be converted to BazWoggle/)
231+
.to match(/In component `Foo`\nProvided prop `foo` could not be converted to BazWoggle/)
232232
end
233233

234234
it 'allows passing and merging complex arguments to params' do

ruby/hyper-component/spec/deprecated_features/param_declaration_legacy_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class Foo < Hyperloop::Component
200200
end
201201
expect(page.body[-60..-19]).to include('<div>12-string</div>')
202202
expect(page.driver.browser.logs.get(:browser).map { |m| m.message.gsub(/\\n/, "\n") }.to_a.join("\n"))
203-
.to match(/Warning: Failed prop( type|Type): In component `Foo`\nProvided prop `foo1` could not be converted to String/)
203+
.to match(/In component `Foo`\nProvided prop `foo1` could not be converted to String/)
204204
end
205205

206206
it 'logs error in warning if validation failed' do
@@ -217,7 +217,7 @@ class Foo2 < Hyperloop::Component
217217
Hyperstack::Component::ReactTestUtils.render_component_into_document(Foo2, bar: 10, lorem: Lorem.new)
218218
end
219219
expect(page.driver.browser.logs.get(:browser).map { |m| m.message.gsub(/\\n/, "\n") }.to_a.join("\n"))
220-
.to match(/Warning: Failed prop( type|Type): In component `Foo2`\nRequired prop `foo` was not specified\nProvided prop `bar` could not be converted to String/)
220+
.to match(/In component `Foo2`\nRequired prop `foo` was not specified\nProvided prop `bar` could not be converted to String/)
221221
end
222222

223223
it 'should not log anything if validation passes' do
@@ -255,7 +255,7 @@ class Foo < Hyperloop::Component
255255
end
256256
end
257257
expect(page.driver.browser.logs.get(:browser).map { |m| m.message.gsub(/\\n/, "\n") }.to_a.join("\n"))
258-
.to match(/Warning: Failed prop( type|Type): In component `Foo`\nProvided prop `foo` could not be converted to Array/)
258+
.to match(/In component `Foo`\nProvided prop `foo` could not be converted to Array/)
259259
end
260260

261261
it "can use the [xxx] notation for arrays of a specific type" do
@@ -266,7 +266,7 @@ class Foo < Hyperloop::Component
266266
end
267267
end
268268
expect(page.driver.browser.logs.get(:browser).map { |m| m.message.gsub(/\\n/, "\n") }.to_a.join("\n"))
269-
.to match(/Warning: Failed prop( type|Type): In component `Foo`\nProvided prop `foo`\[0\] could not be converted to String/)
269+
.to match(/In component `Foo`\nProvided prop `foo`\[0\] could not be converted to String/)
270270
end
271271

272272
it "can convert a json hash to a type" do
@@ -291,7 +291,7 @@ def self._react_param_conversion(json, validate_only)
291291
end
292292
expect(page.body[-60..-19]).to include('<span>1, 2</span>')
293293
expect(page.driver.browser.logs.get(:browser).map { |m| m.message.gsub(/\\n/, "\n") }.to_a.join("\n"))
294-
.to match(/Warning: Failed prop( type|Type): In component `Foo`\nProvided prop `foo` could not be converted to BazWoggle/)
294+
.to match(/In component `Foo`\nProvided prop `foo` could not be converted to BazWoggle/)
295295
end
296296

297297
it 'allows passing and merging complex arguments to params' do

ruby/hyper-spec/lib/hyper-spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def self.on_server?
252252
options.add_argument('--no-sandbox')
253253
options.add_argument('--disable-dev-shm-usage')
254254
options.add_argument('--disable-gpu')
255-
options.add_option('goog:loggingPrefs', { browser: 'ALL' })
255+
options.add_option('goog:loggingPrefs', { browser: 'SEVERE' })
256256
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
257257
end
258258

0 commit comments

Comments
 (0)