-: In the last section, we made a small change
to the app.test.js file.
So we added this line of code right here.
We then went over to our terminal
and executed our test suite
by running the command NPM Run test.
So in this section we're going to talk
about what happened when we ran that command.
After we get a better idea of what happened
we'll then go back over
to our project and start working on our first application.
All right, so quick diagram here.
So a little bit ago,
you and I used a tool called Create React App
to generate a new project.
When we made that project, we got a bunch
of dependencies installed into that project automatically.
Top among that list is the React Library itself.
We also got tools like Webpack
and Babel for linking together JavaScript files
and turning our JavaScript code
and JSX code into ES5 compatible code.
One other library that was installed
into our project automatically was the Jest test suite.
Jest is what we refer to as an automated test runner.
It's job is to take all the different test files that you
and I create inside of our project,
run the tests inside them
and then print the output back to us inside the terminal.
Let me give you a better idea
of what happened when we executed that NPM run test command
at the terminal in the last section.
So we start up here
at the top where we executed that command at the terminal.
When we ran that, it automatically started up
the Jest test runner.
Jest then went through a couple
of automated steps to run all the tests inside
of our project.
First off, it looked over all the different files
and folders inside of our SRC directory.
It looked for every file inside there that ended
with the file extension of .test.js
and it executed all the tests inside of each of those files.
So in our case, Jest started up, it looked inside
the SRC directory and then it found the app.test.js file,
where you and I had written a little bit of testing code.
Well, maybe just this one line right here,
but we'll take credit for everything.
After Jest found that test file and executed the test
inside of it, it then printed out the results
of that test to the terminal.
And so that's what we saw back over here.
You'll notice it at the top Jest printed out
that it found the file called app.test.js
and then it executed the one test that was written inside
there.
The string right here of "renders without crashing"
is coming from this line of code right here.
So you'll notice that string is completely identical.
The fact that there's the nice green checkbox back
to it back over here means to say that all the code inside
of this test, so all this stuff right here,
was executed successfully
and all this testing code looks good to go.
Now after Jest ran and printed that output to the terminal
it then sits around and waits for a file inside
of our project to change.
And any time that happens, the Jest test runner
will automatically once again find all the different
files ending in .test.js, load those file up
and execute the test to find inside of each one,
print out the results and then again
sit around and wait for another file to change.
So right now, the entire core of our entire test suite
or all the testing code we have
inside of this basic application really revolves
around this Jest library.
And so as you might guess throughout this course
we're going to get a lot of experience working directly
with Jest and getting a better idea of exactly how it works.
So let's take a quick pause right here
now that we've got a better idea
of what Jest is doing for us.
We'll continue in the next section
and talk about the application we're going to build
to get a better idea of how testing works.
So quick break, and I'll see you in just a minute.