Documentation
Templates
TypeScript
React
Unit Test

Unit Test

Jest

React DOM

import React from 'react'
import ReactDOM from 'react-dom'
 
import { ResourceName } from 'resourcePath'
 
describe('ResourceName', () => {
  it('renders without crashing', () => {
    const div = document.createElement('div')
 
    ReactDOM.render(<ResourceName />, div)
  })
})

Testing Library

import { render, screen } from '@testing-library/react'
 
import { ResourceName } from 'resourcePath'
 
describe('ResourceName', () => {
  it('renders welcome message', () => {
    render(<ResourceName />)
 
    expect(
      screen.getByText("Hello, I'm a component, auto generated by Clingon CLI!")
    ).toBeInTheDocument()
  })
})

Vitest

React DOM

import React from 'react'
import ReactDOM from 'react-dom'
 
import { describe, it, expect } from 'vitest'
 
import { ResourceName } from 'resourcePath'
 
describe('ResourceName', () => {
  it('renders without crashing', () => {
    const div = document.createElement('div')
 
    const element = ReactDOM.render(<ResourceName />, div)
 
    expect(element).toBeDefined()
  })
})

Testing Library

import { render, screen } from '@testing-library/react'
import { describe, it, expect } from 'vitest'
 
import { ResourceName } from 'resourcePath'
 
describe('ResourceName', () => {
  it('renders welcome message', () => {
    render(<ResourceName />)
 
    expect(
      screen.getByText("Hello, I'm a component, auto generated by Clingon CLI!")
    ).toBeInTheDocument()
  })
})