-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy patherrorPage.test.jsx
More file actions
53 lines (46 loc) · 1.45 KB
/
errorPage.test.jsx
File metadata and controls
53 lines (46 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { render, screen } from '@testing-library/react';
describe('ErrorPage', () => {
it('renders technical details in preview environments', async t => {
t.mock.module('#site/components/Common/Button', {
defaultExport: ({ children, href }) => <a href={href}>{children}</a>,
});
t.mock.module('#site/layouts/GlowingBackdrop', {
defaultExport: ({ children }) => <main>{children}</main>,
});
t.mock.module('#site/next.constants.mjs', {
namedExports: {
SHOW_ERROR_DETAILS: true,
},
});
const { default: ErrorPage } = await import('../app/[locale]/error.tsx');
render(
<ErrorPage
error={Object.assign(new Error('Preview deployment failed'), {
digest: 'abc123',
})}
/>
);
assert.equal(
screen.getByRole('heading').textContent,
'layouts.error.internalServerError.title'
);
assert.equal(
screen.getByRole('link').textContent,
'layouts.error.backToHome'
);
assert.equal(
screen.getByText('components.downloadReleasesTable.details').textContent,
'components.downloadReleasesTable.details'
);
assert.match(
screen.getByText(/Preview deployment failed/).textContent,
/Preview deployment failed/
);
assert.match(
screen.getByText(/digest: abc123/i).textContent,
/digest: abc123/i
);
});
});