-: We've now got some solid infrastructure in place
to run our container in a development environment.
So we've set up both the Docker file.dev file.
We've also set up a Docker composed file
that makes executing the Docker container and starting it up
just a little bit easier.
We're now gonna start to shift our focus
over to running the tests inside of our container.
We're gonna first focus on just running our tests
in our development environment, and then
we're gonna very quickly kind of take that knowledge
and apply it to running our tests over on Travis CI,
which remember is a continuous integration service
specifically made to run tests for your project.
All right.
Now the good news here is that executing NPM run test
inside of our container is gonna be awfully straightforward.
All we really have to do is build our container
using the Docker file.dev file
that we've already put together.
Let's do that right now.
So we'll do Docker build
dash F
Docker file.dev.
I'll then put my dot on there.
Let me pull that back up
just cause I hit enter really quickly.
Don't forget the dot on the end.
So that gives me my image ID right there.
And now remember to run a specific command
inside of that container when it starts up or to just
overright, or override - excuse me - the existing command.
All we have to do is append the command that we
actually want to run on the end of the docker run command.
So I can execute Docker run
the container ID, which I just lost.
Let me copy it again.
And then I'll add on NPM run test like so.
So now when the container first starts up
it's going to execute NPM run test
which starts up the test suites.
We then get presented with a little
interactive menu right here
that allows us to run specific tests,
to quit or to rerun the test suite.
Now I want you to try hitting enter right now.
If you do so you'll notice that the tests appear to not run.
I want you to remember back to the...
when we spoke about the Docker run command
related to the docker CLI.
When we run Docker run by default
we get a connection to standard out inside the container.
But for us to actually trigger
or get any input into the container itself
we have to hook up to standard in as well, and we can do so
by adding on the dash IT options to docker run.
So let's try doing that right now.
I'm gonna stop the container with control C
and then we'll do docker run dash IT.
I'll paste in.
Darn it! I lost the ID again.
Let me build this thing one more time.
Do docker... See, this is why
you're supposed to use tags by the way.
You can tell that I'm being very naughty
and not making use of tags.
All right, so I'll do docker run dash IT,
there's the ID
and then we'll execute NPM run test
when the container starts up.
-: All right, so that's better.
You'll notice that when we add on the IT flags
we get a much more full screen experience here.
And now when I press enter
it's going to rerun all the tests.
I can hit W to go back to the menu and I could
I don't know, I could hit quit if I wanted to quit,
I could run a specific test by using P.
Let's try that out.
So I could do like app
that matches the app.test.js file.
I could hit enter and it runs just that file.
So clearly we get full interactivity here.
All right, so that's looking pretty good.
So we can now exit out of test mode
by hitting control C as usual.
All right, not too bad.
Let's take another quick break right here
and continue in the next section.