194
root.render(<div foo={() => {}} />);
195
});
196
}).toErrorDev(
197
- 'Warning: Invalid value for prop `foo` on <div> tag. Either remove it ' +
197
+ 'Invalid value for prop `foo` on <div> tag. Either remove it ' +
198
'from the element, or pass a string or number value to keep ' +
199
'it in the DOM. For details, see https://react.dev/link/attribute-behavior ' +
200
'\n in div (at **)',
209
root.render(<div foo={() => {}} baz={() => {}} />);
210
});
211
}).toErrorDev(
212
- 'Warning: Invalid values for props `foo`, `baz` on <div> tag. Either remove ' +
212
+ 'Invalid values for props `foo`, `baz` on <div> tag. Either remove ' +
213
'them from the element, or pass a string or number value to keep ' +
214
'them in the DOM. For details, see https://react.dev/link/attribute-behavior ' +
215
'\n in div (at **)',
224
root.render(<div onDblClick={() => {}} />);
225
});
226
}).toErrorDev(
227
- 'Warning: Invalid event handler property `onDblClick`. Did you mean `onDoubleClick`?\n in div (at **)',
227
+ 'Invalid event handler property `onDblClick`. Did you mean `onDoubleClick`?\n in div (at **)',
228
);
229
});
230
236
root.render(<div onUnknown='alert("hack")' />);
237
});
238
}).toErrorDev(
239
- 'Warning: Unknown event handler property `onUnknown`. It will be ignored.\n in div (at **)',
239
+ 'Unknown event handler property `onUnknown`. It will be ignored.\n in div (at **)',
240
);
241
expect(container.firstChild.hasAttribute('onUnknown')).toBe(false);
242
expect(container.firstChild.onUnknown).toBe(undefined);
245
root.render(<div onunknown='alert("hack")' />);
246
});
247
}).toErrorDev(
248
- 'Warning: Unknown event handler property `onunknown`. It will be ignored.\n in div (at **)',
248
+ 'Unknown event handler property `onunknown`. It will be ignored.\n in div (at **)',
249
);
250
expect(container.firstChild.hasAttribute('onunknown')).toBe(false);
251
expect(container.firstChild.onunknown).toBe(undefined);
254
root.render(<div on-unknown='alert("hack")' />);
255
});
256
}).toErrorDev(
257
- 'Warning: Unknown event handler property `on-unknown`. It will be ignored.\n in div (at **)',
257
+ 'Unknown event handler property `on-unknown`. It will be ignored.\n in div (at **)',
258
);
259
expect(container.firstChild.hasAttribute('on-unknown')).toBe(false);
260
expect(container.firstChild['on-unknown']).toBe(undefined);
268
root.render(<div onUnknown={function () {}} />);
269
});
270
}).toErrorDev(
271
- 'Warning: Unknown event handler property `onUnknown`. It will be ignored.\n in div (at **)',
271
+ 'Unknown event handler property `onUnknown`. It will be ignored.\n in div (at **)',
272
);
273
expect(container.firstChild.hasAttribute('onUnknown')).toBe(false);
274
expect(container.firstChild.onUnknown).toBe(undefined);
277
root.render(<div onunknown={function () {}} />);
278
});
279
}).toErrorDev(
280
- 'Warning: Unknown event handler property `onunknown`. It will be ignored.\n in div (at **)',
280
+ 'Unknown event handler property `onunknown`. It will be ignored.\n in div (at **)',
281
);
282
expect(container.firstChild.hasAttribute('onunknown')).toBe(false);
283
expect(container.firstChild.onunknown).toBe(undefined);
286
root.render(<div on-unknown={function () {}} />);
287
});
288
}).toErrorDev(
289
- 'Warning: Unknown event handler property `on-unknown`. It will be ignored.\n in div (at **)',
289
+ 'Unknown event handler property `on-unknown`. It will be ignored.\n in div (at **)',
290
);
291
expect(container.firstChild.hasAttribute('on-unknown')).toBe(false);
292
expect(container.firstChild['on-unknown']).toBe(undefined);
300
root.render(<div CHILDREN="5" />);
301
});
302
}).toErrorDev(
303
- 'Warning: Invalid DOM property `CHILDREN`. Did you mean `children`?\n in div (at **)',
303
+ 'Invalid DOM property `CHILDREN`. Did you mean `children`?\n in div (at **)',
304
);
305
expect(container.firstChild.getAttribute('CHILDREN')).toBe('5');
306
});
328
root.render(<span style={style} />);
329
});
330
}).toErrorDev(
331
- 'Warning: `NaN` is an invalid value for the `fontSize` css style property.' +
331
+ '`NaN` is an invalid value for the `fontSize` css style property.' +
332
'\n in span (at **)',
333
);
334
await act(() => {
355
root.render(<span style={style} />);
356
});
357
}).toErrorDev(
358
- 'Warning: The provided `fontSize` CSS property is an unsupported type TemporalLike.' +
358
+ 'The provided `fontSize` CSS property is an unsupported type TemporalLike.' +
359
' This value must be coerced to a string before using it here.',
360
);
361
}).rejects.toThrowError(new TypeError('prod message'));
891
expect(result2.toLowerCase()).not.toContain('script');
892
}
893
}).toErrorDev([
894
- 'Warning: Invalid attribute name: `blah" onclick="beevil" noise="hi`',
895
- 'Warning: Invalid attribute name: `></div><script>alert("hi")</script>`',
894
+ 'Invalid attribute name: `blah" onclick="beevil" noise="hi`',
895
+ 'Invalid attribute name: `></div><script>alert("hi")</script>`',
896
]);
897
});
898
915
expect(result2.toLowerCase()).not.toContain('script');
916
}
917
}).toErrorDev([
918
- 'Warning: Invalid attribute name: `blah" onclick="beevil" noise="hi`',
919
- 'Warning: Invalid attribute name: `></x-foo-component><script>alert("hi")</script>`',
918
+ 'Invalid attribute name: `blah" onclick="beevil" noise="hi`',
919
+ 'Invalid attribute name: `></x-foo-component><script>alert("hi")</script>`',
920
]);
921
});
922
953
expect(container.firstChild.attributes.length).toBe(0);
954
}
955
}).toErrorDev([
956
- 'Warning: Invalid attribute name: `blah" onclick="beevil" noise="hi`',
957
- 'Warning: Invalid attribute name: `></div><script>alert("hi")</script>`',
956
+ 'Invalid attribute name: `blah" onclick="beevil" noise="hi`',
957
+ 'Invalid attribute name: `></div><script>alert("hi")</script>`',
958
]);
959
});
960
992
expect(container.firstChild.attributes.length).toBe(0);
993
}
994
}).toErrorDev([
995
- 'Warning: Invalid attribute name: `blah" onclick="beevil" noise="hi`',
996
- 'Warning: Invalid attribute name: `></x-foo-component><script>alert("hi")</script>`',
995
+ 'Invalid attribute name: `blah" onclick="beevil" noise="hi`',
996
+ 'Invalid attribute name: `></x-foo-component><script>alert("hi")</script>`',
997
]);
998
});
999
1030
expect(container.firstChild.attributes.length).toBe(0);
1031
}
1032
}).toErrorDev([
1033
- 'Warning: Invalid attribute name: `blah" onclick="beevil" noise="hi`',
1034
- 'Warning: Invalid attribute name: `></div><script>alert("hi")</script>`',
1033
+ 'Invalid attribute name: `blah" onclick="beevil" noise="hi`',
1034
+ 'Invalid attribute name: `></div><script>alert("hi")</script>`',
1035
]);
1036
});
1037
1068
expect(container.firstChild.attributes.length).toBe(0);
1069
}
1070
}).toErrorDev([
1071
- 'Warning: Invalid attribute name: `blah" onclick="beevil" noise="hi`',
1072
- 'Warning: Invalid attribute name: `></x-foo-component><script>alert("hi")</script>`',
1071
+ 'Invalid attribute name: `blah" onclick="beevil" noise="hi`',
1072
+ 'Invalid attribute name: `></x-foo-component><script>alert("hi")</script>`',
1073
]);
1074
});
1075
1410
root.render(<input value="" onChange={onChange} />);
1411
});
1412
}).toErrorDev(
1413
- ' A component is changing an uncontrolled input to be controlled. This is likely caused by ' +
1413
+ 'A component is changing an uncontrolled input to be controlled. This is likely caused by ' +
1414
'the value changing from undefined to a defined value, which should not happen. Decide between ' +
1415
'using a controlled or uncontrolled input element for the lifetime of the component.',
1416
);
1866
await expect(async () => {
1867
await mountComponent({contentEditable: true, children: ''});
1868
}).toErrorDev(
1869
- 'Warning: A component is `contentEditable` and contains `children` ' +
1869
+ 'A component is `contentEditable` and contains `children` ' +
1870
'managed by React. It is now your responsibility to guarantee that ' +
1871
'none of those nodes are unexpectedly modified or duplicated. This ' +
1872
'is probably not intentional.\n in div (at **)',
2194
);
2195
});
2196
}).toErrorDev([
2197
- 'Warning: In HTML, <tr> cannot be a child of ' +
2197
+ 'In HTML, <tr> cannot be a child of ' +
2198
'<div>.\n' +
2199
'This will cause a hydration error.' +
2200
'\n in tr (at **)' +
2215
);
2216
});
2217
}).toErrorDev(
2218
- 'Warning: In HTML, <p> cannot be a descendant ' +
2218
+ 'In HTML, <p> cannot be a descendant ' +
2219
'of <p>.\n' +
2220
'This will cause a hydration error.' +
2221
// There is no outer `p` here because root container is not part of the stack.
2249
root.render(<Foo />);
2250
});
2251
}).toErrorDev([
2252
- 'Warning: In HTML, <tr> cannot be a child of ' +
2252
+ 'In HTML, <tr> cannot be a child of ' +
2253
'<table>. Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated ' +
2254
'by the browser.\n' +
2255
'This will cause a hydration error.' +
2257
'\n in Row (at **)' +
2258
'\n in table (at **)' +
2259
'\n in Foo (at **)',
2260
- 'Warning: In HTML, text nodes cannot be a ' +
2260
+ 'In HTML, text nodes cannot be a ' +
2261
'child of <tr>.\n' +
2262
'This will cause a hydration error.' +
2263
'\n in tr (at **)' +
2264
'\n in Row (at **)' +
2265
'\n in table (at **)' +
2266
'\n in Foo (at **)',
2267
- 'Warning: In HTML, whitespace text nodes cannot ' +
2267
+ 'In HTML, whitespace text nodes cannot ' +
2268
"be a child of <table>. Make sure you don't have any extra " +
2269
'whitespace between tags on each line of your source code.\n' +
2270
'This will cause a hydration error.' +
2294
root.render(<Foo> </Foo>);
2295
});
2296
}).toErrorDev([
2297
- 'Warning: In HTML, whitespace text nodes cannot ' +
2297
+ 'In HTML, whitespace text nodes cannot ' +
2298
"be a child of <table>. Make sure you don't have any extra " +
2299
'whitespace between tags on each line of your source code.\n' +
2300
'This will cause a hydration error.' +
2323
);
2324
});
2325
}).toErrorDev([
2326
- 'Warning: In HTML, text nodes cannot be a ' +
2326
+ 'In HTML, text nodes cannot be a ' +
2327
'child of <tr>.\n' +
2328
'This will cause a hydration error.' +
2329
'\n in tr (at **)' +
2713
root.render(<div class="paladin" />);
2714
});
2715
}).toErrorDev(
2716
- 'Warning: Invalid DOM property `class`. Did you mean `className`?\n in div (at **)',
2716
+ 'Invalid DOM property `class`. Did you mean `className`?\n in div (at **)',
2717
);
2718
await expect(async () => {
2719
const container = document.createElement('div');
2722
root.render(<input type="text" onclick="1" />);
2723
});
2724
}).toErrorDev(
2725
- 'Warning: Invalid event handler property `onclick`. Did you mean ' +
2725
+ 'Invalid event handler property `onclick`. Did you mean ' +
2726
'`onClick`?\n in input (at **)',
2727
);
2728
});
2731
expect(() =>
2732
ReactDOMServer.renderToString(<div class="paladin" />),
2733
).toErrorDev(
2734
- 'Warning: Invalid DOM property `class`. Did you mean `className`?\n in div (at **)',
2734
+ 'Invalid DOM property `class`. Did you mean `className`?\n in div (at **)',
2735
);
2736
expect(() =>
2737
ReactDOMServer.renderToString(<input type="text" oninput="1" />),
2738
).toErrorDev(
2739
- 'Warning: Invalid event handler property `oninput`. ' +
2739
+ 'Invalid event handler property `oninput`. ' +
2740
// Note: we don't know the right event name so we
2741
// use a generic one (onClick) as a suggestion.
2742
// This is because we don't bundle the event system
2760
root.render(<div class="paladin" />);
2761
});
2762
}).toErrorDev(
2763
- 'Warning: Invalid DOM property `class`. Did you mean `className`?\n in div (at **)',
2763
+ 'Invalid DOM property `class`. Did you mean `className`?\n in div (at **)',
2764
);
2765
});
2766
2912
root.render(React.createElement('label', {for: 'test'}));
2913
});
2914
}).toErrorDev(
2915
- 'Warning: Invalid DOM property `for`. Did you mean `htmlFor`?\n in label',
2915
+ 'Invalid DOM property `for`. Did you mean `htmlFor`?\n in label',
2916
);
2917
2918
await expect(async () => {
2924
);
2925
});
2926
}).toErrorDev(
2927
- 'Warning: Invalid DOM property `autofocus`. Did you mean `autoFocus`?\n in input',
2927
+ 'Invalid DOM property `autofocus`. Did you mean `autoFocus`?\n in input',
2928
);
2929
});
2930
2934
React.createElement('label', {for: 'test'}),
2935
),
2936
).toErrorDev(
2937
- 'Warning: Invalid DOM property `for`. Did you mean `htmlFor`?\n in label',
2937
+ 'Invalid DOM property `for`. Did you mean `htmlFor`?\n in label',
2938
);
2939
expect(() =>
2940
ReactDOMServer.renderToString(
2941
React.createElement('input', {type: 'text', autofocus: true}),
2942
),
2943
).toErrorDev(
2944
- 'Warning: Invalid DOM property `autofocus`. Did you mean `autoFocus`?\n in input',
2944
+ 'Invalid DOM property `autofocus`. Did you mean `autoFocus`?\n in input',
2945
);
2946
});
2947
});
2989
await act(() => {
2990
root.render(<div class="test" ref={current => (el = current)} />);
2991
});
2992
- }).toErrorDev(
2993
- 'Warning: Invalid DOM property `class`. Did you mean `className`?',
2994
- );
2992
+ }).toErrorDev('Invalid DOM property `class`. Did you mean `className`?');
2993
2994
expect(el.className).toBe('test');
2995
});
3003
await act(() => {
3004
root.render(<div cLASS="test" ref={current => (el = current)} />);
3005
});
3008
- }).toErrorDev(
3009
- 'Warning: Invalid DOM property `cLASS`. Did you mean `className`?',
3010
- );
3006
+ }).toErrorDev('Invalid DOM property `cLASS`. Did you mean `className`?');
3007
3008
expect(el.className).toBe('test');
3009
});
3022
);
3023
});
3024
}).toErrorDev(
3029
- 'Warning: Invalid DOM property `arabic-form`. Did you mean `arabicForm`?',
3025
+ 'Invalid DOM property `arabic-form`. Did you mean `arabicForm`?',
3026
);
3027
const text = el.querySelector('text');
3028
3160
<div whatever={() => {}} ref={current => (el = current)} />,
3161
);
3162
});
3167
- }).toErrorDev('Warning: Invalid value for prop `whatever` on <div> tag');
3163
+ }).toErrorDev('Invalid value for prop `whatever` on <div> tag');
3164
3165
expect(el.hasAttribute('whatever')).toBe(false);
3166
});
3253
root.render(<div whatever={NaN} ref={current => (el = current)} />);
3254
});
3255
}).toErrorDev(
3260
- 'Warning: Received NaN for the `whatever` attribute. If this is ' +
3256
+ 'Received NaN for the `whatever` attribute. If this is ' +
3257
'expected, cast the value to a string.\n in div',
3258
);
3259
3270
await act(() => {
3271
root.render(<div whatever={() => {}} />);
3272
});
3277
- }).toErrorDev('Warning: Invalid value for prop `whatever` on <div> tag.');
3273
+ }).toErrorDev('Invalid value for prop `whatever` on <div> tag.');
3274
const el = container.firstChild;
3275
expect(el.hasAttribute('whatever')).toBe(false);
3276
});
3284
await act(() => {
3285
root.render(<div SiZe="30" ref={current => (el = current)} />);
3286
});
3291
- }).toErrorDev(
3292
- 'Warning: Invalid DOM property `SiZe`. Did you mean `size`?',
3293
- );
3287
+ }).toErrorDev('Invalid DOM property `SiZe`. Did you mean `size`?');
3288
3289
expect(el.getAttribute('size')).toBe('30');
3290
});
3496
</svg>,
3497
);
3498
});
3505
- }).toErrorDev(
3506
- 'Warning: Invalid DOM property `x-height`. Did you mean `xHeight`',
3507
- );
3499
+ }).toErrorDev('Invalid DOM property `x-height`. Did you mean `xHeight`');
3500
3501
expect(el.querySelector('font-face').hasAttribute('x-height')).toBe(
3502
false,