-
Notifications
You must be signed in to change notification settings - Fork 586
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
move app tests to typescript #5297
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple small things. Otherwise LGTM
expect(this.app).instanceOf(Realm.App); | ||
const credentials = Realm.Credentials.emailPassword("me", "secret"); | ||
let didFail = false; | ||
const user = await this.app.logIn(credentials).catch((err) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be refactored to use expect().to.throw()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That only works for synchronously thrown errors - we should use expect().should.be.rejectedWith()
to assert rejection of promises. That being said, I don't think that'll be able to replace this code entirely as it's not simply matching on the error message, but also asserts the code
to be 50
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have only minor suggestions.
let failed = false; | ||
await app.logIn(credentials).catch((err) => { | ||
failed = true; | ||
expect(err.message).equals("cannot find app using Client App ID 'smurf'"); | ||
}); | ||
expect(failed).to.be.true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as with previous test - chai-as-promised
is "the way" to assert promise rejections.
expect(user).instanceOf(Realm.User); | ||
expect(user.deviceId).to.not.be.null; | ||
expect(user.providerType).equals("anon-user"); | ||
await user.logOut(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know the old test did this, but is it important? if not, it could be deleted. If yes, it might be better to do in an afterEach
or surround the other parts of this test in a try-finally
, where we ensure to log out, even if the code throws.
expect(this.app).instanceOf(Realm.App); | ||
const credentials = Realm.Credentials.emailPassword("me", "secret"); | ||
let didFail = false; | ||
const user = await this.app.logIn(credentials).catch((err) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That only works for synchronously thrown errors - we should use expect().should.be.rejectedWith()
to assert rejection of promises. That being said, I don't think that'll be able to replace this code entirely as it's not simply matching on the error message, but also asserts the code
to be 50
🤔
integration-tests/realm-apps/with-db/auth_providers/local-userpass.json
Outdated
Show resolved
Hide resolved
11f472a
to
b3eb27f
Compare
* Initial commit * Documenting guidelines for testing & refactoring accordingly (#4584) * Fixed types of openRealm * Adding documentation on the hooks * Apply suggestions from code review * Test Migration: Alias tests (#4581) * Migrate alias tests * Refactor to follow new test guidelines * Remove alias-tests from legacy test spec * Add migration tests (#5285) * Migrate set tests to integration tests (#5290) * Move list tests to ts (#5287) * move app tests to typescript (#5297) * remove mistakenly added duplicates of apps * Test Migration: Results Tests (#5325) * move mixed tests to integration tests (#5256) * Move array-buffer tests to integration tests (#5255) * use correct baseurl for tests (#5337) * migrate dictionary tests to ts (#5254) * move linking-objects tests to ts (#5268) * Test Migration: User Tests (#5324) * Test Migration: Queries test (#5299) * Test Migration: Notification Tests (#5347) * Add a debug launcher for integration tests * Fix the mongo client tests for local baas * fix queries test, make test errors more verbose * Remove Chrome Debugger and fix package-lock problems (#5403) * Pushed Chrome Debugger Removal with Lint errors (#5414) * fix the errors * Andrew/tests/fix-watch (#5412) * Initial commit * Fix watch for React Native * Remove lock files * Migrate object-tests to TS (#5348) * test migration: open-behaviour (#5365) * test migration: mixed-sync-test (#5398) * migrate encryption tests to TS (#5362) * migrate sync-based UUID, Dictionary and Set tests (#5356) * migrate realm tests to TS (#5352) there are additions to other files as well such as bson.ts, that is because the old realm.js file had som tests that made more sense elsewhere, so I've moved such tests into other fields where I thought it made more sense * migrate partition-values tests to TS (#5359) * test migration: session tests (#5391) * Fix issues with migrated integration tests, add select helper method. (#5429) * Refactored the importApp hook * Remove BSON as a dependency from tests * Fixed import app hook 🤞 * Renamed "BackingDB" to "mongodb" * Throw on app import errors * Delete the app on failure to import * Added bundled Realm to iOS app * Updating Gemfile.lock after RN update * Increase test timeouts * fix remainder of failing integration tests (#5451) * Cleanup tests and move test-runners into install-tests * Small Fixes for Stability and Cleanup * path tests now put realms in a testFiles folder which has been added to .gitignore * path tests now delete the realms when finished * increased the longTimeout to 30 seconds as some of the migrated tests can take this long * added more `this.longTimeout` calls where appropriate * added `mongodb-realm` directory to .gitignore, which contains app configuration when importing apps * Delete dependants of `tests` and any unused files * Andrew/app-importer/rules (#5478) * Fix for applying the default rules to BaaS * Remove any other rules and apply a general rule that allows everything * Change the app importer to update the default rule * Also fix it for realm-web * Fix web tests and apply PR feedback * Update docker image for BaaS in web tests * `realm-web` importing http service fixed (#5483) * Use the "default_rule" only for mongodb services * Ensure download assisted_agg in baas test server * Fix a broken test from upgrading baas
No description provided.