Skip to content

Commit 7907404

Browse files
committed
fix(typescript): Fix typescript declarations
1 parent 18575c6 commit 7907404

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

index.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,40 @@ declare namespace Cypress {
66
* Command to save current localStorage values into an internal "snapshot"
77
* @example cy.saveLocalStorage()
88
*/
9-
saveLocalStorage(): Chainable<Element>
9+
saveLocalStorage(): Chainable<undefined>
1010

1111
/**
1212
* Command to restore localStorage to previously "snapshot" saved values
1313
* @example cy.restoreLocalStorage()
1414
*/
15-
restoreLocalStorage(): Chainable<Element>
15+
restoreLocalStorage(): Chainable<undefined>
1616

1717
/**
1818
* Command to clear localStorage "snapshot" values
1919
* @example cy.clearLocalStorageSnapshot()
2020
*/
21-
clearLocalStorageSnapshot(): Chainable<Element>
21+
clearLocalStorageSnapshot(): Chainable<undefined>
2222

2323
/**
2424
* Command to get localStorage item value
2525
* @param {string} itemKeyName - localStorage item to get
2626
* @example cy.getLocalStorage("cookies-accepted")
2727
*/
28-
getLocalStorage(itemKeyName: string): Chainable<Element>
28+
getLocalStorage(itemKeyName: string): Chainable<string|null>
2929

3030
/**
3131
* Command to set localStorage item value
3232
* @param {string} itemKeyName - localStorage item to set
3333
* @param {string} value - value to be set
3434
* @example cy.setLocalStorage("cookies-accepted", "true")
3535
*/
36-
setLocalStorage(itemKeyName: string, value: string): Chainable<Element>
36+
setLocalStorage(itemKeyName: string, value: string): Chainable<undefined>
3737

3838
/**
3939
* Command to remove localStorage item
4040
* @param {string} itemKeyName - localStorage item to remove
4141
* @example cy.removeLocalStorage("cookies-accepted")
4242
*/
43-
removeLocalStorage(itemKeyName: string): Chainable<Element>
43+
removeLocalStorage(itemKeyName: string): Chainable<undefined>
4444
}
4545
}

test-e2e/typescript/cypress/integration/assertions-example.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ describe("localStorage cookies-accepted item", () => {
2222

2323
it("should be true after reloading", () => {
2424
cy.getLocalStorage("cookies-accepted").then((cookiesAccepted) => {
25+
if (cookiesAccepted !== null) {
26+
expect(JSON.parse(cookiesAccepted)).to.equal(true);
27+
}
2528
expect(cookiesAccepted).to.equal("true");
2629
});
2730
});

0 commit comments

Comments
 (0)