samedi 24 novembre 2018

Creating documents via mocha test

I'm trying to create documents by creating loop via mocha. It shows that it pass the tests but when I check it on the database it doesn't have any documents. The apps is working if it is done manually but not it the case when I use the mocha. Here's the setup. Btw I'm not really sure if this setup will going to work I just tried and I wanted to know if it is really possible.

const chaiHttp = require('chai-http');
const chai = require('chai');
const assert = chai.assert;
const server = require('../server');

chai.use(chaiHttp);

describe('API ROUTE FOR /api/threads/:board', () => {

  for (let i = 0; i < 10; i++) {
    it('POST', (done) => {
      chai.request(server)
        .post('/api/threads/211')
        .send({ text: 'yeah', delete_password: '12341' })
        .end((err, res) => {
          assert.equal(res.status, 200);
          console.log(res);  
        })

      done();
    });
  }
})

Aucun commentaire:

Enregistrer un commentaire