Ember.js testing

not as hard as you think

Agenda

  1. Introduction.
  2. Runners and frameworks.
  3. Unit tests.
  4. Integration tests.
  5. Running your tests.
  6. Summary

Introduction

What types of tests in Ember.js have we?

Acceptance

Integration

Unit

Frameworks and runners

A test runner that makes Javascript unit testing fun.

What is test runner?

Where can my tests run?

Frameworks and runners

An easy-to-use JavaScript Unit Testing framework.

What is testing framework?

Unit tests

Test a small piece of code and ensure that it is working

Why unit tests instead of acceptance?

When should I bother to write it?

How to do it?

Methods, computed properties, state, helpers, utilities

Create an Ember.Object, set it, execute a method and test it!

Blazing fast, helps to find edge cases, helps to reason about

Unit tests

Examples

Integration tests

Test components by rendering them in tests scope

Why integration tests instead of acceptance?

When should I bother to write it?

How do I test it?

Actions, events, rendering order.

Render the component and assert using jQuery on test's scope

Much faster, easy to maintain, don't need so many dependencies

Integration tests

Examples

Running your tests

Tips & Tricks

Tip #1: Don't use ember test

Tip #2: Just visit http://localhost:4200/tests

Tip #3: Have opened console there and make use of debugger

Tip #4: Don't run all of the tests while working on them - use filters

Good practices

Don't avoid testing in Ember.js

Don't accept not-tested code during code review

Don't know how to test? Ask on #emberjs

Behaviour & responsibilities

Using Ember in your project?

Don't miss Ember mtgs, we cover a lot of use cases

Good practices

Code

Resources

Thanks

Ember.js testing

By Kuba Niechcial

Ember.js testing

  • 1,329