Skip to content

Nock/supertest example #28

@matthewdking

Description

@matthewdking

@eliasCodes example of nock and supertest

test.only('Testing if successfully called API', (t) => {
  nock('https://api.nasa.gov/planetary/apod')
    .get('?date=2018-03-29&api_key=undefined')
    .reply(200, { planet: 'Jupiter', photographer: 'Lawrence' });

  supertest(router)
    .get('/api/search?2018-03-29')
    .expect(200)
    .end((err, res) => {
      t.deepEqual(res.body, { planet: 'Jupiter', photographer: 'Lawrence' });
      t.end();
    });
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions