I started to writing tests a few time ago and faced a non-mature question: can I have more than one describe
per unit test file?
If so, in what circumstances this will happen?
Because so far, I'm describing a/an module/object like this:
tests/User-spec.js
describe ('A user', function () {
it ('should add a "to do" into the list', function () {
var user = new User;
var list = new List({ name: 'Home' });
user.add('Buying some groceries.').to(list);
expect(list.items[0]).to.be('Buying some groceries.');
});
});
In other words, each file of my tests describes an object—there's no space for another describe
.
I know there are a few good/bad practices about tests, and technically I can add more than one describe per spec—I just do not know wether this is the "best" way to go or even good.
Can you describe to me some scenarios where more than one describe
could be within the same spec file? Or even wether my describe
is or isn't wrong?