Skip to content

Commit fda8218

Browse files
committed
refactor(cypress): use correct typings with overrides
1 parent 2dc4cab commit fda8218

1 file changed

Lines changed: 6 additions & 26 deletions

File tree

packages/e2e-cypress/src/helpers/commands/cypress-overrides.ts

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// TODO: Cypress types when overriding select are wrong up until 9.7, they miss subject param
2-
// this forces us to use ts-expect-error on every override
3-
41
function isCheckBasedComponent(subject: JQuery<HTMLElement>) {
52
return (
63
subject.hasClass('q-checkbox') ||
@@ -10,16 +7,9 @@ function isCheckBasedComponent(subject: JQuery<HTMLElement>) {
107
}
118

129
export function registerCypressOverwrites() {
13-
Cypress.Commands.overwrite(
10+
Cypress.Commands.overwrite<'select', 'element'>(
1411
'select',
15-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
16-
// @ts-expect-error
17-
(
18-
originalFn,
19-
subject: JQuery<HTMLElement>,
20-
valueOrTextOrIndex: string | number | Array<string | number>,
21-
options,
22-
) => {
12+
(originalFn, subject, valueOrTextOrIndex, options) => {
2313
// Hijack the subject to be the root q-select element if we notice we are inside one of them
2414
// This is due to Quasar passing data-cy attr to the underlying "q-field__native" element
2515
// The re-target allow to use this command seamlessly, but the problem will still bite back in other scenarios
@@ -60,44 +50,34 @@ export function registerCypressOverwrites() {
6050
return;
6151
}
6252

63-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
64-
// @ts-expect-error
6553
return originalFn(subject, valueOrTextOrIndex, options);
6654
},
6755
);
6856

69-
Cypress.Commands.overwrite(
57+
Cypress.Commands.overwrite<'check', 'element'>(
7058
'check',
71-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
72-
// @ts-expect-error
73-
(originalFn, subject: JQuery<HTMLElement>, options) => {
59+
(originalFn, subject, options) => {
7460
if (isCheckBasedComponent(subject)) {
7561
if (!subject.is('[aria-checked="true"]')) {
7662
cy.wrap(subject).click();
7763
}
7864
return;
7965
}
8066

81-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
82-
// @ts-expect-error
8367
return originalFn(subject, options);
8468
},
8569
);
8670

87-
Cypress.Commands.overwrite(
71+
Cypress.Commands.overwrite<'uncheck', 'element'>(
8872
'uncheck',
89-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
90-
// @ts-expect-error
91-
(originalFn, subject: JQuery<HTMLElement>, options) => {
73+
(originalFn, subject, options) => {
9274
if (isCheckBasedComponent(subject)) {
9375
if (!subject.is('[aria-checked="false"]')) {
9476
cy.wrap(subject).click();
9577
}
9678
return;
9779
}
9880

99-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
100-
// @ts-expect-error
10181
return originalFn(subject, options);
10282
},
10383
);

0 commit comments

Comments
 (0)