For whatever reason, you’ll be happy to know that it’s not a huge undertaking and can be quite simple and highly effective.
For this example I have used the Flaskr example from the official Flask repository.
Once you have your project, lets get started!
While you are in the root directory, you will want to run: You can fill all the prompts out now or later. Its up to you.
This will result in a file.
This will install all the necessary npm packages to run Karma in our Flask application.
We then run:
This will prompt you with a bunch of questions. You can answer them as you like.
For this post, there are two questions that concern me:
We can then test it out by creating a test in the something.spec.js file:
And then we save and run:
Voila! Our tests should pass with green.
Another cool thing about this set up is that the code will be watched. So when you change any files, the tests will rerun to make sure everything is still passing.
I’ll post some more on that later!