How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • import {render, screen, fireEvent} from '@testing-library/angular'
    import {CounterComponent} from './counter.component.ts'
    
    describe('Counter', () => {
      test('should render counter', async () => {
        await render(CounterComponent, {
          componentProperties: {counter: 5},
        })
    
        expect(screen.getByText('Current Count: 5')).toBeInTheDocument()
      })
    
      test('should increment the counter on click', async () => {
        await render(CounterComponent, {
          componentProperties: {counter: 5},
        })
    
        fireEvent.click(screen.getByText('+'))
    
        expect(screen.getByText('Current Count: 6')).toBeInTheDocument()
      })
    })
    Docs
  • import {render, screen, fireEvent} from '@testing-library/angular'
    import {CounterComponent} from './counter.component.ts'
    
    describe('Counter', () => {
      test('should render counter', async () => {
        await render(CounterComponent, {
          componentProperties: {counter: 5},
        })
    
        expect(screen.getByText('Current Count: 5'))
      })
    
      test('should increment the counter on click', async () => {
        await render(CounterComponent, {
          componentProperties: {counter: 5},
        })
    
        fireEvent.click(screen.getByText('+'))
    
        expect(screen.getByText('Current Count: 6'))
      })
    })
    Docs
  • import {Component, NgModule} from '@angular/core'
    import {render, screen} from '@testing-library/angular'
    import {ngMocks} from 'ng-mocks'
    
    @Component({
      selector: 'app-parent-component',
      template: '<app-child-component></app-child-component>',
    })
    class ParentComponent {}
    
    @Component({
      selector: 'app-child-component',
      template: '<p>Child component</p>',
    })
    class ChildComponent {}
    
    @NgModule({
      declarations: [ParentComponent, ChildComponent],
    })
    export class AppModule {}
    
    describe('ParentComponent', () => {
      it('should not render ChildComponent when shallow rendering', async () => {
        const dependencies = ngMocks.guts(null, AppModule, ParentComponent)
    
        await render(ParentComponent, dependencies)
    
        expect(screen.queryByText('Child component')).toBeNull()
      })
    })
    Docs
  • import {render} from '@testing-library/react'
    import '@testing-library/jest-dom'
    
    test('renders a message', () => {
      const {container, getByText} = render(<Greeting />)
      expect(getByText('Hello, world!')).toBeInTheDocument()
      expect(container.firstChild).toMatchInlineSnapshot(`
        <h1>Hello, World!</h1>
      `)
    })
    Docs
  • import React from 'react'
    import {render, screen} from '@testing-library/react'
    import userEvent from '@testing-library/user-event'
    
    test('clear', () => {
      render(<textarea defaultValue="Hello, World!" />)
    
      userEvent.clear(screen.getByRole('textbox'))
      expect(screen.getByRole('textbox')).toHaveValue('')
    })
    Docs
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples