Files
editor/cypress/e2e/cypress-wrapper-driver.ts
Harel M 124ae98bf3 E2E: Improve tests, lint, and add more drivers (#855)
This PR introduces lint to cypress code, adds drivers to try and
abstract the usage of cypress as much as possible.
Nothing very interesting, mainly to try out the driver pattern for the
e2e tests.
2023-12-27 20:58:24 +02:00

41 lines
1022 B
TypeScript

import { CypressHelper } from "@shellygo/cypress-test-utils";
export default class CypressWrapperDriver {
private helper = new CypressHelper({ defaultDataAttribute: "data-wd-key" });
public given = {
...this.helper.given,
/**
*
* @param url a url to a file, this assumes the file name is the last part of the url
* @param alias
*/
interceptGetToFile(url: string) {
let fileNameAndAlias = url.split('/').pop();
cy.intercept('GET', url, { fixture: fileNameAndAlias }).as(fileNameAndAlias!);
},
interceptAndIgnore(url: string) {
cy.intercept({ method: "GET", url }, []);
}
}
public get = {
...this.helper.get,
elementByClassOrType(slector: string) {
return cy.get(slector);
}
}
public when = {
...this.helper.when,
visit(address: string) {
cy.visit(address);
},
confirmAlert() {
cy.on("window:confirm", () => true);
}
}
public beforeAndAfter = this.helper.beforeAndAfter;
}