Skip to content

Commit

Permalink
test: make tests more stable (#825)
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus authored May 28, 2024
1 parent 4ae8b63 commit 5d92b06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/end-to-end/multitenancy.dynamic_login_methods.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,14 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {

it("should postpone render with no react-router-dom", async function () {
await page.setRequestInterception(true);
const requestHandler = (request) => {
let resolveLoginMethodsReq;
const loginMethodsReqPromise = new Promise((res) => {
resolveLoginMethodsReq = res;
});
const requestHandler = async (request) => {
if (request.url().startsWith(LOGIN_METHODS_API)) {
setTimeout(() => request.continue(), 500);
await loginMethodsReqPromise;
request.continue();
} else {
request.continue();
}
Expand All @@ -249,7 +254,7 @@ describe("SuperTokens Multitenancy dynamic login methods", function () {

const spinner = await waitForSTElement(page, "[data-supertokens~=delayedRender]");
assert.ok(spinner);
await page.waitForTimeout(2000);
resolveLoginMethodsReq();
const providers = await getProvidersLabels(page);
compareArrayContents(providers, ["Continue with Apple"]);
});
Expand Down
1 change: 1 addition & 0 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export async function waitForSTElement(page, selector, inverted = false) {
console.log("Caught exception in waitForSTElement, but retrying until timeout", ex);
}
}
throw new Error(`Waiting for ${selector} to ${inverted ? "disappear" : "appear"} timed out`);
}

export function waitForUrl(page, url, onlyPath = true) {
Expand Down

0 comments on commit 5d92b06

Please sign in to comment.