4.46 sur 5
4.46

Test unitaire de votre Javascript avec jasmin

Apprenez à tester unitairement votre JavaScript à l'aide du framework jasmine, de votre premier test à l'intégration continue.
Écrire des suites, des spécifications et des attentes propres.
Isoler les dépendances sur les unités grâce à des doubles de test (espions).
Automatiser les tests par intégration continue à partir du contrôle de version à l'aide d'un navigateur sans tête et d'un lanceur de test.
Configurez jasmine comme cadre de test unitaire à partir de zéro.
Configurer l'installation et le démontage des suites.
Comprendre comment fonctionnent les matchers dans Jasmine.
Écrivez des matchers personnalisés et incluez-les dans votre projet.
Consommer des matchers tiers.
Testez le code asynchrone.
Exécutez des tests unitaires à partir d'un navigateur Web et d'un terminal via un lanceur de tests.
Générer des rapports de couverture de code.
Améliorez la gestion des dépendances via un gestionnaire de packages.

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

1
Course overview

Here we explore the full course outline.

2
Why unit testing? why jasmine?

Here we explore the importance of unit testing and why Jasmine as your testing framework is a great choice.

3
Important javascript notes!
4
Download exercise files
5
Creating your first test

Here we write our first spec using jasmine, from scratch!

6
Section summary

Recap of what we learned in this section.

7
Section notes

Downloadable materials for this section.

Jasmine functions

1
Section intro

Overview of the content for this section.

2
Course project

Explore the project we will build and that we will unit test throughout this course.

3
Let's build it!

Build the course project base functionality.

4
Programing the UI

Program the user interface to interact with the core functionality we previously built so the project is usable.

5
Improving errors

Enhance the error handling for our application.

6
Styling the UI (optional lecture)

Make our application more attractive to the user and improve user experience.

7
Setting up jasmine

Manually set up jasmine from the main jasmine repository.

8
Suites

Explore what suites are, and how to implement them, to test our application.

9
Specs

Understand what specs are, how to use them and we will write the first specs that test our application.

10
Expectations

Learn about expectations and write our own to assert our code.

11
Disabled specs and disabled suites

In this lecture we are going to learn how to disable suits and specs, and why is this useful.

12
Section summary

Recap of what we learned in this section.

13
Section notes

Downloadable materials of this section.

Matchers

1
Section intro

Overview of the content for this section.

2
What is a matcher

Learn what a matcher is, and how to use them.

3
toBe

Learn about the toBe matcher and use it to test your code.

4
toEqual

Learn how to use the toEqual matcher and use it to test our code.

5
toBeTruthy, toBeFalsy

Learn how to use the toBeTruthy, and toBeFalsy matchers, why they are important and use them to test our code.

6
Negating matchers

Learn  how to negate the different matchers and use this to test our code.

7
toBeDefined, toBeUndefined

Learn about the toBeDefined, and the toBeUndefined matchers, and use them to test your code.

8
toBeNull

Learn about the toBeNull matcher, and use it to test your code.

9
toContain

Learn about the toContain matcher, and use it to test your code.

10
toBeNaN

In this lecture we will learn about the toBeNaN matcher, and use it to test our code.

11
toThrow, toThrowError

Learn about the toThrow, and toThrowError matchers, and use it to test our code.

12
toMatch

Learn about the toMatch matcher, and use it to test your code.

13
Other matchers

Learn about other  matchers, and use it to test your code.

14
Match anything

Explore asymmetric matchers and learn how to match anything.

15
Custom matchers

Create our own custom matchers to fit the needs of our code.

16
Update on third party matchers! Read before the next lecture.
17
Third party matchers

Explore the different matchers from third-party sources.

18
Section summary

Recap what we learned in this section.

19
Section notes

Organizing your specs

1
Section intro

Overview of the content of this section.

2
Recommendations to organize our specs

Some recommendations and best practices to organize better your specs.

3
Nesting suites

Explore how to nest our suites and why this is important.

4
Setup and teardown

Explore the different life cycle hooks that jasmine offers.

5
beforeEach, afterEach

Learn about the beforeEach and the afterEach setup and teardown methods and use them in your suites.

6
beforeAll, afterAll

Learn about the beforeAll, and the afterAll life cycles, and use them to test in your suites.

7
Jasmine and the [this] keyword

Learn about the this  keyword, and the different context that it has in our suites.

8
Section summary

Recap what we learned in this section.

9
Section notes

Downloadable materials for this section.

Spying on your code (stubs / test doubles)

1
Section intro

Overview of the content for this section.

2
Jasmine spies

Learn what spies are, why they are important and how to use them.

3
Spying on functions

Explore the different functions that jasmine has to spy on our code.

4
toHaveBeenCalled

Learn about the toHaveBeenCalled matcher, and use it to write assertions on spies.

5
toHaveBeenCalledWith

Learn about the toHaveBeenCalledWith matcher, , and use it to write assertions on spies.

6
toHaveBeenCalledTimes

Learn about the toHaveBeenCalledTimes matcher, and use it to write assertions on spies.

7
Spying on prototypes

Learn how to spy on JavaScript prototypes.

8
callThrough

Learn about the spy method callThrough and use it to configure your spies.

9
callFake

Learn about callFake and use it to configure your spies.

10
returnValue

Learn about the spy method returnValue and use it to configure your spies.

11
returnValues

Learn about returnValues and use it to configure your spies.

12
Spy and throwError

Learn about throwError and use it to configure your spies.

13
Using getters

In this lecture we implement a getter for our project.

14
spyOnProperty

Learn about how to test getters and setters with spyOnProperty

15
Section summary

Recap what we learned in this section.

16
Section notes

Downloadable materials of this section.

Testing asynchronous code

1
Section intro

Overview of the content of this section.

2
Using promises

Use promises within our application.

3
The done callback

The done callback provided by jasmine to test promises.

4
Your turn! (spec exercise)

Your turn to work on a spec!

5
showVersion() spec solution

Solution for the exercise, and the logic behind it.

6
Async and await with specs

Async and await, we implement it in our application and show you how to test with them.

7
Section summary

Recap what we learned in this section.

8
Section notes

Downloadable materials of this section.

Test reports and continuous integration (CI)

1
Section intro

Overview of the content of this section.

2
The package.json

The package.json, how it works and how to generate one.

3
Installing dependencies

Install the different dependencies needed for the application.

4
Karma runner

Karma runner, the benefits and how to use it to automatize our tests.

5
Headless browser

What is a headless browser, and add one to our Karma runner.

6
Coverage reports

What are coverage reports, how to read them and why are they important.

7
Pushing to version control

Push our code to version control.

8
Connecting to CI system

Connect our repository to the CI system.

9
Configuring build

Create the manifest to build our project for the CI system.

10
Build badge

Add a build badge for our README in our repository.

11
Section summary

Recap what we learned in this section.

12
Section notes

Downloadable materials of this section.

Extras

1
What's next!

Explore what you should learn next to further improve your skills.

2
Bonus!
Vous pouvez afficher et revoir les supports de cours indu00e9finiment, comme une chau00eene u00e0 la demande.
Absolumentu00a0! Si vous disposez d'une connexion Internet, les cours sur WeCours sont disponibles u00e0 tout moment sur n'importe quel appareil. Si vous n'avez pas de connexion Internet, certains instructeurs permettent u00e9galement u00e0 leurs u00e9tudiants de tu00e9lu00e9charger les cours. instructeur cependant, alors assurez-vous d'u00eatre de leur bon cu00f4tu00e9u00a0!
4.5
4.5 sur 5
Notes569

Détails des Notes

Étoiles 5
283
Étoiles 4
176
Étoiles 3
63
Étoiles 2
8
Étoiles 1
7
Suivre un cours
Garantie de remboursement de 30 jours

Inclut

6 heures de vidéo à la demande
Accès complet à vie
Accès sur le mobile et la télévision
Certificat d'achèvement

Archive

Working hours

Monday 9:30 am - 6.00 pm
Tuesday 9:30 am - 6.00 pm
Wednesday 9:30 am - 6.00 pm
Thursday 9:30 am - 6.00 pm
Friday 9:30 am - 5.00 pm
Saturday Closed
Sunday Closed