I've been writing test (in JavaScript) for the last two months. And, I have the habit of checking if module has some properties.
For example:
// test/foo.js
const Foo = require('../lib/foo');
const Expect = require('chai').expect;
describe('Foo API', () => {
it('should have #do and #dont properties', () => {
Expect(foo).to.have.property('do')
.and.to.be.a('function');
Expect(foo).to.have.property('dont')
.and.to.be.a('function');
});
});
});
And, I've been wondering if I am doing the right things. Just wanna know a few things:
-
Is this pattern "right"?
- Is it widely used?
- Are there other ways to do it?
-
If its not "right"?
- Why?
-
Does it even makes sense?
- I mean, it is unnecesary or redundant?
Aucun commentaire:
Enregistrer un commentaire