Skip to content

Commit ab507bc

Browse files
committed
update test
1 parent 66ed321 commit ab507bc

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

packages/render/src/edge-light/render.spec.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* @vitest-environment jsdom
3+
*/
4+
15
import { Preview } from '../shared/utils/preview';
26
import { Template } from '../shared/utils/template';
37
import { render } from './render';
@@ -8,25 +12,29 @@ type Import = typeof import('react-dom/server') & {
812

913
describe('render on the edge', () => {
1014
beforeAll(() => {
11-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-extraneous-class
1215
global.MessageChannel = class {
1316
constructor() {
1417
throw new Error('MessageChannel is not supported');
1518
}
16-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1719
} as any;
1820
});
1921

22+
afterEach(() => {
23+
vi.resetAllMocks();
24+
});
25+
2026
it('converts a React component into HTML with Next 14 error stubs', async () => {
21-
vi.mock('react-dom/server', async () => {
22-
const ReactDOMServer = await vi.importActual<Import>('react-dom/server');
27+
vi.mock('react-dom/server', async (_importOriginal) => {
28+
const ReactDOMServerBrowser = await vi.importActual<Import>(
29+
'react-dom/server.browser',
30+
);
2331
const ERROR_MESSAGE =
2432
'Internal Error: do not use legacy react-dom/server APIs. If you encountered this error, please open an issue on the Next.js repo.';
2533

2634
return {
27-
...ReactDOMServer,
35+
...ReactDOMServerBrowser,
2836
default: {
29-
...ReactDOMServer.default,
37+
...ReactDOMServerBrowser,
3038
renderToString() {
3139
throw new Error(ERROR_MESSAGE);
3240
},
@@ -48,12 +56,10 @@ describe('render on the edge', () => {
4856
expect(actualOutput).toMatchInlineSnapshot(
4957
`"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><link rel="preload" as="image" href="img/test.png"/><!--$--><h1>Welcome, <!-- -->Jim<!-- -->!</h1><img alt="test" src="img/test.png"/><p>Thanks for trying our product. We&#x27;re thrilled to have you on board!</p><!--/$-->"`,
5058
);
51-
52-
vi.resetAllMocks();
5359
});
5460

5561
// This is a test to ensure we have no regressions for https://github.com/resend/react-email/issues/1667
56-
it('should handle characters with a higher byte count gracefully in React 18', async () => {
62+
it('should handle characters with a higher byte count gracefully', async () => {
5763
const actualOutput = await render(
5864
<>
5965
<p>Test Normal 情報Ⅰコース担当者様</p>

0 commit comments

Comments
 (0)