integration tests for your ember.js application

19

Click here to load reader

Upload: yoranbe

Post on 12-Jun-2015

248 views

Category:

Software


4 download

DESCRIPTION

Lately, there’s been a lot of attention going to testing in the Ember.js community but I feel it focuses almost exclusively on the Ember side of things. However, most applications interface with a back-end and I don’t think much has been written how to do integration tests in Ember.js that test your whole stack, including the back-end. Hence this talk. Particularly, I go into how you can seed your data before running each test. The presentation was given at the Boston Ember.js meetup on the 10th of July 2014. You can find the video here: https://www.youtube.com/watch?v=S4M78SO3gAc#t=3740

TRANSCRIPT

Page 1: Integration tests for your Ember.js application

Integration tests for yourEmber.js application

@YoranBrondsema

Page 2: Integration tests for your Ember.js application

About meFull-stack developer at Hstry

~10 months intensive Ember.js user

Page 3: Integration tests for your Ember.js application
Page 4: Integration tests for your Ember.js application

From my experiences working on Hstry

Page 5: Integration tests for your Ember.js application

Integration tests

Test the whole stack from the user's perspective

Were driven by back-end back in the "old" days

Page 6: Integration tests for your Ember.js application

This is how the application was tested too...Hstry

Page 7: Integration tests for your Ember.js application

... but the tests were slow, brittle and flaky.

Page 8: Integration tests for your Ember.js application

Ember.js now provides a nice framework to dointegration tests...

visit

fillIn

click

find

currentRouteName

... plus your own

Page 9: Integration tests for your Ember.js application

... and Hstry converted (almost) all its integrationtests successfully!

Page 10: Integration tests for your Ember.js application

What to test?

Page 11: Integration tests for your Ember.js application

What the user is supposed to see.

Click on button X, should see Y.

Go on page X, should see Y.

Page 12: Integration tests for your Ember.js application

That the data is correctly persisted.

Click on this "Submit" button, issues POST request to endpoint XXX with parametersYYY.

Page 13: Integration tests for your Ember.js application

What do you need?

Testing framework: QUnit (default for Ember), Mocha,Jasmine,...

Test runner: Teaspoon (Rails), Testem (Node.js)

Page 14: Integration tests for your Ember.js application

DEMO

Page 15: Integration tests for your Ember.js application

What about seed data?I want to test the /blog_posts/POST_ID route.

Need to set up data in back-end beforehand

Page 16: Integration tests for your Ember.js application

How?An API endpoint /seed_db

Call this endpoint before each test

Do not open this endpoint in production!

Page 17: Integration tests for your Ember.js application

DEMO

Page 18: Integration tests for your Ember.js application

is hiringHstryLooking for an experienced Rails and Ember.js full-stack developer

Page 19: Integration tests for your Ember.js application

Thank you