Hello 👋

Testing

Why?

How you might write code now

What potential problems does this introduce?

What should drive our development?

T.D.D

Let's compare

Testing vs. Test Driven Development

Testing

Unit Testing

What is Unit Testing

Testing a single "unit" of a program, with as little dependencies involved as possible.

How do we go about testing?

Jest

A JavaScript Test Runner

yarn add --dev jest

npm i -D jest

Writing Test Suites

Writing Tests

Actually Testing

Layout of a test

Arrange ðŸĪ”

Layout and setup all variables and mocks required to run the test.

Act ðŸĪš

Run the unit you are trying to test

Assert ðŸ•ĩïļâ€â™‚ïļ

Make sure that you get the result you were looking for! Jest and other test runners have built in assertions.

Running the tests 🏃‍♀ïļ

Add a script to package.json like so

Running the tests 🏃‍♀ïļ

Testing, not TDD

TDD?

A more advanced example

Thank you!



TwitterGithub
@zealigan@ericadamski