Getting started #148
stroiman
started this conversation in
Getting started tips
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Some parts of this code is growing more mature; the general API seems to have settled well around function
New(...BrowserOption). I generally passing the root HTTP handler as input to bypass the TCP stack for reduced overhead (see caveat in the bottom)One could imagine many useful helper functions; but I don't want to add simple functions usable only in some cases, that can easily be created as a helper function in your own test code
WithLoggeraccepts an*slog.Logger- Go's standard for structured logging, passing log records to anslog.Handlerinterface. Gost-DOM has aHandlerimplementation that directs log output to thetesting.TB.Logfunction. JavaScriptconsoleoutput will be directed to the logger at appropriate levels.console.errorwill result in anslog.LevelErrorlog record.By default the log helper will also mark a test as failed, calling
TB.Fail(), if an error is logged. As a consequence, JavaScript error logs will cause the test to fail. I find this useful, as error logs typically indicate the code isn't behaving as I expect. I want to be notified, this is a potential false positive. In some cases, e.g., when tampering with cookies in CSRF test code, I can always change the default.Caveat: when using
WithHandler(), NO outgoing HTTP requests will be sent, so referencing JavaScript from e.g., a CDN will not work. The fix isn't complicated, just haven't been a priority, as my personal philosophy is to have a test suite independent of external dependencies.Beta Was this translation helpful? Give feedback.
All reactions