digitalbazaar / mocha-w3c-interop-reporter

Mocha W3C Interoperability Test Suite reporter
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Add the ability for a describe statement to contain multiple matrixes/tables #5

Open aljones15 opened 2 years ago

aljones15 commented 2 years ago

Right now this library creates a table or matrix in a report if a describe statement contains this.report = true. This results in using a for loop inside of that describe statement to construct a single table in a report. This is inefficient in cases where we might want to construct multiple matrixes/tables in a report from a single async resource such as a REST API.

Add the ability to do something like this:

describe('multiple tests', function() {
  this.report = true;
  this.tables = ['foo'];
  this.matrixes = ['bar'];
  for(const [name, implementation] of implementations) {
    let vc;
    before(async function() {
      vc = await implementation.issuer[0].issue({body});
     });
    describe('test one', function() {
      it('test one assertion', function() {
         this.test.cell = {rowId: this.test.title, columnId: name, testId: 'foo'}
       })
    })
    describe('test two', function() {
      it('test two assertion', function() {
         this.test.cell = {rowId: this.test.title, columnId: name, testId: 'bar'}
       })
    })
  }
})

In the above example one call on the issuer is used in 2 different tables/matrixes. In the current implementation this would require each describe statement to iterate through every implementation.

p.s. this could also be done as part of the --parallel rewrite and remove the need to mutate mocha's suite and test objects with reporter details.