fix(test): flapping empty property test, improve test logs
This commit is contained in:
parent
2370fb22c1
commit
0aff004fc3
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue