https://cypress.io logo
Join Discord
Powered by
# e2e-testing
  • l

    late-planet-4481

    06/29/2022, 1:41 PM
    There might be some projects out there that attempt this, but I'm not familiar with any of them. The ability to retrieve the test metadata will depend on your retrieval method. In my own case I am writing test case data to file during runtime, so I never really parse through the source. If you follow my example you'll have plenty of options available, including a simple
    cy.writeFile()
    command at the end of each test.
  • a

    adorable-stone-42197

    06/29/2022, 1:43 PM
    Can we use cy.session ( in custom command LOGIN; and just call cy.login in every beforeEach. Are we gonna save the session?
  • a

    ambitious-school-63406

    06/29/2022, 1:46 PM
    Thank you for the suggestion, will try that
  • l

    late-planet-4481

    06/29/2022, 1:59 PM
    Yes. It saves the session between tests. I don't know if it saves between specs, but that's easy for you to try.
  • a

    adorable-stone-42197

    06/29/2022, 2:30 PM
    I am trying but my cy.visit is stuck
  • p

    polite-lunch-8069

    06/29/2022, 2:48 PM
    Hi, is there a way to pass the exact same variable generated by function between different parts of test?
  • p

    polite-lunch-8069

    06/29/2022, 2:49 PM
    Copy code
    it("Creates xxx", () => {
        cy.get('some_input').type(key());
        });
    
    it("Tests feature", () => {
            cy.get('some_input').should('have.value', key())
        })
  • p

    polite-lunch-8069

    06/29/2022, 2:49 PM
    something like this
  • p

    polite-lunch-8069

    06/29/2022, 2:54 PM
    @gray-kilobyte-89541
  • m

    magnificent-finland-58048

    06/29/2022, 3:07 PM
    best is for the test to live where the code is and block PRs on regressions. Anything else is a failing setup imo. The only time I'd go for a external test repo is if 2 services shares the exact same tests.
  • m

    magnificent-finland-58048

    06/29/2022, 3:08 PM
    cy.session is between it blocks, not between specs cy.dataSession is another story... it can share between specs
  • m

    magnificent-finland-58048

    06/29/2022, 3:10 PM
    they have to share context in something like a before hook check out this

    https://www.youtube.com/watch?v=VUx-Ztkbtaw▾

  • a

    adorable-stone-42197

    06/29/2022, 3:37 PM
    Can someone help me using this plugin cy.dataSession. beforeEach(() => { cy.dataSession({ name: 'shared value', setup: () => cy.login(), validate: true, shareAcrossSpecs: true, }) });
  • a

    adorable-stone-42197

    06/29/2022, 3:38 PM
    Is this correct i am trying to run all the test with one login
  • f

    full-gold-83078

    06/29/2022, 3:47 PM
    How to set browser chrome in headless mode for version 10.3.0?
  • g

    gray-kilobyte-89541

    06/29/2022, 4:18 PM
    yes, i many ways
  • p

    polite-lunch-8069

    06/29/2022, 4:40 PM
    do you have anything about this on your website? :)
  • l

    late-planet-4481

    06/29/2022, 4:56 PM
    You have a few choices. One is to declare a global variable outside of the
    it()
    blocks and update it during the test. Sometimes I piggyback on the
    Cypress
    object. But in most cases it's a bad practice to make one test depend upon another 🙂
  • a

    adorable-stone-42197

    06/29/2022, 5:12 PM
    @gray-kilobyte-89541 am i doing right thing?
  • g

    gray-kilobyte-89541

    06/29/2022, 6:16 PM
    if you are following the readme and the examples tested in that repo, you are. But without a reproducible example, I cannot guarantee it
  • m

    magnificent-finland-58048

    06/29/2022, 6:37 PM
    but you are expected to have run into every possible problem, been there and done it before short of that, you are expected to mind read
  • a

    adorable-stone-42197

    06/29/2022, 7:52 PM
    export function createRoom(name = 'basement') { return cy.dataSession({ name, setup: () => { // yields the new room's ID return cy.task('makeRoom', name) }, validate(id) { // yields undefined if the room was not found // which we convert into a boolean value return cy.task('getRoom', id, { log: false }).then(Boolean) }, shareAcrossSpecs: true, }) } i watching this, and can’t find what is makeRoom?
  • a

    adorable-stone-42197

    06/29/2022, 7:54 PM
    Cypress.Commands.add('login', () => { if (Cypress.env('stage') === 'local') { window.localStorage.setItem('dhuiToken', Cypress.env('localToken')); cy.visit('/'); } else { cy.request({ method: 'GET', url: '/', followRedirect: false, }).then((response) => { const { location: redirectLocation } = response.headers; const state = decodeURIComponent( redirectLocation // @ts-expect-error .substring(redirectLocation.indexOf('state')) .split('=')[1] .split('&')[0] ); const optionsSessionToken = { method: 'POST', url: Cypress.env('session_token_url'), body: { username: Cypress.env('username'), password: Cypress.env('password'), options: { warnBeforePasswordExpired: 'true', multiOptionalFactorEnroll: 'true', }, }, }; cy.request(optionsSessionToken).then((responseWithSession) => { const { sessionToken } = responseWithSession.body; const qs = { client_id: Cypress.env('client_id'), state, redirect_uri: Cypress.env('redirect_uri'), response_type: 'code', scope: 'openid email offline_access', access_type: 'offline', sessionToken, }; cy.request({ method: 'GET', url: Cypress.env('auth_token_url'), form: true, followRedirect: false, qs, }).then(({ redirectedToUrl }) => { const accessToken = redirectedToUrl .substring(redirectedToUrl.indexOf('token')) .split('=')[1] .split('&')[0]; cy.wrap(accessToken).as('Token'); cy.visit(decodeURIComponent(redirectedToUrl)); }); }); }); } }); and this is my login command, and trying ti implement
  • a

    adorable-stone-42197

    06/29/2022, 8:12 PM
    export function singlecLogin() { cy.dataSession({ name: 'shared User', setup: () => cy.login(), validate: (x) => x === 'a', shareAcrossSpecs: true, }) } i try like this and got cy.task('dataSession:save') failed with the following error: > Converting circular structure to JSON --> starting at object with constructor 'Object' --- property 'window' closes the circle
  • g

    gray-kilobyte-89541

    06/29/2022, 11:44 PM
    ok, is this a question? seems like your setup is returning the
    window
    object?
  • c

    chilly-noon-25793

    06/30/2022, 4:02 AM
    thanks. tried switching cy.session with cy.dataSession, but doesn't like
    cy.origin
  • a

    adorable-stone-42197

    06/30/2022, 7:47 AM
    Yes a question. I am trying to follow example but i can’t doing right. In the examples u have how my custom login looks. And how i tried to login once and run all the test
  • s

    strong-kangaroo-46309

    06/30/2022, 8:21 AM
    Hello all. I am experimenting a little bit with Cypress but I am having some trouble. My use case is this: We are building a plugin for Confluence Cloud. This plugin is supposed to add an iframe and display some content (first screenshot with the two navigation bars). The issue is that when running a simple test, just logging in to the Confluence instance, after logging in I cannot see the content and the iframe is not added at all (second screenshot with just one navigation bar). Do you have any idea what is causing this issue? If you need more information please let me know. We are seriously considering to Cypress but this is a blocker for us.
  • s

    strong-kangaroo-46309

    06/30/2022, 8:25 AM
    This is the second screenshot
  • f

    fresh-doctor-14925

    06/30/2022, 8:50 AM
    Is it a cross origin iframe, by any chance? https://docs.cypress.io/guides/guides/web-security
1...616263...192Latest