Jasmine est un framework de développement axé sur le comportement pour tester le code JavaScript. Il ne dépend d’aucun autre framework JavaScript. Il ne nécessite pas de modèle objet de document (DOM), et il a une syntaxe claire et évidente afin que vous puissiez facilement écrire des tests.
Si vous voulez se démarquer en tant que développeur JavaScript, vous devez apprendre à tester votre code unitairement. Le jasmin est un excellent moyen de le faire.
À la fin de regarder ce cours, vous serez capable de :
- Comprenez ce qu’est le test unitaire et pourquoi il est important sur le marché actuel.
- Configurez le jasmin à partir de zéro.
- Rédigez des suites, des spécifications et des spécifications claires et concises.
- Comprenez et utilisez tous les -the-box jasmin matchers, créez les vôtres et incluez-les dans votre projet.
- Isolez les dépendances à l’aide de test-doubles, appelés espions dans Jasmine, pour de vrais tests unitaires.
- Code asynchrone de test unitaire.
- Configuration rapports de test et intégration continue du contrôle de version pour automatiser vos tests.
- Appliquer les meilleures pratiques lors de la structuration de vos tests.
Avec ce cours, vous obtiendrez du code source, des diapositives et des sec notes.
PRÉREQUIS
Il s’agit d’un cours débutant et intermédiaire.
Aucune expérience préalable des tests unitaires n’est nécessaire, juste une connaissance de base de JavaScript, HTML et CSS (juste en option lors de la construction de notre projet de cours).
Vous n’avez pas du tout besoin d’une expérience préalable avec un framework de test. Nous avons ce qu’il vous faut !
—
Licence de musique vidéo promotionnelle :
Adventures by A Himitsu – Creative Commons — Attribution 3.0 Unported— CC BY 3.0 Musique publiée par Argofox – Musique fournie par la bibliothèque audio
Course Intro
Here we explore the full course outline.
Here we explore the importance of unit testing and why Jasmine as your testing framework is a great choice.
Here we write our first spec using jasmine, from scratch!
Recap of what we learned in this section.
Downloadable materials for this section.
Jasmine functions
Overview of the content for this section.
Explore the project we will build and that we will unit test throughout this course.
Build the course project base functionality.
Program the user interface to interact with the core functionality we previously built so the project is usable.
Enhance the error handling for our application.
Make our application more attractive to the user and improve user experience.
Manually set up jasmine from the main jasmine repository.
Explore what suites are, and how to implement them, to test our application.
Understand what specs are, how to use them and we will write the first specs that test our application.
Learn about expectations and write our own to assert our code.
In this lecture we are going to learn how to disable suits and specs, and why is this useful.
Recap of what we learned in this section.
Downloadable materials of this section.
Matchers
Overview of the content for this section.
Learn what a matcher is, and how to use them.
Learn about the toBe matcher and use it to test your code.
Learn how to use the toEqual matcher and use it to test our code.
Learn how to use the toBeTruthy, and toBeFalsy matchers, why they are important and use them to test our code.
Learn how to negate the different matchers and use this to test our code.
Learn about the toBeDefined, and the toBeUndefined matchers, and use them to test your code.
Learn about the toBeNull matcher, and use it to test your code.
Learn about the toContain matcher, and use it to test your code.
In this lecture we will learn about the toBeNaN matcher, and use it to test our code.
Learn about the toThrow, and toThrowError matchers, and use it to test our code.
Learn about the toMatch matcher, and use it to test your code.
Learn about other matchers, and use it to test your code.
Explore asymmetric matchers and learn how to match anything.
Create our own custom matchers to fit the needs of our code.
Explore the different matchers from third-party sources.
Recap what we learned in this section.
Organizing your specs
Overview of the content of this section.
Some recommendations and best practices to organize better your specs.
Explore how to nest our suites and why this is important.
Explore the different life cycle hooks that jasmine offers.
Learn about the beforeEach and the afterEach setup and teardown methods and use them in your suites.
Learn about the beforeAll, and the afterAll life cycles, and use them to test in your suites.
Learn about the this keyword, and the different context that it has in our suites.
Recap what we learned in this section.
Downloadable materials for this section.
Spying on your code (stubs / test doubles)
Overview of the content for this section.
Learn what spies are, why they are important and how to use them.
Explore the different functions that jasmine has to spy on our code.
Learn about the toHaveBeenCalled matcher, and use it to write assertions on spies.
Learn about the toHaveBeenCalledWith matcher, , and use it to write assertions on spies.
Learn about the toHaveBeenCalledTimes matcher, and use it to write assertions on spies.
Learn how to spy on JavaScript prototypes.
Learn about the spy method callThrough and use it to configure your spies.
Learn about callFake and use it to configure your spies.
Learn about the spy method returnValue and use it to configure your spies.
Learn about returnValues and use it to configure your spies.
Learn about throwError and use it to configure your spies.
In this lecture we implement a getter for our project.
Learn about how to test getters and setters with spyOnProperty
Recap what we learned in this section.
Downloadable materials of this section.
Testing asynchronous code
Overview of the content of this section.
Use promises within our application.
The done callback provided by jasmine to test promises.
Your turn to work on a spec!
Solution for the exercise, and the logic behind it.
Async and await, we implement it in our application and show you how to test with them.
Recap what we learned in this section.
Downloadable materials of this section.
Test reports and continuous integration (CI)
Overview of the content of this section.
The package.json, how it works and how to generate one.
Install the different dependencies needed for the application.
Karma runner, the benefits and how to use it to automatize our tests.
What is a headless browser, and add one to our Karma runner.
What are coverage reports, how to read them and why are they important.
Push our code to version control.
Connect our repository to the CI system.
Create the manifest to build our project for the CI system.
Add a build badge for our README in our repository.
Recap what we learned in this section.
Downloadable materials of this section.
Extras
Explore what you should learn next to further improve your skills.