Horje
how to write unit test cases in react js Code Example
how to write unit test cases in react js
# Given a component
import React from 'react';
const Hi = ({ userName }) => (
  <div className="sayhello">Howdy, {userName}!</div>
);
export default Hi;

# Install required deps
npm install --save-dev riteway

# Unit test
import React from 'react';
import { describe } from 'riteway';
import render from 'riteway/render-component';
import match from 'riteway/match';
import Hi from '../hi';
describe('Hi component', async assert => {
  const userName = 'MeMyself';
  const $ = render(<Hello userName={userName} />);
  const contains = match($('.sayhello').html());
  assert({
    given: 'A user',
    should: 'It should render a correct username.',
    actual: contains(userName),
    expected: `Hi, ${userName}!`
  });
});




Javascript

Related
react notification Code Example react notification Code Example
GET IP ADDRESS GEO DATA IN JAVASCRIPT Code Example GET IP ADDRESS GEO DATA IN JAVASCRIPT Code Example
turf greatcircle example Code Example turf greatcircle example Code Example
title after load undefined nuxtjs Code Example title after load undefined nuxtjs Code Example
js fill array with count elements Code Example js fill array with count elements Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8