Skip to content

Commit 440ea19

Browse files
committed
Update test assertions
1 parent d27c5f3 commit 440ea19

File tree

67 files changed

+350
-369
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+350
-369
lines changed

packages/react-dom/src/__tests__/CSSPropertyOperations-test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ describe('CSSPropertyOperations', () => {
108108
root.render(<Comp />);
109109
});
110110
}).toErrorDev(
111-
'Warning: Unsupported style property background-color. Did you mean backgroundColor?' +
111+
'Unsupported style property background-color. Did you mean backgroundColor?' +
112112
'\n in div (at **)' +
113113
'\n in Comp (at **)',
114114
);
@@ -137,10 +137,10 @@ describe('CSSPropertyOperations', () => {
137137
root.render(<Comp style={styles} />);
138138
});
139139
}).toErrorDev([
140-
'Warning: Unsupported style property -ms-transform. Did you mean msTransform?' +
140+
'Unsupported style property -ms-transform. Did you mean msTransform?' +
141141
'\n in div (at **)' +
142142
'\n in Comp (at **)',
143-
'Warning: Unsupported style property -webkit-transform. Did you mean WebkitTransform?' +
143+
'Unsupported style property -webkit-transform. Did you mean WebkitTransform?' +
144144
'\n in div (at **)' +
145145
'\n in Comp (at **)',
146146
]);
@@ -171,11 +171,11 @@ describe('CSSPropertyOperations', () => {
171171
});
172172
}).toErrorDev([
173173
// msTransform is correct already and shouldn't warn
174-
'Warning: Unsupported vendor-prefixed style property oTransform. ' +
174+
'Unsupported vendor-prefixed style property oTransform. ' +
175175
'Did you mean OTransform?' +
176176
'\n in div (at **)' +
177177
'\n in Comp (at **)',
178-
'Warning: Unsupported vendor-prefixed style property webkitTransform. ' +
178+
'Unsupported vendor-prefixed style property webkitTransform. ' +
179179
'Did you mean WebkitTransform?' +
180180
'\n in div (at **)' +
181181
'\n in Comp (at **)',
@@ -207,11 +207,11 @@ describe('CSSPropertyOperations', () => {
207207
root.render(<Comp />);
208208
});
209209
}).toErrorDev([
210-
"Warning: Style property values shouldn't contain a semicolon. " +
210+
"Style property values shouldn't contain a semicolon. " +
211211
'Try "backgroundColor: blue" instead.' +
212212
'\n in div (at **)' +
213213
'\n in Comp (at **)',
214-
"Warning: Style property values shouldn't contain a semicolon. " +
214+
"Style property values shouldn't contain a semicolon. " +
215215
'Try "color: red" instead.' +
216216
'\n in div (at **)' +
217217
'\n in Comp (at **)',
@@ -234,7 +234,7 @@ describe('CSSPropertyOperations', () => {
234234
root.render(<Comp />);
235235
});
236236
}).toErrorDev(
237-
'Warning: `NaN` is an invalid value for the `fontSize` css style property.' +
237+
'`NaN` is an invalid value for the `fontSize` css style property.' +
238238
'\n in div (at **)' +
239239
'\n in Comp (at **)',
240240
);
@@ -270,7 +270,7 @@ describe('CSSPropertyOperations', () => {
270270
root.render(<Comp />);
271271
});
272272
}).toErrorDev(
273-
'Warning: `Infinity` is an invalid value for the `fontSize` css style property.' +
273+
'`Infinity` is an invalid value for the `fontSize` css style property.' +
274274
'\n in div (at **)' +
275275
'\n in Comp (at **)',
276276
);

packages/react-dom/src/__tests__/ReactComponent-test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ describe('ReactComponent', () => {
217217
root.render(<Component />);
218218
});
219219
}).toErrorDev([
220-
'Warning: Component "Component" contains the string ref "inner". ' +
220+
'Component "Component" contains the string ref "inner". ' +
221221
'Support for string refs will be removed in a future major release. ' +
222222
'We recommend using useRef() or createRef() instead. ' +
223223
'Learn more about using refs safely here: https://react.dev/link/strict-mode-string-ref\n' +
@@ -711,7 +711,7 @@ describe('ReactComponent', () => {
711711
root.render(<Foo />);
712712
});
713713
}).toErrorDev(
714-
'Warning: Functions are not valid as a React child. This may happen if ' +
714+
'Functions are not valid as a React child. This may happen if ' +
715715
'you return Foo instead of <Foo /> from render. ' +
716716
'Or maybe you meant to call this function rather than return it.\n' +
717717
' <Foo>{Foo}</Foo>\n' +
@@ -733,7 +733,7 @@ describe('ReactComponent', () => {
733733
root.render(<Foo />);
734734
});
735735
}).toErrorDev(
736-
'Warning: Functions are not valid as a React child. This may happen if ' +
736+
'Functions are not valid as a React child. This may happen if ' +
737737
'you return Foo instead of <Foo /> from render. ' +
738738
'Or maybe you meant to call this function rather than return it.\n' +
739739
' <Foo>{Foo}</Foo>\n' +
@@ -756,7 +756,7 @@ describe('ReactComponent', () => {
756756
root.render(<Foo />);
757757
});
758758
}).toErrorDev(
759-
'Warning: Functions are not valid as a React child. This may happen if ' +
759+
'Functions are not valid as a React child. This may happen if ' +
760760
'you return Foo instead of <Foo /> from render. ' +
761761
'Or maybe you meant to call this function rather than return it.\n' +
762762
' <span>{Foo}</span>\n' +
@@ -811,13 +811,13 @@ describe('ReactComponent', () => {
811811
root.render(<Foo ref={current => (component = current)} />);
812812
});
813813
}).toErrorDev([
814-
'Warning: Functions are not valid as a React child. This may happen if ' +
814+
'Functions are not valid as a React child. This may happen if ' +
815815
'you return Foo instead of <Foo /> from render. ' +
816816
'Or maybe you meant to call this function rather than return it.\n' +
817817
' <div>{Foo}</div>\n' +
818818
' in div (at **)\n' +
819819
' in Foo (at **)',
820-
'Warning: Functions are not valid as a React child. This may happen if ' +
820+
'Functions are not valid as a React child. This may happen if ' +
821821
'you return Foo instead of <Foo /> from render. ' +
822822
'Or maybe you meant to call this function rather than return it.\n' +
823823
' <span>{Foo}</span>\n' +

packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ describe('ReactComponentLifeCycle', () => {
271271
root.render(<StatefulComponent />);
272272
});
273273
}).toErrorDev(
274-
"Warning: Can't call setState on a component that is not yet mounted. " +
274+
"Can't call setState on a component that is not yet mounted. " +
275275
'This is a no-op, but it might indicate a bug in your application. ' +
276276
'Instead, assign to `this.state` directly or define a `state = {};` ' +
277277
'class property with the desired state in the StatefulComponent component.',
@@ -1504,20 +1504,20 @@ describe('ReactComponentLifeCycle', () => {
15041504
}).toWarnDev(
15051505
[
15061506
/* eslint-disable max-len */
1507-
`Warning: componentWillMount has been renamed, and is not recommended for use. See https://react.dev/link/unsafe-component-lifecycles for details.
1507+
`componentWillMount has been renamed, and is not recommended for use. See https://react.dev/link/unsafe-component-lifecycles for details.
15081508
15091509
* Move code with side effects to componentDidMount, and set initial state in the constructor.
15101510
* Rename componentWillMount to UNSAFE_componentWillMount to suppress this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run \`npx react-codemod rename-unsafe-lifecycles\` in your project source folder.
15111511
15121512
Please update the following components: MyComponent`,
1513-
`Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://react.dev/link/unsafe-component-lifecycles for details.
1513+
`componentWillReceiveProps has been renamed, and is not recommended for use. See https://react.dev/link/unsafe-component-lifecycles for details.
15141514
15151515
* Move data fetching code or side effects to componentDidUpdate.
15161516
* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://react.dev/link/derived-state
15171517
* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run \`npx react-codemod rename-unsafe-lifecycles\` in your project source folder.
15181518
15191519
Please update the following components: MyComponent`,
1520-
`Warning: componentWillUpdate has been renamed, and is not recommended for use. See https://react.dev/link/unsafe-component-lifecycles for details.
1520+
`componentWillUpdate has been renamed, and is not recommended for use. See https://react.dev/link/unsafe-component-lifecycles for details.
15211521
15221522
* Move data fetching code or side effects to componentDidUpdate.
15231523
* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run \`npx react-codemod rename-unsafe-lifecycles\` in your project source folder.

packages/react-dom/src/__tests__/ReactCompositeComponent-test.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ describe('ReactCompositeComponent', () => {
313313
root.render(<MyComponent />);
314314
});
315315
}).toErrorDev(
316-
"Warning: Can't call forceUpdate on a component that is not yet mounted. " +
316+
"Can't call forceUpdate on a component that is not yet mounted. " +
317317
'This is a no-op, but it might indicate a bug in your application. ' +
318318
'Instead, assign to `this.state` directly or define a `state = {};` ' +
319319
'class property with the desired state in the MyComponent component.',
@@ -347,7 +347,7 @@ describe('ReactCompositeComponent', () => {
347347
root.render(<MyComponent />);
348348
});
349349
}).toErrorDev(
350-
"Warning: Can't call setState on a component that is not yet mounted. " +
350+
"Can't call setState on a component that is not yet mounted. " +
351351
'This is a no-op, but it might indicate a bug in your application. ' +
352352
'Instead, assign to `this.state` directly or define a `state = {};` ' +
353353
'class property with the desired state in the MyComponent component.',
@@ -484,7 +484,7 @@ describe('ReactCompositeComponent', () => {
484484
});
485485
}).rejects.toThrow(TypeError);
486486
}).toErrorDev(
487-
'Warning: The <ClassWithRenderNotExtended /> component appears to have a render method, ' +
487+
'The <ClassWithRenderNotExtended /> component appears to have a render method, ' +
488488
"but doesn't extend React.Component. This is likely to cause errors. " +
489489
'Change ClassWithRenderNotExtended to extend React.Component instead.',
490490
);
@@ -631,7 +631,7 @@ describe('ReactCompositeComponent', () => {
631631
instance.setState({bogus: true});
632632
});
633633
}).toErrorDev(
634-
'Warning: ClassComponent.shouldComponentUpdate(): Returned undefined instead of a ' +
634+
'ClassComponent.shouldComponentUpdate(): Returned undefined instead of a ' +
635635
'boolean value. Make sure to return true or false.',
636636
);
637637
});
@@ -651,7 +651,7 @@ describe('ReactCompositeComponent', () => {
651651
root.render(<Component />);
652652
});
653653
}).toErrorDev(
654-
'Warning: Component has a method called ' +
654+
'Component has a method called ' +
655655
'componentDidUnmount(). But there is no such lifecycle method. ' +
656656
'Did you mean componentWillUnmount()?',
657657
);
@@ -673,7 +673,7 @@ describe('ReactCompositeComponent', () => {
673673
root.render(<Component />);
674674
});
675675
}).toErrorDev(
676-
'Warning: Component has a method called ' +
676+
'Component has a method called ' +
677677
'componentDidReceiveProps(). But there is no such lifecycle method. ' +
678678
'If you meant to update the state in response to changing props, ' +
679679
'use componentWillReceiveProps(). If you meant to fetch data or ' +
@@ -699,7 +699,7 @@ describe('ReactCompositeComponent', () => {
699699
root.render(<Component />);
700700
});
701701
}).toErrorDev(
702-
'Warning: Setting defaultProps as an instance property on Component is not supported ' +
702+
'Setting defaultProps as an instance property on Component is not supported ' +
703703
'and will be ignored. Instead, define defaultProps as a static property on Component.',
704704
);
705705
});
@@ -1199,9 +1199,9 @@ describe('ReactCompositeComponent', () => {
11991199
});
12001200
}).rejects.toThrow();
12011201
}).toErrorDev([
1202-
'Warning: No `render` method found on the RenderTextInvalidConstructor instance: ' +
1202+
'No `render` method found on the RenderTextInvalidConstructor instance: ' +
12031203
'did you accidentally return an object from the constructor?',
1204-
'Warning: No `render` method found on the RenderTextInvalidConstructor instance: ' +
1204+
'No `render` method found on the RenderTextInvalidConstructor instance: ' +
12051205
'did you accidentally return an object from the constructor?',
12061206
]);
12071207
});
@@ -1239,9 +1239,9 @@ describe('ReactCompositeComponent', () => {
12391239
});
12401240
}).rejects.toThrow();
12411241
}).toErrorDev([
1242-
'Warning: No `render` method found on the RenderTestUndefinedRender instance: ' +
1242+
'No `render` method found on the RenderTestUndefinedRender instance: ' +
12431243
'you may have forgotten to define `render`.',
1244-
'Warning: No `render` method found on the RenderTestUndefinedRender instance: ' +
1244+
'No `render` method found on the RenderTestUndefinedRender instance: ' +
12451245
'you may have forgotten to define `render`.',
12461246
]);
12471247
});

packages/react-dom/src/__tests__/ReactCompositeComponentState-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ describe('ReactCompositeComponent-state', () => {
474474
root.render(<Test />);
475475
});
476476
}).toErrorDev(
477-
'Warning: Test.componentWillReceiveProps(): Assigning directly to ' +
477+
'Test.componentWillReceiveProps(): Assigning directly to ' +
478478
"this.state is deprecated (except inside a component's constructor). " +
479479
'Use setState instead.',
480480
);
@@ -523,7 +523,7 @@ describe('ReactCompositeComponent-state', () => {
523523
root.render(<Test />);
524524
});
525525
}).toErrorDev(
526-
'Warning: Test.componentWillMount(): Assigning directly to ' +
526+
'Test.componentWillMount(): Assigning directly to ' +
527527
"this.state is deprecated (except inside a component's constructor). " +
528528
'Use setState instead.',
529529
);
@@ -571,7 +571,7 @@ describe('ReactCompositeComponent-state', () => {
571571
root.render(<B />);
572572
});
573573
}).toErrorDev(
574-
"Warning: Can't perform a React state update on a component that hasn't mounted yet",
574+
"Can't perform a React state update on a component that hasn't mounted yet",
575575
);
576576
});
577577

packages/react-dom/src/__tests__/ReactDOM-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ describe('ReactDOM', () => {
198198
);
199199
}).toErrorDev(
200200
[
201-
'Warning: Expected the last optional `callback` argument to be a function. Instead received: no.',
202-
'Warning: Expected the last optional `callback` argument to be a function. Instead received: no.',
201+
'Expected the last optional `callback` argument to be a function. Instead received: no.',
202+
'Expected the last optional `callback` argument to be a function. Instead received: no.',
203203
],
204204
{withoutStack: 2},
205205
);

packages/react-dom/src/__tests__/ReactDOMAttribute-test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe('ReactDOM unknown attribute', () => {
110110
root.render(<div inert="" />);
111111
});
112112
}).toErrorDev([
113-
'Warning: Received an empty string for a boolean attribute `inert`. ' +
113+
'Received an empty string for a boolean attribute `inert`. ' +
114114
'This will treat the attribute as if it were false. ' +
115115
'Either pass `false` to silence this warning, or ' +
116116
'pass `true` if you used an empty string in earlier versions of React to indicate this attribute is true.',
@@ -137,7 +137,7 @@ describe('ReactDOM unknown attribute', () => {
137137

138138
it('coerces NaN to strings and warns', async () => {
139139
await expect(() => testUnknownAttributeAssignment(NaN, 'NaN')).toErrorDev(
140-
'Warning: Received NaN for the `unknown` attribute. ' +
140+
'Received NaN for the `unknown` attribute. ' +
141141
'If this is expected, cast the value to a string.\n' +
142142
' in div (at **)',
143143
);
@@ -170,14 +170,14 @@ describe('ReactDOM unknown attribute', () => {
170170
await expect(() =>
171171
expect(test).rejects.toThrowError(new TypeError('prod message')),
172172
).toErrorDev(
173-
'Warning: The provided `unknown` attribute is an unsupported type TemporalLike.' +
173+
'The provided `unknown` attribute is an unsupported type TemporalLike.' +
174174
' This value must be coerced to a string before using it here.',
175175
);
176176
});
177177

178178
it('removes symbols and warns', async () => {
179179
await expect(() => testUnknownAttributeRemoval(Symbol('foo'))).toErrorDev(
180-
'Warning: Invalid value for prop `unknown` on <div> tag. Either remove it ' +
180+
'Invalid value for prop `unknown` on <div> tag. Either remove it ' +
181181
'from the element, or pass a string or number value to keep it ' +
182182
'in the DOM. For details, see https://react.dev/link/attribute-behavior \n' +
183183
' in div (at **)',
@@ -188,7 +188,7 @@ describe('ReactDOM unknown attribute', () => {
188188
await expect(() =>
189189
testUnknownAttributeRemoval(function someFunction() {}),
190190
).toErrorDev(
191-
'Warning: Invalid value for prop `unknown` on <div> tag. Either remove ' +
191+
'Invalid value for prop `unknown` on <div> tag. Either remove ' +
192192
'it from the element, or pass a string or number value to ' +
193193
'keep it in the DOM. For details, see ' +
194194
'https://react.dev/link/attribute-behavior \n' +

0 commit comments

Comments
 (0)