test fixes to support Jest 29

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-09-05 23:26:34 +02:00
parent fe535a86da
commit 2e4e6c3500
15 changed files with 58 additions and 36 deletions
-1
View File
@@ -27,7 +27,6 @@ const envOptions = {
const transformIgnorePattern = [
'@material-ui',
'@rjsf',
'ajv',
'core-js',
'jest-.*',
@@ -118,9 +118,10 @@ describe('ApiProvider', () => {
}).toThrow(/^API context is not available/);
}).error,
).toEqual([
expect.stringMatching(
/^Error: Uncaught \[Error: API context is not available/,
),
expect.objectContaining({
detail: new Error('API context is not available'),
type: 'unhandled exception',
}),
expect.stringMatching(
/^The above error occurred in the <MyHookConsumer> component/,
),
@@ -133,9 +134,10 @@ describe('ApiProvider', () => {
}).toThrow(/^API context is not available/);
}).error,
).toEqual([
expect.stringMatching(
/^Error: Uncaught \[Error: API context is not available/,
),
expect.objectContaining({
detail: new Error('API context is not available'),
type: 'unhandled exception',
}),
expect.stringMatching(
/^The above error occurred in the <withApis\(Component\)> component/,
),
@@ -154,9 +156,10 @@ describe('ApiProvider', () => {
}).toThrow('No implementation available for apiRef{x}');
}).error,
).toEqual([
expect.stringMatching(
/^Error: Uncaught \[Error: No implementation available for apiRef{x}\]/,
),
expect.objectContaining({
detail: new Error('No implementation available for apiRef{x}'),
type: 'unhandled exception',
}),
expect.stringMatching(
/^The above error occurred in the <MyHookConsumer> component/,
),
@@ -173,9 +176,10 @@ describe('ApiProvider', () => {
}).toThrow('No implementation available for apiRef{x}');
}).error,
).toEqual([
expect.stringMatching(
/^Error: Uncaught \[Error: No implementation available for apiRef{x}\]/,
),
expect.objectContaining({
detail: new Error('No implementation available for apiRef{x}'),
type: 'unhandled exception',
}),
expect.stringMatching(
/^The above error occurred in the <withApis\(Component\)> component/,
),
@@ -47,9 +47,11 @@ describe('TabbedLayout', () => {
});
expect(error).toEqual([
expect.stringMatching(
/Child of TabbedLayout must be an TabbedLayout.Route/,
),
expect.objectContaining({
detail: new Error(
'Child of TabbedLayout must be an TabbedLayout.Route',
),
}),
expect.stringMatching(
/The above error occurred in the <TabbedLayout> component/,
),
@@ -67,7 +67,9 @@ describe('<ErrorBoundary/>', () => {
});
expect(error).toEqual([
expect.stringMatching(/^Error: Uncaught \[Error: Bomb\]/),
expect.objectContaining({
detail: new Error('Bomb'),
}),
expect.stringMatching(
/^The above error occurred in the <Bomb> component:/,
),
@@ -29,7 +29,7 @@ const validBackstageToken =
describe('ProxiedSignInIdentity', () => {
describe('tokenToExpiry', () => {
beforeEach(() => jest.useFakeTimers('modern'));
beforeEach(() => jest.useFakeTimers());
afterEach(() => jest.useRealTimers());
it('handles undefined', async () => {
@@ -56,7 +56,7 @@ describe('ProxiedSignInIdentity', () => {
});
describe('ProxiedSignInIdentity', () => {
beforeEach(() => jest.useFakeTimers('modern'));
beforeEach(() => jest.useFakeTimers());
afterEach(() => jest.useRealTimers());
const worker = setupServer();
@@ -117,7 +117,7 @@ describe('extensions', () => {
render(<BrokenComponent />);
});
screen.getByText('Error in my-plugin');
expect(errors[0]).toMatch('Test error');
expect(errors[0]).toMatchObject({ detail: new Error('Test error') });
});
it('should wrap extended component with analytics context', async () => {
+1 -1
View File
@@ -62,7 +62,7 @@ describe('isValidHost', () => {
['[::]', true],
['[::1]', true],
['[1:2:3:4:5:6:7:8]', true],
['1.2.3.4.5.6.7.8', true],
['1.2.3.4.5.6.7.8', false],
['https://example.com', false],
['foo:100000', false],
['FOO', false],
@@ -92,9 +92,11 @@ describe('wrapInTestApp', () => {
});
expect(error).toEqual([
expect.stringMatching(
/^Error: Uncaught \[Error: MockErrorApi received unexpected error, Error: NOPE\]/,
),
expect.objectContaining({
detail: new Error(
'MockErrorApi received unexpected error, Error: NOPE',
),
}),
expect.stringMatching(/^The above error occurred in the <A> component:/),
]);
});