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

Let Jasmine handle promises in tests #169

Closed
17 tasks done
raphinesse opened this issue Oct 29, 2019 · 1 comment
Closed
17 tasks done

Let Jasmine handle promises in tests #169

raphinesse opened this issue Oct 29, 2019 · 1 comment
Labels
bug Something isn't working enhancement New feature or request

Comments

@raphinesse
Copy link
Contributor

raphinesse commented Oct 29, 2019

Almost all asynchronous interfaces we provide or work with, make use of Promises. Jasmine has elegant built-in support for handling promises. Nonetheless, most asynchronous legacy tests don't make use of it. Instead, they are using makeshift and often buggy constructs using Jasmine's callback-style asynchronous tests (using the done parameter).

In many repos the transition to a simpler more robust Promise handling in tests has already been made. This issue should serve as a checklist of the remaining work in this area.

It's also often helpful to make this transition before removing Q (#7) in the given repo.

Of course, there are perfectly acceptable usages of done, most notably when working with callback-based async interfaces. But these are the vast minority in our tests.

Task list

(only repos that feature or featured usage of done)

Tools/libs

Platforms

Plugins

  • cordova-plugin-battery-status (acceptable usage)
  • cordova-plugin-file (acceptable usage)
  • cordova-plugin-geolocation (acceptable usage)
  • cordova-plugin-inappbrowser (acceptable usage)
  • cordova-plugin-media (acceptable usage)
  • cordova-plugin-screen-orientation
@raphinesse raphinesse added bug Something isn't working enhancement New feature or request labels Oct 29, 2019
raphinesse added a commit to apache/cordova-ios that referenced this issue Oct 29, 2019
@raphinesse raphinesse changed the title Let Jasmine handle async test results Let Jasmine handle promises Oct 29, 2019
@raphinesse raphinesse changed the title Let Jasmine handle promises Let Jasmine handle promises in tests Oct 30, 2019
@raphinesse
Copy link
Contributor Author

For future reference. You can find all usage of Jasmine's done with the following ESLint config:

rules:
    no-restricted-syntax:
        - error
        - selector: 'CallExpression[callee.name=it] > :function:nth-child(2) > :first-child'
          message: "Jasmine's done is not allowed"

raphinesse added a commit to apache/cordova-plugin-screen-orientation that referenced this issue Nov 21, 2019
* test: let Jasmine handle promises

Last in line for apache/cordova#169

* lock in portrait mode to avoid trouble on CI

cordova-paramedic runs the SauceLabs CI tests in portrait mode. For
the Android 7.0 target, it seemed as our locking to landscape interferes
with the Appium driver trying to set the app to portrait orientation.
The result is a failure to connect to the device and finally a timeout.
To avoid that, we are locking the app into portrait mode instead.

* test: verify orientation after locking
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant