You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
...I think much of @appium/test-support doesn't add value. The withMocks() and withSandbox() methods are better expressed more simply using sinon directly. Sinon's mocking API looks like an anti-pattern; there's no visibility into what exactly gets checked when mock.verify() is called, and it's better to be explicit about assertions. Further, it makes its own assertions; we already have an assertion library (chai).
Both withMocks() forces the consumer into defining values within the suite itself (describe callback), which does not jive well with how Mocha works. This is especially problematic if the parameter you're passing to withMocks cannot be created synchronously, as describe callbacks are synchronous. In other words, if you wanted to use withMocks(someValue) and you had to const someValue = await someMethod(), you're SOL.
In general, unless a value is a constant, it should not be defined within a suite callback. Instead, the value can be declared there (via let) and should be assigned via beforeEach() or before() hooks.
Tests are better without a lot of abstraction. KISS!
We should deprecate withMocks, and withSandbox at minimum, and offer some alternative patterns. I'm not sure if these methods are used outside of our official drivers... I'll do some searching.
The text was updated successfully, but these errors were encountered:
(This comment copied from appium/appium-xcuitest-driver#1531)
...I think much of
@appium/test-support
doesn't add value. ThewithMocks()
andwithSandbox()
methods are better expressed more simply usingsinon
directly. Sinon's mocking API looks like an anti-pattern; there's no visibility into what exactly gets checked whenmock.verify()
is called, and it's better to be explicit about assertions. Further, it makes its own assertions; we already have an assertion library (chai
).Both
withMocks()
forces the consumer into defining values within the suite itself (describe
callback), which does not jive well with how Mocha works. This is especially problematic if the parameter you're passing towithMocks
cannot be created synchronously, asdescribe
callbacks are synchronous. In other words, if you wanted to usewithMocks(someValue)
and you had toconst someValue = await someMethod()
, you're SOL.In general, unless a value is a constant, it should not be defined within a suite callback. Instead, the value can be declared there (via
let
) and should be assigned viabeforeEach()
orbefore()
hooks.Tests are better without a lot of abstraction. KISS!
We should deprecate
withMocks
, andwithSandbox
at minimum, and offer some alternative patterns. I'm not sure if these methods are used outside of our official drivers... I'll do some searching.The text was updated successfully, but these errors were encountered: