Comments (3)
Hey @bonchuk, could you make it easier to help by sending a minimal sample GitHub repository?
from playwright.
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:
- Set up a React component test with Playwright.
- Include a BoxLayout component with an to render BoxScreen.
- Use BrowserRouter and await page.evaluate(() => {
window.history.pushState({}, '', '/com/box/');
}); before mount to simulate the URL /:language/box/. - 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.
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)
- [Feature]: Visible option for locators HOT 1
- [Feature]: Trace Viewer: add baseURL to meta data
- [Docs]: Closing all contexts also disconnects the entire browser HOT 2
- [Bug]: FillAsync Cannot type text into input[type=number] HOT 1
- Unable to use Test.use() at individual test level HOT 5
- [Bug]: Reporter list print step broken on version 1.45.1 HOT 4
- [Feature]: option to set a timeout in the playwright library, not only the test-runner HOT 1
- [Bug]: Live Debugger Don't Work with New Tabs
- [internal] improve react code in UI mode, trace viewer and html report HOT 3
- [Bug]: AddInitScript not injecting Script correctly HOT 3
- [Feature]: expect.toPass failure output should include last inner error output HOT 2
- [Bug]: Control border not fully visible with headless false (Firefox) HOT 5
- Unable to launch the browser on aws lambda even though the browser launch works fine on same image of docker on local machine HOT 2
- How to get Annotations to display in Azure test results HOT 1
- [Feature]: WaitForCondition Should Return Result As Boolean HOT 1
- [Bug]: `getByLabel` only matches element labelled by first label found when `id` is repeated HOT 3
- [Bug]: `getByRole` doesn't match properly with multiple exact labels with the same `id` HOT 3
- Is there a way to turn off videos on any specs in a certain folder? HOT 3
- "Error: locator.click: Target page, context or browser has been closed". in 2nd iteration in typescript HOT 1
- page.selectOption: TypeError: element.tagName.toUpperCase is not a function HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from playwright.