cfpb / development

A repository for the discussion and publication of the CFPB development team standards.
Creative Commons Zero v1.0 Universal
64 stars 32 forks source link

Improving the docs: browser testing! #115

Open marteki opened 8 years ago

marteki commented 8 years ago

The testing guidelines have very little information about what functional browser testing looks like in D&D, and the stuff that's there now might be a bit out-of-date.

Also, in different code reviews of the same browser test spec, I've received conflicting information from reviewers about what "best practice" should be for a particular line. Maybe we could add some more guidance around what our best practices are for browser testing?

Current behavior

KimberlyMunoz commented 8 years ago

Thanks for bringing this up!

There is a difference between truthy and true. toBeTruthy (Jasmine) / to.be.ok (Chai BDD) and toBeTrue() (Jasmine) /``to.be.true (Chai BDD) in how they'll evaluate out and we've tried to use true over truthy whenever we can because it is more strict. I think guidance on that is helpful!

I don't think we should issue guidance on what type of syntax to use. It looks like all the syntax above is in Jasmine, which is the best supported tool for Protractor, but there's been talk about switching to Mocha Chai to keep it consistent with our unit tests. We also want to leave ourselves open in case there's a better tool for testing other things like React. I think we should describe what is used rather than offer guidelines here. (Also, I'm not sure what syntax uses toBeTrue(), I tried searching in projects to research it but came up empty.)

marteki commented 8 years ago

There is a difference between truthy and true. toBeTruthy (Jasmine) / to.be.ok (Chai BDD) and toBeTrue() (Jasmine) /to.be.true (Chai BDD) in how they'll evaluate out and we've tried to use true over truthy whenever we can because it is more strict. I think guidance on that is helpful!

Then maybe that's all the guidance needed, rather than syntax standards: "When looking at how things evaluate, be as strict as possible."

(Personal note: when first starting Jasmine/Protractor browser tests at the Bureau, I had tests written using toBe( true) and was advised to change them to toBeTruthy(). Several months later, told by someone else that they should be changed back. Knowing that we lean more towards strict evaluation would be helpful to know when deciding if a code review change request is actually the best choice for a particular situation.)

Finally, toBeTrue() is used in a Jasmine add-on. I hadn't checked if the Bureau was using it specifically, but it could be something that outside folks are using or new folks have experience with. Maybe another vote in the "don't talk about specific syntax" column!

KimberlyMunoz commented 8 years ago

@sebworks has some good starter notes here: https://gist.github.com/sebworks/edb4c89c4e8c244812f2dac3d6f77a89

I'm prodding him to add to them to the repo!