Skip to content

MarisaAfuera/exampleMochaChai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents

  1. General Info
  2. Repository content
  3. Technologies
  4. Installation
  5. Try the example

General Info


This is an example of a unit test of javascript file. The target of this file is to get users thru the API located in https://dummyapi.io/data/api

Repository content

File Content description
readUsers.js Subject under test
readUsers.test.js test
/exceptions/notFound.js error manager
/exceptions/validation.js error manager
package.json dependencies. Use by npm install command

Technologies


A list of technologies used within the project:

Installation


To try this example is necessary install node. Then:

$ git clone https://github.com/MarisaAfuera/exampleMochaChai.git
$ cd exampleMochaChai
$ npm install
$ npm start

Try the example


Execute the command:

mocha readUsers.test.js 

You'll see the test result:

  readUsers: 
    getResource
      √ should throw a ValidationError when the resource is empty
      √ should throw a NotFoundError when the resource is not found (77ms)
      √ should fetch requested resource (642ms)
      √ should throw a NotFoundError with the given identifier when resource is not found
      √ should fetch a user with the given id (987ms)

  5 passing (2s)

About

Javascript test example with Mocha and Chai

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published