test fixes to support Jest 29
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -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:/),
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user