-
Notifications
You must be signed in to change notification settings - Fork 576
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
Improve running tests when server is missing #6494
Conversation
ff58f60
to
368cd6e
Compare
…ion has gone away
368cd6e
to
e8f32bc
Compare
I'll merge to improve our DX tomorrow 🙈 Feel free to review in retrospect (or not 😊). |
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.
Nice DX improvement 👍
function getCredentials(): Credentials { | ||
if (typeof publicKey === "string" && typeof privateKey === "string") { | ||
return { | ||
kind: "api-key", | ||
publicKey, | ||
privateKey, | ||
}; | ||
} else { | ||
return { | ||
kind: "username-password", | ||
username, | ||
password, | ||
}; | ||
} | ||
} | ||
|
||
const credentials = getCredentials(); |
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.
Looks like the function is only used once, so it may not need to be a function.
function getCredentials(): Credentials { | |
if (typeof publicKey === "string" && typeof privateKey === "string") { | |
return { | |
kind: "api-key", | |
publicKey, | |
privateKey, | |
}; | |
} else { | |
return { | |
kind: "username-password", | |
username, | |
password, | |
}; | |
} | |
} | |
const credentials = getCredentials(); | |
const credentials: Credentials = | |
typeof publicKey === "string" && typeof privateKey === "string" | |
? { kind: "api-key", publicKey, privateKey } | |
: { kind: "username-password", username, password }; |
); | ||
} | ||
|
||
function printWarningBox(...lines: string[]) { |
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.
We may want to utilize this elsewhere as well, could we move this into /utils
? 🙂
describe("Logging", () => { | ||
importAppBefore(buildAppConfig("with-pbs").anonAuth().flexibleSync()); | ||
afterEach(() => Realm.clearTestState()); | ||
// Skipped because reusing a single app across tests break this |
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.
// Skipped because reusing a single app across tests break this |
* Moved app import util into the hook * Moved skipping tests on missingServer into importAppBefore hook * Skip tests which importAppBefore when failing to install * Renamed "realmBaseUrl" to "baseUrl" * Fix closing a realm if import skips it completely * Moved testing non-existing app id into "with valid app" * Printing warning after all tests * Fixed "allowSkippingServerTests" * Adding documentation to importAppBefore * Moved "Logging" test out of "SessionTest" because the importApp function has gone away
What, How & Why?
I want to improve the default experience of running our tests.
Unfortunately, contributors to the project isn't allowed to pull the docker image and run the test server, but that shouldn't keep them from running tests at all. In its current form, its a subtly documented feature of the test runner that you can run with
missingServer
context, but I want to make this more obvious and improve the default experience (when the server is missing).If the environment does not explicitly provide a
baseUrl
nor setmissingServer=false
the tests usingimportAppBefore
will skip if the app import fails due to a connection refusal. If this happens, a warning will be printed after all tests has ran:realmBaseUrl
tobaseUrl
since theres only ever one base url, so there's no need to disambiguate it and the latter is the name used in the code anyway.missingServer
, to include this check in theimportAppBefore
hook as they were (almost) always used together anyway and could easily be forgotten.☑️ ToDos
Compatibility
label is updated or copied from previous entryCOMPATIBILITY.md
package.json
s (if updating internal packages)Breaking
label has been applied or is not necessary