Skip to content
 
 

Repository files navigation

Testing Workshop

👋 hi there! My name is Kent C. Dodds! This is a workshop repo to teach you about testing JavaScript applications.

NOTICE: If you're coming here from my Frontend Masters 2017 workshop, please go to the fem branch to make sure you're looking at the accurate information for your workshop.

slides-badge chat-badge Build Status MIT License All Contributors

PRs Welcome Code of Conduct Watch on GitHub Star on GitHub Tweet

Topics covered

  1. Unit Testing with Jest
  2. Integration Testing with Jest
  3. End to End (E2E) Testing with Cypress

We'll mention other forms of testing, but these are the types we'll focus on and learn in this workshop. We'll learn about the benefits (and tradeoffs) of TDD. We'll learn how to configure the tools and why, when, where, and what to test.

Project

Branches

This project has been used to teach about testing in various settings. You may want to switch to the appropriate branch for this workshop. Otherwise the code you're looking at may not be exactly the same as the code used in the setting you're working with.

  • Frontend Masters 2017 fem

System Requirements

  • git v2.14.1 or greater
  • NodeJS v8.9.4 or greater
  • npm v5.6.0 or greater

All of these must be available in your PATH. To verify things are set up properly, you can run this:

git --version
node --version
npm --version

If you have trouble with any of these, learn more about the PATH environment variable and how to fix it here for windows or mac/linux.

Setup

After you've made sure to have the correct things (and versions) installed, you should be able to just run a few commands to get set up:

git clone https://github.com/kentcdodds/testing-workshop.git
cd testing-workshop
npm run setup --silent
node ./scripts/autofill-feedback-email.js YOUR@EMAIL.com
git commit -am "ready to go"

Change YOUR@EMAIL.com to your actual email address

This may take a few minutes. If you get any errors, please read through them and see if you can find out what the problem is. You may also want to look at Troubleshooting. If you can't work it out on your own then please file an issue and provide all the output from the commands you ran (even if it's a lot).

Cypress

For everyone else, you'll want to come with Cypress.io downloaded, installed and have an account ready to go. Please follow these instructions to do this!

Running the app

To get the app up and running (and really see if it worked), run:

npm start

This will start the api server, and the client server in development mode at the same time. Your browser should open up automatically to http://localhost:8080 (if it doesn't, just open that yourself) and you should be able to start messing around with the app.

If this fails at any point for you, please open an issue.

Login

If you want to login, there's a user you can use:

  • Username: til
  • Password: til

To stop all the servers, hit Ctrl + C.

Troubleshooting

"npm run setup" command not working

Here's what the setup script does. If it fails, try doing each of these things individually yourself:

# verify your environment will work with the project
node ./scripts/verify

# install dependencies in the root of the repo
npm install

# install dependencies in the api directory
cd api
npm install

# install dependencies in the client directory
cd ../client
npm install

# get back to the root of the repo
cd ..

# verify the project is ready to run
npm run lint
npm run test:coverage
npm run test:e2e

If any of those scripts fail, please try to work out what went wrong by the error message you get. If you still can't work it out, feel free to open an issue with all the output from that script. I will try to help if I can.

"npm start" command not working

If it doesn't work for you, you can start each of these individually yourself (in separate terminals):

cd server && npm start
cd client && npm start

If any of those scripts fail, please try to work out what went wrong by the error message you get. If you still can't work it out, feel free to open an issue with all the output from that script. I will try to help if I can.

Structure

This project has a bit of a unique setup. Normally you'll have just a single package.json at the root of your repository, but to simplify setup I've included both the server and client projects in a single repository. The root of the project has a package.json as does server, and client. While you'll be working in the source code and tests in these folders, you should be able to leave you command line in the root directory for the whole workshop.

LICENSE

MIT

Contributors

Thanks goes to these wonderful people (emoji key):


Kent C. Dodds

💻 📖 🚇 ⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!

About

A workshop for learning how to test JavaScript applications

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages