Home > OS >  Mocha Does Not Run Second describe()
Mocha Does Not Run Second describe()

Time:09-21

I am writing a test coverage for my code base and just started using Mocha/Chai for my backend. For whatever reason I can't get my second describe() to run in this function. I don't receive any error, it just exits after running the first describe() suite.

export async function testCreateUnknownCustomer(billCodeTest) {
  let unknownRecordTest;
  describe("Create A Unknown Customer Record", function () {
    it("Creates a new unknown customer", async function () {
      unknownRecordTest = await CustomersController.createUnknownCustomer(
        ' 15555551111',
        billCodeTest
      )
    })
    it('Should Be a Instance of a Sequelize Model', function () {
      expect(unknownRecordTest instanceof Model).equals(true);
    })
  });

  describe("Hard Delete unknown customer record", function () {
    const unknownID = unknownRecordTest.customer_id;
    it("Deletes a customer record", async function () {
      console.log(await unknownRecordTest.destroy());
      console.log(unknownRecordTest);
    }) 
  });
}

CodePudding user response:

Leaving the describes raw in the file seems to have fixed everything. As opposed to wrapping it in a function that is exported and run in a main.test.js execution file. I don't really have a technical explanation why secondary describes wouldn't have executed regardless.

  • Related