How to use the supertest function in supertest

To help you get started, we’ve selected a few supertest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CloudBreadProject / CloudBread-Socket / tests / server.spec.js View on Github external
it('says hello worlds!', done => {
    request(server)
      .get('/')
      .expect(200, done);
  });
});
github jembi / openhim-core-js / test / integration / auditAPITests.js View on Github external
it('should only allow admin users to add audits', async () => {
        await request(constants.BASE_URL)
          .post('/audits')
          .set('auth-username', testUtils.nonRootUser.email)
          .set('auth-ts', authDetails.authTS)
          .set('auth-salt', authDetails.authSalt)
          .set('auth-token', authDetails.authToken)
          .send(auditData)
          .expect(403)
      })
    })
github jembi / openhim-core-js / test / integration / clientsAPITests.js View on Github external
it('should not allow a non admin user to remove a client', async () => {
        await request(constants.BASE_URL)
          .del('/clients/000000000000000000000000')
          .set('auth-username', testUtils.nonRootUser.email)
          .set('auth-ts', authDetails.authTS)
          .set('auth-salt', authDetails.authSalt)
          .set('auth-token', authDetails.authToken)
          .expect(403)
      })
    })
github TossShinHwa / node-odata / test / odata.query.filter.functions.js View on Github external
it('should filter items', async function() {
      const res = await request(host).get(`/book?$filter=year(publish_date) eq 2000`); 
        res.body.value.length.should.greaterThan(0);
        res.body.value.should.matchEach((item) => new Date(item.publish_date).getFullYear() === 2000);
    });
  });
github auth0-extensions / auth0-sso-dashboard-extension / tests / server / routes / connections.tests.js View on Github external
it('should return list of connections', (done) => {
      request(app)
        .get('/connections')
        .expect('Content-Type', /json/)
        .expect(200)
        .end((err, res) => {
          if (err) throw err;
          expect(res.body).toEqual(defaultConnections);
          done();
        });
    });
  });
github scttcper / koa-simple-ratelimit / test / index.spec.ts View on Github external
.end(() => {
            request(listen)
              .get('/')
              .expect(200, `${goodBody}2`)
              .expect(routeHitTwice)
              .end(done);
          });
      }, rateLimitDuration * 2);
github TossShinHwa / node-odata / test / odata.actions.js View on Github external
function requestToHalfPrice(id) {
  return request(host).post(`/book(${id})/50off`);
}
github wisnuc / appifi / test / fruitmix / agent / share.js View on Github external
const swm = (token, callback) => 
    request(app)
      .get('/share/sharedWithMe')
      .set('Authorization', 'JWT ' + token)
      .set('Accept', 'application/json')
      .expect(200)
      .end((err, res) => 
        err ? callback(err) : callback(null, res.body))
github voluntarily / vly2 / server / api / goal / __tests__ / goal.spec.js View on Github external
test.serial('Should correctly select just the names and ids', async t => {
  const query = {
    q: JSON.stringify({ category: 'Getting Started' }),
    p: 'slug imgUrl category'
  }
  const res = await request(server)
    .get(`/api/goals?${queryString(query)}`)
    .set('Accept', 'application/json')
    .expect(200)
    .expect('Content-Type', /json/)
  const got = res.body
  t.is(got.length, 2)
  t.is(got[0].name, undefined)
  t.is(got[0].slug, 'goal-complete-profile')
})
github VadimDez / watchstocks / server / api / stock / stock.integration.js View on Github external
beforeEach(function(done) {
      request(app)
        .put('/api/stocks/' + newStock._id)
        .send({
          name: 'Updated Stock',
          info: 'This is the updated stock!!!'
        })
        .expect(200)
        .expect('Content-Type', /json/)
        .end(function(err, res) {
          if (err) {
            return done(err);
          }
          updatedStock = res.body;
          done();
        });
    });

supertest

SuperAgent driven library for testing HTTP servers

MIT
Latest version published 13 days ago

Package Health Score

91 / 100
Full package analysis