Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API breaking change request #113

Closed
munrocket opened this issue Oct 8, 2021 · 2 comments
Closed

API breaking change request #113

munrocket opened this issue Oct 8, 2021 · 2 comments
Labels

Comments

@munrocket
Copy link
Contributor

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
Copy link
Owner

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
Copy link
Contributor Author

:c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants