Testing strategies with Angular 2 – Julie Ralph

preview_player
Показать описание


Angular loves testability, and Angular 2 will continue to make it easy to write great test suites so that you're confident in your site. Learn how to use karma and other tools to set up and debug tests, see how the Angular team creates their test suite, and meet new test helpers just for Angular 2 components.
Рекомендации по теме
Комментарии
Автор

CRY (constantly repeat yourself) principle?

import {MyService} from './services/my-service'
describe('MyService', () => {
beforeEachProviders(() => [MyService])
it('should service me', inject([MyService], (service:MyService) => {
expect(service...

At least 4 MyService references are required here. Also, why promises and not RX if that's the foundation? P.S. The ADD_ID inject test fails with "cannot resolve getXHR). Not to be a downer but the testing experience solution is frankenstein-like and it will impact NG2 adoption to some extent. I'm confident and hopeful it will improve.

codegooroo
Автор

Thanks, useful for getting started! I grabbed this whilst updating my head from Angular 1.5 -era. With Ubuntu and using Chromium instead of ordinary Chrome, I had to set 'export CHROME_BIN=' to match the path to Chromium executable. Otherwise this worked straight off the bat.

fytubevw
Автор

It would be great if you update the code in github for using angular 2.0.0-beta.2.
Most of the paths are changed.
For example, 'browser_adapter' is placed under different folder and 'testing.js' must be changed to .

AlexanderMarinov
Автор

what about a new connect about latest Final Release testing¿? does it exist?¿

crisbelda
Автор

I feel like in testing in general the part that I don't like and the part that bloats the files is how you have to repeat all your dependencies in the unit test. It would be nice if there was a way to just include all the dependencies from the file being tested. You aren't testing that part anyway so it seems really redundant to set all of that up again every time you test something. It also adds a lot of complexity because most apps are not designed to be able to pull out one file and test it so maybe there should be a way to just "import all the imports from the original import list" and then just test what is in the file. I hate unit testing because I'm always a one man team so I don't have time to go around optimizing specific tasks. Literally nothing I write ever breaks. If you want to encourage testing you should find a way to focus the test on just what is different in the file. Having all those dependencies in the test is just adding new places for the app to break. You have to be an EXTREMELY large organization before anyone starts re-using units. I've worked on hundreds of websites totaling billions of dollars of production value and some of the largest companies in the world and the truth is people rarely actually re-use code because the landscape changes to much. It's more cost effective to make new code with a new feature. The audience for unit testing is actually only inside these largest companies. In other places end to end testing is the only thing that might be practical. Otherwise the lifespan of the website is so short it doesn't make sense. You get it up and build something new. You optimize the new thing. I would like to one day unit test something just to try and find value in it, but I make real world dollars by making new things and not perfecting old things. I hope one day there can be an easier way to unit test so we can get the best of both worlds. --I want to add this is a great presentation and I like how you put all the information in there without worrying about if people will get it right then. It makes for a good youtube video even if the audience is confused. Thank you.

nickjunes