Jest test fails

Why is my jest mock failing here?
import '@testing-library/jest-dom';
import React, { Fragment } from 'react';

jest.mock('next-i18next', () => ({
Trans: ({ i18nKey, children }) => (
<Fragment>
{i18nKey}
{children}
</Fragment>
),
useTranslation: () => ({
i18n: {
changeLanguage: jest.fn(),
language: 'de',
},
t: key => key,
}),
}));

jest.mock('next/legacy/image', () => ({
__esModule: true,
default: () => 'Next legacy image stub',
}));
jest.mock('next/image', () => ({
__esModule: true,
default: () => 'Next image stub',
}));

window.google = {
maps: {
places: {
Autocomplete: class {},
AutocompleteService: class {},
AutocompleteSessionToken: class {},
PlacesService: class {},
},
},
};
import '@testing-library/jest-dom';
import React, { Fragment } from 'react';

jest.mock('next-i18next', () => ({
Trans: ({ i18nKey, children }) => (
<Fragment>
{i18nKey}
{children}
</Fragment>
),
useTranslation: () => ({
i18n: {
changeLanguage: jest.fn(),
language: 'de',
},
t: key => key,
}),
}));

jest.mock('next/legacy/image', () => ({
__esModule: true,
default: () => 'Next legacy image stub',
}));
jest.mock('next/image', () => ({
__esModule: true,
default: () => 'Next image stub',
}));

window.google = {
maps: {
places: {
Autocomplete: class {},
AutocompleteService: class {},
AutocompleteSessionToken: class {},
PlacesService: class {},
},
},
};
Getting this error
● Test suite failed to run

SyntaxError: /Users/code/myapp_monorepo/apps/main-frontend/jest.setup.js: Unexpected token, expected "," (8:6)

6 | <Fragment>
7 | {i18nKey}
> 8 | {children}
| ^
9 | </Fragment>
10 | ),
11 | useTranslation: () => ({
● Test suite failed to run

SyntaxError: /Users/code/myapp_monorepo/apps/main-frontend/jest.setup.js: Unexpected token, expected "," (8:6)

6 | <Fragment>
7 | {i18nKey}
> 8 | {children}
| ^
9 | </Fragment>
10 | ),
11 | useTranslation: () => ({
1 Reply
Ambushfall
Ambushfall3y ago
There's little to no context here, at least for me. So I've converted it to a TS file, and got the following errors in the image. Please add a bit more context (What framework, what libraries, what's expected, etc.)
Want results from more Discord servers?
Add your server