lorenzofox3 / zora

Lightest, yet Fastest Javascript test runner for nodejs and browsers
MIT License
539 stars 93 forks source link

API breaking change request #113

Closed munrocket closed 3 years ago

munrocket commented 3 years ago

Thanks for creating zora-reporters and supporting zora! I am using Zora in all my personal projects! I think it will be cool to change this

import { hold, test, report } from 'zora';
import { createDiffReporter } from 'zora-reporters';

hold();

test('my outstanding tests', t => {
  t.equal(2, 2, '2=2');
});

report({reporter: createDiffReporter()});

To something like this

import { test, withReporter } from 'zora';
import { diffReporter } from 'zora-reporters';

withReporter(diffReporter, () => {

  test('my outstanding tests', t => {
    t.equal(2, 2, '2=2');
  });

});

This hold and report doesn't make sense to me. Anyway I am happy that we have ES6 reporters now.

lorenzofox3 commented 3 years ago

not sure to understand what would be the expected behavior if your tests are spread into various files 🤔 would you have to add the wrapper on every test file ?

You can have something similar in the userland without introducing a breaking change here (and I am more comfortable with that idea ):

// ex: test-utils.js (or can be published as a package on top of zora
import {createHarness} from 'zora';

export withReporter = (reporter) => {
    const harness= createHarness();

   // auto-start reporting if that is what you want:
   setTimeout(() => { harness.report({ reporter }) },0);

   // export the test function or the whole API if needed
   return harness.test;
}

// then in your project: 'test-harness.js'
export const test = withReporter(someReporter);

// and in your spec files
import {test} from './test-harness.js';

/*

test(`...`, t => {});

etc
*/
munrocket commented 3 years ago

:c