Coder Social home page Coder Social logo

Comments (3)

sand4rt avatar sand4rt commented on July 4, 2024 2

Hey @bonchuk, could you make it easier to help by sending a minimal sample GitHub repository?

from playwright.

bonchuk avatar bonchuk commented on July 4, 2024

Description:
I am experiencing an issue with rendering the component from react-router-dom in my Playwright component tests. Specifically, I have a BoxLayout component that includes an , which should render the BoxScreen component when the URL matches /:language/basket/. However, the BoxScreen component is never shown during testing.

Expected Behavior:
The BoxScreen component should render correctly within the BoxLayout when the URL is /:language/box/.

Current Behavior:
The BoxScreen component does not render, and I am unable to verify its presence in the test.

Steps to Reproduce:

  1. Set up a React component test with Playwright.
  2. Include a BoxLayout component with an to render BoxScreen.
  3. Use BrowserRouter and await page.evaluate(() => {
    window.history.pushState({}, '', '/com/box/');
    }); before mount to simulate the URL /:language/box/.
  4. Observe that the BoxScreen component does not render.

test snippet:
test.only('box-empty @theme', async ({ mount }, testInfo) => { await page.evaluate(() => { window.history.pushState({}, '', '/com/box/'); }); const component = await mount( <WrapperForTests> <boxContext.Provider value={context}> <boxLayout /> </boxContext.Provider> </WrapperForTests>, ); const screenshot = await component.screenshot(); expect(screenshot).toMatchSnapshot(); }); });

Additional Information:

Library Versions:
react-router-dom: [6.11.2]
@playwright/experimental-ct-react: [1.39.0]
@playwright/test: [1.39.0],

Environment:
Node.js version: [v21.7.3]
npm version: [10.8.1]
Operating System: [ubuntu 22.04]

Request:
Could you please provide guidance on how to correctly render components nested within using playwright and react-router-dom in component tests? Any help or examples would be greatly appreciated.

from playwright.

yury-s avatar yury-s commented on July 4, 2024

We need to be able to reproduce the problem to make this report actionable. Please file a new bug and provide a minimal reproducible example which we could run locally.

from playwright.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.