1
0
Fork 0

fix(test): flapping empty property test, improve test logs

This commit is contained in:
Sean Sube 2022-10-18 17:28:50 -05:00
parent 2370fb22c1
commit 0aff004fc3
2 changed files with 5 additions and 4 deletions

View File

@ -84,6 +84,7 @@ describe('example properties', () => {
return text.length > 0;
});
}, {
examples: [''],
// error formatting can be overridden with a custom handler, or fast-check's default
errorReporter: defaultReportMessage,
}, itFails('after 1 tests', done));

View File

@ -4,12 +4,12 @@ export function itFails(msg: string, done: Mocha.Done, count = 1): Mocha.TestFun
const expectations: Array<Chai.PromisedAssertion> = [];
const mockIt = function (this: Mocha.Context, name: string, test: Mocha.AsyncFunc) {
console.log('mock it invoked with test', name, test.name, expectations.length);
console.log(`mock it invoked for '${name}' with test '${test.name}', ${expectations.length} of ${count}`);
expectations.push(expect(test.call(this), name).to.eventually.be.rejectedWith(Error, `Property failed ${msg}`));
if (expectations.length >= count) {
console.log('all expectations queued for', name, expectations.length);
console.log(`all ${expectations.length} expectations queued for '${name}'`);
Promise.all(expectations).then((_val) => done(), (err) => done(err));
}
@ -22,12 +22,12 @@ export function itPasses(done: Mocha.Done, count = 1): Mocha.TestFunction {
const expectations: Array<Chai.PromisedAssertion> = [];
const mockIt = function (this: Mocha.Context, name: string, test: Mocha.AsyncFunc) {
console.log('mock it invoked with test', name, test.name, expectations.length);
console.log(`mock it invoked for '${name}' with test '${test.name}', ${expectations.length} of ${count}`);
expectations.push(expect(test.call(this), name).to.eventually.be.oneOf([true, undefined]));
if (expectations.length >= count) {
console.log('all expectations queued for', name, expectations.length);
console.log(`all ${expectations.length} expectations queued for '${name}'`);
Promise.all(expectations).then((_val) => done(), (err) => done(err));
}