Testing components

You can test your componets in some simple steps

  1. Setup a test suite

describe('Home component', () => {
  
   it('should render', () => {
      
   })
})
  1. Declare and render your component

import { html, render, Component} from 'vistajs/dom';

describe('Home component', () => {
  
   it('should render', () => {
      
      const hello = Component(`app-home`, () => {
        return () => html`Hello World`;
      });
      
      render(document.body, hello)
   })
})
  1. Then, make your assertions

  1. Then, just run your tests

You can go even further by taking a look at DOM Testing Library to learn how to use it for testing your applications besides check out Vitest docs

Last updated