vendredi 9 avril 2021

How to read describe and it titles of test files?

I'm trying to read the titles of 'describe' and 'it' from a test file used on mocha. I tried to find it on the flow of the mocha module, but since it's written in TypeScript and I know only Javascript I'm not being able to figure it out.

I want to extract from a main.test.js file, for example, all of it's'describes' and 'its'.

describe('Array', function() {
  describe('#indexOf()', function() {
    it('should return -1 when the value is not present', function() {
      assert.equal([1, 2, 3].indexOf(4), -1);
    });
  });
});

For the code above, I'd extract the describes 'Array' and '#indexOf()' and the it 'should return -1 when the value is not present'.

Is there a way of doing it in Javascript?

Aucun commentaire:

Enregistrer un commentaire