@umbraco/playwright-testhelpers
Version:
Test helpers for making playwright tests for Umbraco solutions
40 lines • 1.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.test = void 0;
const test_1 = require("@playwright/test");
const _1 = require(".");
const umbraco_config_1 = require("../../umbraco.config");
const test = test_1.test.extend({
umbracoApi: async ({ page }, use) => {
const umbracoApi = new _1.ApiHelpers(page);
// Runs the isAccessTokenValid before each implementation of umbracoApi in our tests (Which is every single one)
// await umbracoApi.isAccessTokenValid();
// TODO: use isAccessTokenValid in the tests, currently it is a bit flaky. So now we refresh the token after each test
await umbracoApi.refreshAccessToken(umbraco_config_1.umbracoConfig.user.login, umbraco_config_1.umbracoConfig.user.password);
await use(umbracoApi);
},
umbracoUi: async ({ page }, use) => {
const umbracoApi = new _1.UiHelpers(page);
await use(umbracoApi);
}
});
exports.test = test;
test.beforeEach(async () => {
await new Promise((res) => setTimeout(res, 300)); // Add delay before each test to avoid DB lock
});
test.afterEach(async ({ context }) => {
// Force kill context
for (const page of context.pages()) {
if (!page.isClosed()) {
await page.close();
}
}
try {
await context.close();
}
catch (e) {
console.warn('Context close error:', e);
}
await new Promise((res) => setTimeout(res, 500)); // Add delay before each test to avoid DB lock
});
//# sourceMappingURL=testExtension.js.map