Skip to content

Commit

Permalink
fix(test): flapping empty property test, improve test logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Oct 18, 2022
1 parent 2370fb2 commit 0aff004
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions test/TestOver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
8 changes: 4 additions & 4 deletions test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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));
}
Expand Down

0 comments on commit 0aff004

Please sign in to comment.