Playwright version: 1.43.1
I am currently investigating why some of my e2e tests are very slow if it needs to be rewritten or just need to increase the default timeout. I recognize some test that needs to be rewritten and some test cases even simple ones are taking a very long time to finish due to after hooks.
Here is a sample snippet of my trace file:
After hooks is very slow for unknown reason.
[After Hooks] (https://i.sstatic.net/nuSnGU4P.png)
Just in case, anyone is wondering how the before hooks looks like:
Before Hooks
I have a fixture but there are no custom hooks in there also. Here is a snippet of the fixture
export const test = base.extend<APIRequestOptions & APIRequestFixture>({
apiBaseURL: ['', { option: true }],
apiKeyCloakURL: ['', { option: true }],
asUser: async ({ apiBaseURL, apiKeyCloakURL }, use) => {
const buildQueries = async (username: SupportedUsernames) =>
createQueries({ apiUrl: apiBaseURL, keycloakUrl: apiKeyCloakURL, username });
await use(buildQueries);
},
page: async ({ baseURL, page }, use) => {
await page.goto(`${baseURL}`, { waitUntil: 'domcontentloaded' });
// added this to mimic the waiting time before the actual page is loaded
await Promise.all([
page.getByText('Initialising...').waitFor({ state: 'visible' }),
page.getByText('Initialising...').waitFor({ state: 'detached' }),
]);
// Re-authenticate if necessary
await use(page);
},
});
Do you have any ideas why it has a very big duration in the After Hooks?
I did try to investigate if there are any Promise objects or locators without await but I assure there are none.
I am expecting that after hooks should be in low duration and not within 1-2 or more minutes range.
Leicester Digitalis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.