make the act() expecting test more robust to variations, and fix missing await

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-03-21 09:37:46 +01:00
parent 3043e8f4f4
commit 9c6e849d1c
2 changed files with 8 additions and 9 deletions
@@ -48,14 +48,13 @@ describe('wrapInTestApp', () => {
await Promise.resolve();
});
expect(error).toEqual([
expect.stringMatching(
/^Warning: An update to %s inside a test was not wrapped in act\(...\)/,
expect(
error.some(e =>
e.includes(
'Warning: An update to %s inside a test was not wrapped in act(...)',
),
),
expect.stringMatching(
/^Warning: An update to %s inside a test was not wrapped in act\(...\)/,
),
]);
).toBeTruthy();
});
it('should render a component in a test app without warning about missing act()', async () => {
@@ -24,7 +24,7 @@ describe('Trend', () => {
const rendered = await renderInTestApp(
<Trend data={data} title={title} color="#000" />,
);
expect(rendered.findAllByText('testTitle')).toBeTruthy();
expect(await rendered.findAllByText('testTitle')).toBeTruthy();
});
it('should render empty state', async () => {
@@ -32,6 +32,6 @@ describe('Trend', () => {
const rendered = await renderInTestApp(
<Trend title={title} color="#000" />,
);
expect(rendered.findAllByText('testTitle')).toBeTruthy();
expect(await rendered.findAllByText('testTitle')).toBeTruthy();
});
});