Unit.js
Unit.js
Unit.js
| Développé par | Nicolas Tallefourtane |
|---|---|
| Dernière version |
2.1.0 ()[1],[2] 2.1.1 ()[2] |
| Dépôt | github.com/unitjs/unit.js |
| Écrit en | JavaScript |
| Système d'exploitation | Multiplateforme (d) |
| Environnement | Multiplate-forme |
| Langues | Anglais |
| Type | bibliothèque JavaScript, Test unitaire |
| Licence | AGPL-3.0+ |
| Site web | unitjs.com |
Unit.js est une bibliothèque de tests unitaires open source dédiée au langage de programmation JavaScript.
La bibliothèque contient notamment les fonctionnalités suivantes :
- Container IoC (Inversion de contrôle) et Injection de dépendances[3]
- Plugins [4]
- Gestion des services (Fabrique)
- Gestion de l’exécution synchrone / asynchrone [5].
Utilisation
Un simple test hello world ressemble au code ci-dessous :
var example = 'Hello world!';
test.string(example)
.isEqualTo('Hello world!');
Unit.js s'intègre dans une suite de tests de type Behavior Driven Development
describe('Hello world', function() {
it('says hello', function() {
var example = 'Hello world!';
test.string(example)
.isEqualTo('Hello world!');
});
});
Styles d'assertions
Unit.js supporte de multiples interfaces de programmation, ce qui permet au développeur de choisir le style d'écriture qu'il juge le plus confortable et productif
- Unit.js
test.string(str)
.number(num).is(42);
- Assert
test.assert(typeof str === 'string');
test.assert(typeof num === 'number');
test.assert.equal(num, 42);
- Must.js
test.must(str).be.a.string();
test.must(num).be.a.number();
test.must(num).equal(42);
- Should.js
test.should(str).be.a.String
test.should(num).be.Number
.and.equal(42);
Voir aussi
Notes et références
- ↑ « Release 2.1.0 », (consulté le )
- npmjs (base de données en ligne), consulté le .
- ↑ (en) « Dependency injection », sur unitjs.com (consulté le ).
- ↑ (en) « Plugins », sur unitjs.com (consulté le ).
- ↑ (en) « Promise », sur unitjs.com (consulté le ).
Liens externes
- (en) Site officiel
- (en) Unit.js sur GitHub
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.