Journey to the Center of Ember Test Helpers

170
Journey to the Center of Ember Test Helpers Liz Baillie @infinite_math

Transcript of Journey to the Center of Ember Test Helpers

Page 1: Journey to the Center of Ember Test Helpers

Journey to the Center of

Ember Test

Helpers

Liz Baillie @infinite_math

Page 2: Journey to the Center of Ember Test Helpers

Abandon All Hope, Ye Who Enter

Here

Page 3: Journey to the Center of Ember Test Helpers

A LOT OF SOURCE

CODE!!11!

Page 4: Journey to the Center of Ember Test Helpers

me (Liz)

Page 5: Journey to the Center of Ember Test Helpers
Page 6: Journey to the Center of Ember Test Helpers
Page 7: Journey to the Center of Ember Test Helpers
Page 8: Journey to the Center of Ember Test Helpers
Page 9: Journey to the Center of Ember Test Helpers
Page 10: Journey to the Center of Ember Test Helpers
Page 11: Journey to the Center of Ember Test Helpers

Rails + Ember =

<3

Page 12: Journey to the Center of Ember Test Helpers

Rust :)

Page 13: Journey to the Center of Ember Test Helpers
Page 14: Journey to the Center of Ember Test Helpers

Liz Baillie

Ember Wildlife Adventure ExpertTomster Specialist Level Zero

cryptotomsterology

Page 15: Journey to the Center of Ember Test Helpers

* not a real thing

Page 16: Journey to the Center of Ember Test Helpers

Liz Baillie

Ember Wildlife Adventure ExpertTomster Specialist Level Zero

cryptotomsterology

Page 17: Journey to the Center of Ember Test Helpers

TOMSTER

Page 18: Journey to the Center of Ember Test Helpers

ember test

Page 19: Journey to the Center of Ember Test Helpers

ember test

Page 20: Journey to the Center of Ember Test Helpers
Page 21: Journey to the Center of Ember Test Helpers
Page 22: Journey to the Center of Ember Test Helpers
Page 23: Journey to the Center of Ember Test Helpers
Page 24: Journey to the Center of Ember Test Helpers
Page 25: Journey to the Center of Ember Test Helpers
Page 26: Journey to the Center of Ember Test Helpers
Page 27: Journey to the Center of Ember Test Helpers
Page 28: Journey to the Center of Ember Test Helpers
Page 29: Journey to the Center of Ember Test Helpers
Page 30: Journey to the Center of Ember Test Helpers
Page 31: Journey to the Center of Ember Test Helpers
Page 32: Journey to the Center of Ember Test Helpers
Page 33: Journey to the Center of Ember Test Helpers
Page 34: Journey to the Center of Ember Test Helpers
Page 35: Journey to the Center of Ember Test Helpers
Page 36: Journey to the Center of Ember Test Helpers
Page 37: Journey to the Center of Ember Test Helpers
Page 38: Journey to the Center of Ember Test Helpers
Page 39: Journey to the Center of Ember Test Helpers
Page 40: Journey to the Center of Ember Test Helpers
Page 41: Journey to the Center of Ember Test Helpers
Page 42: Journey to the Center of Ember Test Helpers
Page 43: Journey to the Center of Ember Test Helpers
Page 44: Journey to the Center of Ember Test Helpers
Page 45: Journey to the Center of Ember Test Helpers
Page 46: Journey to the Center of Ember Test Helpers
Page 47: Journey to the Center of Ember Test Helpers
Page 48: Journey to the Center of Ember Test Helpers
Page 49: Journey to the Center of Ember Test Helpers

How an Ember CLI command is run

• lookupCommand() looks up the command we pass to it using findCommand()

• the findCommand() method (which is in lookup-command.js) validates the command and returns it if it’s all good

• if a core command is overwritten by this, an error is thrown, but we we still return it (I think)

Page 50: Journey to the Center of Ember Test Helpers

How an Ember CLI command is run

• lookupCommand() looks up the command we pass to it using findCommand()

• the findCommand() method (which is in lookup-command.js) validates the command and returns it if it’s all good

• if a core command is overwritten by this, an error is thrown, but we we still return it (I think)

Page 51: Journey to the Center of Ember Test Helpers

How an Ember CLI command is run

• lookupCommand() looks up the command we pass to it using findCommand()

• the findCommand() method (which is in lookup-command.js) validates the command and returns it if it’s all good

• if a core command is overwritten by this, an error is thrown, but we we still return it (I think)

Page 52: Journey to the Center of Ember Test Helpers
Page 53: Journey to the Center of Ember Test Helpers
Page 54: Journey to the Center of Ember Test Helpers
Page 55: Journey to the Center of Ember Test Helpers
Page 56: Journey to the Center of Ember Test Helpers
Page 57: Journey to the Center of Ember Test Helpers
Page 58: Journey to the Center of Ember Test Helpers
Page 59: Journey to the Center of Ember Test Helpers
Page 60: Journey to the Center of Ember Test Helpers
Page 61: Journey to the Center of Ember Test Helpers
Page 62: Journey to the Center of Ember Test Helpers
Page 63: Journey to the Center of Ember Test Helpers
Page 64: Journey to the Center of Ember Test Helpers
Page 65: Journey to the Center of Ember Test Helpers
Page 66: Journey to the Center of Ember Test Helpers
Page 67: Journey to the Center of Ember Test Helpers
Page 68: Journey to the Center of Ember Test Helpers
Page 69: Journey to the Center of Ember Test Helpers

~ ANYWAY ~

Page 70: Journey to the Center of Ember Test Helpers

How lookupCommand calls the command

• required + used in cli.js

• before it’s run, we can pass in options to extend it

• validate the command in validateAndRun() + throw an error if needed

• otherwise, we run the command

Page 71: Journey to the Center of Ember Test Helpers

How lookupCommand calls the command

• required + used in cli.js

• before it’s run, we can pass in options to extend it

• validate the command in validateAndRun() + throw an error if needed

• otherwise, we run the command

Page 72: Journey to the Center of Ember Test Helpers

How lookupCommand calls the command

• required + used in cli.js

• before it’s run, we can pass in options to extend it

• validate the command in validateAndRun() + throw an error if needed

• otherwise, we run the command

Page 73: Journey to the Center of Ember Test Helpers

How lookupCommand calls the command

• required + used in cli.js

• before it’s run, we can pass in options to extend it

• validate the command in validateAndRun() + throw an error if needed

• then, we run the command

Page 74: Journey to the Center of Ember Test Helpers
Page 75: Journey to the Center of Ember Test Helpers
Page 76: Journey to the Center of Ember Test Helpers
Page 77: Journey to the Center of Ember Test Helpers
Page 78: Journey to the Center of Ember Test Helpers
Page 79: Journey to the Center of Ember Test Helpers
Page 80: Journey to the Center of Ember Test Helpers
Page 81: Journey to the Center of Ember Test Helpers
Page 82: Journey to the Center of Ember Test Helpers
Page 83: Journey to the Center of Ember Test Helpers
Page 84: Journey to the Center of Ember Test Helpers
Page 85: Journey to the Center of Ember Test Helpers
Page 86: Journey to the Center of Ember Test Helpers
Page 87: Journey to the Center of Ember Test Helpers
Page 88: Journey to the Center of Ember Test Helpers
Page 89: Journey to the Center of Ember Test Helpers
Page 90: Journey to the Center of Ember Test Helpers
Page 91: Journey to the Center of Ember Test Helpers
Page 92: Journey to the Center of Ember Test Helpers
Page 93: Journey to the Center of Ember Test Helpers
Page 94: Journey to the Center of Ember Test Helpers
Page 95: Journey to the Center of Ember Test Helpers
Page 96: Journey to the Center of Ember Test Helpers
Page 97: Journey to the Center of Ember Test Helpers

How the ‘test’ task is run from the command

• the test task is built and run in the command

• testem is triggered from our ‘test’ task

• testem runs our tests!

Page 98: Journey to the Center of Ember Test Helpers

How the ‘test’ task is run from the command

• the test task is built and run in the command

• testem is triggered from our ‘test’ task

• testem runs our tests!

Page 99: Journey to the Center of Ember Test Helpers

How the ‘test’ task is run from the command

• the test task is built and run in the command

• testem is triggered from our ‘test’ task

• testem runs our tests!

Page 100: Journey to the Center of Ember Test Helpers
Page 101: Journey to the Center of Ember Test Helpers

• come with Ember out of the box

What do we know about Ember’s test helpers?

Page 102: Journey to the Center of Ember Test Helpers

• come with Ember out of the box

• can only use on acceptance tests

What do we know about Ember’s test helpers?

Page 103: Journey to the Center of Ember Test Helpers

• come with Ember out of the box

• can only use on acceptance tests

• some are asynchronous

What do we know about Ember’s test helpers?

Page 104: Journey to the Center of Ember Test Helpers

• come with Ember out of the box

• can only use on acceptance tests

• some are asynchronous

• some are synchronous

What do we know about Ember’s test helpers?

Page 105: Journey to the Center of Ember Test Helpers

• come with Ember out of the box

• can only use on acceptance tests

• some are asynchronous

• some are synchronous

• andThen() - our one ‘wait’ helper

What do we know about Ember’s test helpers?

Page 106: Journey to the Center of Ember Test Helpers

• they are maybe all about to

change?

What do we know about Ember’s test helpers?

Page 107: Journey to the Center of Ember Test Helpers
Page 108: Journey to the Center of Ember Test Helpers

~ ANYWAY ~

Page 109: Journey to the Center of Ember Test Helpers
Page 110: Journey to the Center of Ember Test Helpers
Page 111: Journey to the Center of Ember Test Helpers
Page 112: Journey to the Center of Ember Test Helpers
Page 113: Journey to the Center of Ember Test Helpers
Page 114: Journey to the Center of Ember Test Helpers
Page 115: Journey to the Center of Ember Test Helpers
Page 116: Journey to the Center of Ember Test Helpers
Page 117: Journey to the Center of Ember Test Helpers

`registerAsyncHelper` is used to register an async test helper that will be injected when `App.injectTestHelpers` is called.

The helper method will always be called with the current Application as the first parameter.

Page 118: Journey to the Center of Ember Test Helpers
Page 119: Journey to the Center of Ember Test Helpers
Page 120: Journey to the Center of Ember Test Helpers
Page 121: Journey to the Center of Ember Test Helpers
Page 122: Journey to the Center of Ember Test Helpers
Page 123: Journey to the Center of Ember Test Helpers
Page 124: Journey to the Center of Ember Test Helpers

`registerAsyncHelper` is used to register an async test helper that will be injected when `App.injectTestHelpers` is called.

Page 125: Journey to the Center of Ember Test Helpers

This injects the test helpers into the `helperContainer` object.

Page 126: Journey to the Center of Ember Test Helpers

‘If an object is provided it will be used as the helperContainer.’

Page 127: Journey to the Center of Ember Test Helpers

“If ‘helperContainer’ is not set it will default to ‘window.’”

Page 128: Journey to the Center of Ember Test Helpers

“If a function of the same name has already been defined it will be cached

(so it can be reset if the helper is removed with ‘unregisterHelper’ or ‘removeTestHelpers’)”

Page 129: Journey to the Center of Ember Test Helpers
Page 130: Journey to the Center of Ember Test Helpers
Page 131: Journey to the Center of Ember Test Helpers
Page 132: Journey to the Center of Ember Test Helpers
Page 133: Journey to the Center of Ember Test Helpers
Page 134: Journey to the Center of Ember Test Helpers
Page 135: Journey to the Center of Ember Test Helpers
Page 136: Journey to the Center of Ember Test Helpers
Page 137: Journey to the Center of Ember Test Helpers
Page 138: Journey to the Center of Ember Test Helpers
Page 139: Journey to the Center of Ember Test Helpers

How test helpers get called

• test helpers are registered as either sync or async when they are called in a test

• before each test, the helpers are injected and then called

Page 140: Journey to the Center of Ember Test Helpers

How test helpers get called

• test helpers are registered as either sync or async when they are called in a test

• before each test, the helpers are injected and then called

Page 141: Journey to the Center of Ember Test Helpers
Page 142: Journey to the Center of Ember Test Helpers
Page 143: Journey to the Center of Ember Test Helpers
Page 144: Journey to the Center of Ember Test Helpers
Page 145: Journey to the Center of Ember Test Helpers
Page 146: Journey to the Center of Ember Test Helpers

your name here

Ember Wildlife Adventure ExpertTomster Specialist Level Zero

cryptotomsterology

Page 147: Journey to the Center of Ember Test Helpers
Page 148: Journey to the Center of Ember Test Helpers
Page 149: Journey to the Center of Ember Test Helpers

You are probably wondering things

Page 150: Journey to the Center of Ember Test Helpers

• Why did we just do all that?

• Why would I ever want to that?

• It seems like you might have glossed over a bunch of stuff. Are you sure all that things you said were correct?

Page 151: Journey to the Center of Ember Test Helpers

• Why did we just do all that?

• Why would I ever want to that?

• It seems like you might have glossed over a bunch of stuff. Are you sure all that things you said were correct?

Page 152: Journey to the Center of Ember Test Helpers

• Why did we just do all that?

• Why would I ever want to that?

• It seems like you might have glossed over a bunch of stuff. Are you sure all that things you said were correct?

Page 153: Journey to the Center of Ember Test Helpers

Why did we just do all that?

Page 154: Journey to the Center of Ember Test Helpers

• we don’t HAVE TO do this

• anyone CAN do this, if they want

• not that scary!

• treat it like an adventure

Page 155: Journey to the Center of Ember Test Helpers

• we don’t HAVE TO do this

• anyone CAN do this, if they want

• not that scary!

• treat it like an adventure

Page 156: Journey to the Center of Ember Test Helpers

• we don’t HAVE TO do this

• anyone CAN do this, if they want

• not that scary!

• treat it like an adventure

Page 157: Journey to the Center of Ember Test Helpers

• we don’t HAVE TO do this

• anyone CAN do this, if they want

• not that scary!

• treat it like an adventure

Page 158: Journey to the Center of Ember Test Helpers

Why would I ever want to do that?

Page 159: Journey to the Center of Ember Test Helpers

• Reading source code is a great learning experience

• better understanding of how things work under the hood

• can come in handy later on when debugging our tests

• anyone can do it

Page 160: Journey to the Center of Ember Test Helpers

• Reading source code is a great learning experience

• better understanding of how things work under the hood

• can come in handy later on when debugging our tests

• anyone can do it

Page 161: Journey to the Center of Ember Test Helpers

• Reading source code is a great learning experience

• better understanding of how things work under the hood

• can come in handy later on when debugging our tests

• anyone can do it

Page 162: Journey to the Center of Ember Test Helpers

• Reading source code is a great learning experience

• better understanding of how things work under the hood

• can come in handy later on when debugging our tests

• anyone can do it

Page 163: Journey to the Center of Ember Test Helpers

Was all that stuff correct?

Page 164: Journey to the Center of Ember Test Helpers

• I don’t know, probably not all of it?

• pique your curiosity

• inspire you to read source code without intimidation

Page 165: Journey to the Center of Ember Test Helpers

• I don’t know, probably not all of it?

• pique your curiosity

• inspire you to read source code without intimidation

Page 166: Journey to the Center of Ember Test Helpers

• I don’t know, probably not all of it?

• pique your curiosity

• inspire you to read source code without intimidation

Page 167: Journey to the Center of Ember Test Helpers
Page 168: Journey to the Center of Ember Test Helpers

Resources• Ember CLI GitHub repo: https://github.com/ember-cli/ember-cli

• Ember CLI API docs: ember-cli.com/api

• Ember repo: https://github.com/emberjs/ember.js

• Ember API docs: emberjs.com/api

• Ember Community Slack for answers to your questions

Page 169: Journey to the Center of Ember Test Helpers

Resources

• Robert Jackson’s Grand Testing Unification RFC: https://github.com/rwjblue/rfcs/blob/42/text/0000-grand-testing-unification.md

Page 170: Journey to the Center of Ember Test Helpers

THANK YOULiz Baillie @infinite_math