supertest mocha Why I get success test passing although expected fails?

14 Views Asked by At

I use supertest and mocha and all works but I got one problem. If I use the expect function and it fails my test says still its passing but this is false it should show an error and not passed. What I am doing wrong ?

 
  Create Tenant Account
    Login to a user who is Admin
POST /api/auth/sign_in 200 745.330 ms - 3341
AssertionError: expected { isAdmin: true, …(4) } to have own property 'isAdm21221in'
    at file:///C:/Users/rambo/Desktop/psm-solution/backend/test/createTenant.test.js:34:28
    at processTicksAndRejections (node:internal/process/task_queues:95:5) {
  actual: {
    isAdmin: true,
    isTenantAdmin: true,
    provider: 'email',
    providers: [ 'email' ],
    tenantId: 'f997ca0e-9bed-4550-a115-1175ff1406e7'
  },
  expected: undefined,
  showDiff: false
}
      ✔ should login to a user and recieve a 200 http status code (970ms)


  1 passing (994ms)

You see AssertionError and the expected fails but then you see at the bottom 1 passing so it succeed. it should fail here is my code

import supertest from 'supertest';
import { app, supabase } from '../src/server.ts';
import { expect } from 'chai';

describe('Create Tenant Account', () => {

  describe('Login to a user who is Admin', () => {
    it('should login to a user and recieve a 200 http status code', done => {
      supertest(app)
      .post('/api/auth/sign_in')
      .send({email: '[email protected]', password: '123456'})
      .then(res => {

        expect(appmeta).to.haveOwnProperty('isAdm21221in');
        expect(res.statusCode).to.equal(200);
      
        done();
      })
      .catch(e => {
        console.log(e);
        done();
      });
    });
  });

});
0

There are 0 best solutions below