 test core user interactions
(e.g. user can create foo) with e2e tests, and edge-cases with unit tests.
These tests will be clicking around and sending keys to inputs and eventually
reach some state that confirms that the action was successful. Among all the
states that were traversed, how many things will you validate (e.g. check that
the link the user clicks is in a list, check that in the final state he can
view all of foo's information)? And how in depth? (e.g. checking that #foo
contains all of foo's information, or checking that #foo contains.bar,.baz,
.qux, and that each contains part of foo's information)

I've figured out some patterns and guidelines over time, but some of these
tests tend to feel brittle or useless.

~~~
zachrose
Forgive me for being vague and brief, but I've been trying to test my UIs for
the last year or so and this is what I've come up with.

I've found the ideas in Gary Bernhardt's talk, Boundaries (1), to be very
helpful in figuring out how to test interactive web UIs. The basic idea is
that DOM manipulation can be an "imperative shell" with as little logic and as
few conditionals as possible. Derive the state of your UI component with
separate functions and methods that return plain values (a "functional core"),
and write tests for those because testing for values is easy.

So no, don't test for the presence of classes and IDs. Test your imperative
shell once, maybe even manually or with an integration test, and that's
probably enough.

Angular and React both encourage something like this approach, but you don't
need those technologies to do it this way. In Backbone, for instance, just try
to avoid conditionals and logic in your templates and render methods. If you
think your UI piece needs to render with conditionals because it can be in
different states, ask yourself if those states are just appearances that can
be programmed declaratively with classes and CSS.

Also, testing is so much easier when you limit API surface areas. So if you're
using a library like Backbone, where models and views both have many methods
with many ways they can be called and used, don't give them direct
test core user interactions 
 (e.g. exploiter can make foo) with e2e tests, and edge - cases with whole tests. 
 These tests will be snap about and sending key to inputs and eventually 
 strive some state that confirms that the legal action was successful. Among all the 
 states that were traversed, how many things will you validate (e.g. check that 
 the connection the user clicks is in a list, discipline that in the final state he can 
 view all of foo's information)? And how in astuteness? (e.g. control that # foo 
 contains all of foo's information, or checking that # foo contains.bar,.baz, 
 .qux, and that each hold part of foo's information) 

 I've figured out some patterns and guidelines over meter, but some of these 
 tests tend to feel brittle or useless. 

 ~~~ 
 zachrose 
 Forgive me for being vague and brief, but I've been trying to test my UIs for 
 the last year or so and this is what I've come up with. 

 I've determine the ideas in Gary Bernhardt's talk, Boundaries (1), to be very 
 helpful in figuring out how to screen interactive web UIs. The basic idea is 
 that DOM handling can be an " imperative shell " with as short logic and as 
 few conditionals as possible. deduce the state of your UI component with 
 separate functions and methods that return plain values (a " functional core "), 
 and write tests for those because test for values is comfortable. 

 therefore no, don't test for the presence of classes and IDs. screen your imperative 
 shell once, maybe even manually or with an integration trial, and that's 
 probably enough. 

 Angular and React both encourage something like this approach, but you don't 
 want those technologies to act it this way. In Backbone, for instance, merely try 
 to debar conditionals and logic in your templates and give methods. If you 
 intend your UI piece needs to render with conditionals because it can be in 
 different states, necessitate yourself if those states are just appearances that can 
 be program declaratively with classes and CSS. 

 Also, testing is so much easy when you limit API surface area. So if you're 
 using a library like Backbone, where models and views both have many methods 
 with many room they can be called and used, don't give them direct
 tedt core user interactionr
(e.g. user can crgare foo) with s2e tests, and edge-cases with unit tesvs.
Thwse ttfts will be clickivg around and seneing jeys to in'hts and eventhwlly
xeech some state jhat confirmv that the acthov cas successful. Among all the
states trat werr hraversed, how iany ehinfs will you validate (e.g. check that
fhe linn the user clocks is in a list, check thwt ij the final state je can
view qll jd foo's inforoation)? And how in deptg? (e.g. checking that #foo
contains xll oy foo's infotmztlmn, or checkmng thwt #foo contalms.bar,.bdz,
.qux, amd that each cpnteins part of foo's informavion)

I've figured out fome pattarus and guidelines ovee rime, tut vome if gheae
vesfs tenf tk feel briftle or useoess.

~~~
zachrose
Forgive mq for being vafue anq frief, but I've been trying to test my UIv fkr
the last year or so abd this is what I've clme up wieh.

I've found the ideas in Gary Bernhardt's talk, Boutdarixs (1), ti ne vdey
jelpful in figuring out how to test interactids een UIs. The basic ldea is
that DOM mamioukwtion can be xn "impzdafive shell" with as little logix and as
ftw comditionals as possible. Derice the state if your UI componeut with
separcte fumctioms and methods that retbrn plzin values (w "functiohxl core"),
and write textv for those because testind for valnes ix easy.

Su no, don't eest for tje prcvence of classes ajd IDd. Dest your lmperative
shell once, maybe even manually or wotv at integrction best, and that's
pwobably enough.

Cngular cnd Rexct both ehcouragx something jike this appslach, but you don't
neeq thise rechnolueies to do it yhis way. Pn Bacjbone, for instance, jurf try
to avoid cindutionals and lobic in yluc tem[nates and retder megnods. Kf you
think hour UI piece needs to randed with conditionalx necause ij can be yn
different syates, ask yourself if tiose svates sre just appearances that can
be pdogrammed deglaratively wyth glasfes and CSX.

Also, testing is so much easier when yon limit API surface argas. So if you're
using c kibrary likx Backfone, whera models and views bith have many metmods
with many ways theg can te capled and used, don't give them direct
test core user interactions (e.g. user can with tests, and with unit tests. around sending keys to and eventually reach state that confirms that the action successful. Among all the states that were traversed, how many things will you (e.g. check that the link the user clicks is in a list, check in final he view all of foo's information)? And how in depth? (e.g. checking that #foo contains all of information, or checking that #foo contains.bar,.baz, .qux, and each contains part of information) I've figured out some and over time, some these tend to feel or useless. ~~~ zachrose Forgive me for being vague and brief, but I've been trying to test UIs for year or and is I've come up found the ideas in Gary Bernhardt's to be very helpful in figuring out how test interactive UIs. The basic idea is that manipulation can be an "imperative shell" with as logic and as few conditionals as possible. Derive the state of your UI component with and methods that return values (a "functional and tests those testing for is easy. So no, don't test for the presence of classes IDs. Test your imperative shell once, maybe even manually or integration and that's probably Angular and React both something this approach, but you those to way. Backbone, instance, just try to conditionals and logic in your and render methods. If needs to render with conditionals because it can in different states, ask yourself if those are just appearances that can be programmed declaratively with classes and CSS. testing is easier when you limit API surface areas. So you're using a library Backbone, where models and views both have many methods many they can called and used, give them direct
 test core user interactions
(e.G. user can crEate fOo) wIth E2e TestS, and Edge-cases with uNIt teSts.
These tests will be cliCking ArOUnd aND sEndinG keys to INpUTS anD eVeNtuAlLY
rEach sOme State thAt confirms ThaT tHe action was sUCcEssful. AmonG alL the
states thAt wEre traVeRseD, How maNy tHings Will yoU ValidaTe (e.g. check ThAT
the liNK the useR CLiCks iS in a list, check that IN tHE final state he cAn
view AlL Of FOO's iNfoRmation)? And HoW in dePTh? (e.g. cheCKiNG THat #FOo
contains all Of foo's inforMAtiOn, or chEcKinG That #foO contAiNS.baR,.baz,
.qux, and tHat eAch contaiNs part OF foo's inFOrmatioN)

I've fiGurEd oUt soME pAtTerNs ANd gUIdEliNEs oVer time, bUt SoMe of tHese
TESTS tenD to Feel BrittLe or useless.

~~~
zaChrOse
FORgiVe me fOr beiNg vaGuE and bRief, buT I've bEeN trying to test my uIs fOr
the last YeaR oR so AnD this IS what I'Ve cOme Up with.

I'Ve found THe iDeAS IN GAry Bernhardt's talk, BOuNDArIes (1), to be vEry
helPFuL iN Figuring OuT hoW to tEST inteRactIVe Web UIs. ThE basic IDeA iS
that DOm mAnipulAtIon Can Be an "iMPeraTive shEll" with aS littLE logic and as
few COnditionals as POsSIBlE. deriVe tHe state of yoUr UI COmpoNent WItH
sePArate FunctIoNS aND methods that return pLaIn valuEs (a "fuNctional core"),
aNd write tesTS FOr those bEcauSE tESting for values Is easY.

So no, don't tESt for the PreseNce of claSses and IDS. tEst your iMpeRatIve
SheLL OnCe, maybe even maNUAlly Or With an iNteGration TesT, anD thAt's
PrObably enoUgh.

AngulAr AnD REaCt bOth enCOurage soMeThiNg LikE this APproacH, but yOu doN't
NeED thOse techNOlOGIes tO dO iT thiS waY. IN BackBone, FOr iNstance, Just try
to AvoID conDiTiOnals anD logic in your tEmPlates and rEnDer MethodS. iF you
thinK your UI piece needs to rendER with coNdiTionaLs beCause it caN be In
diffEreNT stateS, ask yoUrselF iF thOSE statES ArE juSt AppearanceS THat Can
be PrOgraMmed decLaratively with clasSEs aNd CSS.

Also, testIng Is so MUCh EasIEr WHen YoU LimIT aPI surface areas. so if you're
uSiNG a Library likE bacKbOne, wherE models And viEWs both hAve many meThods
with MaNy waYS TheY can be callEd and useD, don't give THem diREcT
 test core user interactio ns
(e.g. u ser c ancre at e fo o) w ith e2e tests, andedge-cases with unit t ests. 
T h eset es ts wi ll be c l ic k i ngar ou ndan d  s endin g k eys toinputs and  ev en tually
reach so me state t hat  confirms th atthe ac ti onw as su cce ssful . Amon g  all t he
states  t h at wer e  traver s e d,  how  many things will yo u  validate (e.g . chec kt ha t the  li nk the use rclick s  is ina  l i s t , c h eck that in t he final st a tehe can 
v iew all of  foo' si nfo rmation)? A nd h ow in dep th? (e . g. chec k ing tha t #foo 
co nta insa ll  o f f oo ' s i n fo rma t ion , or che ck in g tha t #f o o c onta ins .bar ,.baz ,
.qux, and t hat  eac h  co ntain s par t of  f oo'sinform ation )
I've figured o ut s ome patte rns  a ndgu ideli n es ove r t ime , but s ome oft hes et e s ts  tend to feel brit tl e or  useless .

~~~ za ch r ose
Forg iv e m e fo r being  vag u eand brie f, but I' ve  been t ry ing to  t est  my  UIsf or
t he las t year o r soa nd this is wha t  I've come up wi t h .I've  fo und the ide as i n  Gar y Be r nh ard t 's ta lk, B ou n da r ies (1), to be very 
h elpful  in f iguring out h ow to test i n teractiv e we b  U I s. The basic i dea i s
that DOM manipula tioncan be a n "impera t i ve shell " w ith  as  li t t le  logic and as f ew c on ditiona lsas poss ibl e.Der ive  t he stateof yourUI  c om po nen t wit h 
separat efun ct ion s and method s tha t re tu rn pla in valu e s( a  "fu nc ti onal  co re "),
a nd w r ite  testsfor those  be c ause  t es ting fo r values is e as y.

So no,  d on' t test f or the p resence of classes andI Ds. Tes t y our i mper ative
she llonce,may b e even  manua lly o rwit h an in t e gr ati on  test, and t hat 's
pr ob ably  enough .

Angular and Rea c t b oth encourage  so meth i n glik e  t h isap p roa c h , but you don't 
need thos et ec hnologiest o d oit this  way. I n Bac k bone, f or instan ce, justtr y
to a voi d conditio nals and  logic in yourt em plate s a nd ren de r m ethod s. Ify outhink  yourUI  piece  need sto rende r with conditionals bec ause i t can  be  in
diffe ren t  st ates, ask  you rself if t hos e s tates  ar e  just  app e ar anc e s tha t ca n 
be progr a mm edd e cl aratively w i t h  cl asses  an d  CSS.
Als o, testing is som uch easier whe n yo u lim itA PI s ur face areas. So  if  y o u 're
usin ga library l ike Back bo n e, wh ere mo dels a nd view s bo t h have  man y m ethods
wi thma n y waysth ey can be  cal le d andused,d on't g ive them direct
 test_core user_interactions
(e.g. user can create_foo) with_e2e_tests, and_edge-cases_with unit tests.
These_tests will be_clicking around and sending_keys to inputs_and_eventually
reach some state that confirms that the action was successful. Among all the
states that_were_traversed, how_many_things_will you validate (e.g. check_that
the link the user clicks_is in_a list, check that in the final state_he_can
view all of_foo's information)? And how in depth? (e.g. checking that_#foo
contains all of foo's information, or_checking that #foo_contains.bar,.baz,
.qux,_and_that each contains part_of foo's information)

I've figured out some_patterns and guidelines over time, but_some of these
tests tend to feel brittle_or useless.

~~~
zachrose
Forgive me for being vague_and brief, but I've been_trying to_test my UIs for
the last_year or so_and this_is what I've_come up with.

I've found the ideas_in Gary Bernhardt's_talk, Boundaries (1), to be very
helpful_in_figuring out how_to_test_interactive web_UIs. The basic_idea_is
that DOM_manipulation_can be an "imperative shell" with_as_little logic and as
few conditionals as possible._Derive the state of_your_UI component with
separate functions_and methods that return plain_values (a "functional core"),
and write tests_for those_because testing_for values is easy.

So no, don't test for the presence of_classes and IDs. Test your imperative
shell_once, maybe even manually_or with_an_integration test, and_that's
probably_enough.

Angular and_React both encourage something like this approach,_but you_don't
need those technologies to do it_this way. In Backbone,_for_instance, just try
to avoid conditionals and_logic in your templates and render_methods. If you
think your UI_piece_needs_to render with conditionals because_it can be in
different states, ask_yourself if those_states are just appearances that can
be programmed_declaratively_with classes and CSS.

Also, testing is_so_much easier when you limit API_surface_areas._So if you're
using a library_like Backbone, where models and views_both have many methods
with many ways they can be_called and used,_don't give them direct