Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] undefined: Maximum call stack size exceeded with I18nextProvider #19498

Closed
zkrzyzanowski opened this issue Dec 16, 2022 · 1 comment
Closed

Comments

@zkrzyzanowski
Copy link

zkrzyzanowski commented Dec 16, 2022

Context:

  • Playwright Version: 1.26.1
  • Operating System: mac
  • Node.js version: 16.17.0
  • Browser: chromium
  • Extra:

Code Snippet

import { test, expect } from '@playwright/experimental-ct-react';
import SomeComponent from '../../components/some_component';
import { I18nextProvider } from 'react-i18next';
import i18n from '../../i18n/i18n';

test.use({ viewport: { width: 500, height: 500 } });

test('should work', async ({ mount }) => {
  const component = await mount(
    <I18nextProvider i18n={i18n}>
      <SomeComponent />
    </I18nextProvider>
  );

  await expect(component).toContainText('some text here');
});

Describe the bug

When running a component test using I18nextProvider from react-i18next, I'd expect the provider to be available and translated text to be shown.

playwright test

expected:
• passing test

actual:

Running 1 test using 1 worker

  ✘  1 [chromium] › tests/components/component.spec.tsx:9:1 › should work (1s)


  1) [chromium] › tests/components/component.spec.tsx:9:1 › should work ======

    undefined: Maximum call stack size exceeded

       at ../../node_modules/.pnpm/@playwright+test@1.26.1/node_modules/@playwright/test/lib/mount.js:48

      46 |   }, use) => {
      47 |     await use(async (component, options) => {
    > 48 |       const selector = await page._wrapApiCall(async () => {
         |                                   ^
      49 |         return await innerMount(page, component, options);
      50 |       }, true);
      51 |       const locator = page.locator(selector);

     
@zkrzyzanowski
Copy link
Author

Figured it out based on this issue

Moving the provider out to its own tsx file like so

import { I18nextProvider } from 'react-i18next';
import i18n from '../../i18n/i18n';

export const WrappedComponent = ({ children }: { children: JSX.Element }) => {
  return <I18nextProvider i18n={i18n}>{children}</I18nextProvider>;
};

and WrappedComponent into the .spec.tsx file allows the test to pass successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant