acceptable-hamburger-48790
08/22/2022, 1:51 PMbrash-army-33335
08/22/2022, 2:23 PMmicroscopic-crowd-9149
08/22/2022, 4:26 PMmicroscopic-crowd-9149
08/22/2022, 4:49 PMdamp-glass-84607
08/22/2022, 4:57 PMfresh-nail-30646
08/22/2022, 8:31 PMplain-garden-5374
08/22/2022, 8:51 PMabundant-hydrogen-26466
08/22/2022, 9:17 PMfresh-nail-30646
08/22/2022, 9:26 PMabundant-hydrogen-26466
08/22/2022, 9:37 PMbrash-mechanic-5372
08/22/2022, 9:38 PMabundant-hydrogen-26466
08/22/2022, 9:40 PMlet LOCAL_STORAGE_MEMORY = {};
Cypress.Commands.add("saveLocalStorage", () => {
cy.window().then(window => {
Object.keys(window.localStorage).forEach(key => {
LOCAL_STORAGE_MEMORY[key] = window.localStorage[key];
});
});
});
Cypress.Commands.add("restoreLocalStorage", () => {
cy.window().then(window => {
Object.keys(LOCAL_STORAGE_MEMORY).forEach(key => {
window.localStorage.setItem(key, LOCAL_STORAGE_MEMORY[key]);
});
});
});
put that into your commands.js, and then at then at the top of your tests after your describe(
and before your first it(
test, call it this way:
beforeEach(() => {
cy.restoreLocalStorage();
});
afterEach(() => {
cy.saveLocalStorage();
});
fresh-nail-30646
08/22/2022, 9:52 PMhigh-restaurant-93761
08/22/2022, 10:54 PMlittle-france-10142
08/22/2022, 10:56 PMcy.visit
it results in it getting tagged with the baseUrl
.
From what I've read, you're not supposed to navigate to external sites within the same test. It looks like there's the option to enable the experimental feature (cy.origin
) but that seems like a lot. The other option I'm seeing is cy.routing
but I'm not sure that's what I'm after.
Does anyone here have practical experience with Mailosaur and navigating through an email link in one test?abundant-hydrogen-26466
08/22/2022, 11:21 PMCypress.Commands.add('crossVisit', (crossUrl) => {
// this is a workaround due to the fact that Cypress currently does not support hitting a different super domain with .visit()
cy.window().then((window) => {
window.location.assign(crossUrl);
});
});
chilly-queen-22182
08/23/2022, 2:15 AMacceptable-hamburger-48790
08/23/2022, 3:59 AMearly-nest-3800
08/23/2022, 6:57 AMearly-nest-3800
08/23/2022, 7:05 AM<h1/><div><h2/></div>
, what's the most efficient way to get from the h1 to the h2? I'm thinking of some function like .next("h2")
that does preorder DOM traversal.blue-battery-71202
08/23/2022, 11:03 AMAPI.getAccessCodes(id).then((response: **GetCodesResponse**) => { // error 1
expect(response.success).to.be.true; // intellisense work here as expected
expect(response.data.code).to.equal('12345678'); // intellisense work here
});
// error 1:
// No overload matches this call. Argument of type '(response: GetCodesResponse) => void' is not assignable to parameter of type '(this: ObjectLike, currentSubject: Response<any>) => void'.
// API.getAccessCodes(id: string): Cypress.Chainable<Cypress.Response<any>>
getAccessCodes
return the cy.request()
, and the above example works as expected, however I cannot seem to resolve the issue with the response type, and if I do, TS loses the ability to have intellisense inside the .then()
little-france-10142
08/23/2022, 3:33 PMfreezing-wall-5568
08/23/2022, 4:08 PMhallowed-lighter-4305
08/23/2022, 4:34 PMfresh-doctor-14925
08/23/2022, 4:38 PMhallowed-lighter-4305
08/23/2022, 4:46 PMearly-optician-55799
08/23/2022, 5:03 PMhallowed-lighter-4305
08/23/2022, 5:14 PMhallowed-lighter-4305
08/23/2022, 5:24 PMearly-optician-55799
08/23/2022, 5:28 PM