-
We are trying to use the tools for testing that you offer in
An example of a simple test that we are writing is: describe('AppTest', () => {
let element: AppIndex;
beforeEach(async () => {
element = await fixture(html`
<app-index></app-index>
`);
});
it('renders a h1', () => {
const h1 = element.shadowRoot!.querySelector('h1')!;
expect(h1).to.exist;
expect(h1.textContent).to.equal('About');
});
}); Our
So we are a little stuck trying to figure out how we can run the application navigate to an end-point and test there something like: describe('AppTest', () => {
beforeEach(async () => {
browser().goTo('/about');
});
it('renders a h1', () => {
// Just test here something in the about page
});
}); Thanks community! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
if you have a state property for those pages like
then you could test that. However, it seems more like you want to have end to end testing which is a browser actually opening your running application and you do some expects on what the browser sees. for that using for example playwright + node moch seems more appropriate. see some examples at the playwright homepage the way that would work with web dev server would be to run those in parallel (for example with https://www.npmjs.com/package/concurrently)
The playwright-cli even has a tool which records your interactions and creates a test file automatically another popular tool would be https://www.cypress.io/ |
Beta Was this translation helpful? Give feedback.
-
To clarify, web test runner runs your tests in the browser itself and not with a remote controlled browser like selenium, puppeteer or playwright. You can test it the way @daKmoR explains, but if it's a single page app you can still test your app with WTR. You need to make sure your router is initialized properly, and you make changes to the URL in a way your router expects. This is different for each router. You also need to make sure you initialize your application properly like you mentioned. Again this is different for each application. What is loaded in your index.html? |
Beta Was this translation helpful? Give feedback.
-
We were trying different configurations investigating a little bit about As a test we tried too configure without |
Beta Was this translation helpful? Give feedback.
if you have a state property for those pages like
then you could test that.
However, it seems more like you want to have end to end testing which is a browser actually opening your running application and you do some expects on what the browser sees.
for that using for example playwright + node moch seems more appropriate.
see some examples at the playwright homepage
https://playwright.dev/#version=v1.5.1&path=docs%2Ftest-runners.md&q=test-runners
the way that would work with web dev server would be to run those in parallel (for example with https://www.npmjs.com/package/concurrently)
T…