Testing routes

  1. Setup your test suite

import { screen } from '@testing-library/dom';
import { html, render, Component} from 'vistajs/dom';

const home = Component('app-home', () => {
    return () =>  html`Hello from homepage`
})

const about = Component('app-about', () => {
   return () =>  html`Hello from about page`
})


describe('Router Rendering', () => {
    beforeAll(() => {
      // Start up routes
      routeTesting([
        {
          path: '',
          component: () => home,
        },
        {
          path: 'about',
          component: () => about,
        },
      ]);
  });

  it('should render about page', async () => {});
);

  1. Then, make your assertions

Going further

With route events it's possible to test your app's routing throughout diferent moments of the routing cycle

Example with CHANGE_END:

Last updated