Closed tomerghelber-tm closed 1 year ago
Hi 👋,
the no-top-level-hooks
basically forbids to define hooks outside of a suite (e.g. describe()
). Using hooks in a regular function means it could be potentially outside of a suite, because we don’t know where and when this function is called. How exactly does your function look like? Would it be possible to create the suite within the function? I would assume it should work like that:
function createSuite(title) {
describe(title, function () {
beforeEach(function () {
// to stuff...
});
it('works', function () {
// verify stuff...
});
});
}
I understand now, thank you for the explanation! I will try to fix the function with a suite.
Hello,
We have in our code base a lot of functions that generate test suites.
Those functions catch the rule
mocha/no-top-level-hooks
and I am not sure it should. Why doesn't it work only if they are on the top level?They also catch the rule of
mocha/no-exports
andmocha/no-identical-title
. Is this their expected behavior?Thank you for the work