Skip to content

gabrielogregorio/docbytest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

version 0.2

Codacy Badge Codacy Badge

Introduction

This is a library that generates the documentation of an API based initially on integration tests with supertest!

๐Ÿš€ Example Code in pratic

For NPM/Yarn users

Do you need install docbytest and docbytest-ui

npm i docbytest docbytest-ui

or

yarn add docbytest docbytest-ui

Use docbytest example api for reference for project.

Write your tests

Create tests with this pattern

use 2 spaces in your code!!!

/* 1 is order show cases*/
describe('[1] ๐Ÿ™‹ Suggestions', () => {
  /* doc:
    your comments from suit
  */

  test('[doc]: โœ… send suggestions', async () => {
  /* doc: your comments from all tests */

    const suggestionId = 123456
    const res = await request.put(`/suggestion/${suggestionId}`).send({
      title: 'new title',
      body: 'new body'
    });

    // success example
    expect(res.statusCode).toEqual(200);
    expect(mock.body.id).toBeDefined()

    const mock = {body: {...res.body, id: 123456}}

    expect(mock.body).toEqual({
      id: 123456,
      title: 'new title',
      body: 'new body'
    });
  });

  it('[doc]: ๐Ÿšซ block suggestion without parameters', async () => {
    const suggestionId = 123456
    const res = await request.put(`/suggestion/${suggestionId}`).send({});

    expect(res.statusCode).toEqual(400);

    expect(re.body).toEqual({
      message: 'bad Request'
    });
  });

  test('tests not docs', async () => {
    // ....
  });
});

Example CI in Github