Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test-support: deprecate some portion thereof #18415

Open
boneskull opened this issue Mar 29, 2023 · 0 comments
Open

test-support: deprecate some portion thereof #18415

boneskull opened this issue Mar 29, 2023 · 0 comments
Labels
@appium/test-support chore refactoring, overhead, tests, etc.

Comments

@boneskull
Copy link
Contributor

(This comment copied from appium/appium-xcuitest-driver#1531)

...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.

@boneskull boneskull added chore refactoring, overhead, tests, etc. @appium/test-support labels Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@appium/test-support chore refactoring, overhead, tests, etc.
Projects
None yet
Development

No branches or pull requests

1 participant