- We're going to use Jest as the test framework
for most of the tests in this video series.
So obviously the first thing we need to do
is to install Jest onto our machines.
There were two ways to do that.
You can either use Node Package Manager, NPM
or you can use Yarn.
Let's take a look at both techniques.
Both are fine.
Personally I tend to use Node Package Manager
but Yarn is equally good.
So if you want to use Node Package Manager
to install Jest,
obviously the first thing
you have to have Node Package Manager installed.
NPM comes with nodejs.
So if you go to node.js.org
and download Node.js from there.
Just click the long term support button.
It takes a while to download Node.js.
It installs Python as well,
plus some C++ libraries.
So you have to give it a good five minutes to install it.
Once you've done that, you can then use NPM
to install any libraries you need, like Jest.
So let's do that now.
Just run this command,
npminstall, the --global flag
will install Jest globally
in the NPM folder on your machine.
So you can run Jest
from any directory you want to thereafter.
Okay. So open up a terminal window or command window.
Run that command and you now have Jest
installed on your machine.
If you prefer to use Yarn then...
Well, first of all
if you haven't got Yarn installed on your machine
you can actually use NPM to install Yarn
which seems a little bit roundabout.
So you can say this,
open up a terminal window, or command window,
npm install --global, install the Yarn library,
or the Yarn tool.
Once you've installed Yarn,
and that takes a moment or two,
you can then use Yarn to install Jest, like this.
So in the command window
or in your terminal window,
yarn global add.
So in the global Yarn folder,
we are adding the Jest library.
Okay. So in both cases
we should now have Jest installed on our machine
ready to use.
To verify that Jest is installed properly,
just run this command from a terminal,
jest --version and all being well,
it should show a version number.
So when I'm running this demo myself
the latest version is 27.5.1.
Obviously, by the time you get to watch this video
it might be a different number.
Probably will be but that should be fine.
Let's do that.
(keyboard clicking)
Okay. So I have Jest installed on my machine.
It was quite straightforward.
What we're going to see in the next section
is how to write some simple tests
and to run them using the Jest execution framework.