https://cypress.io logo
Join DiscordCommunities
Powered by
# general-chat
  • c

    cool-application-67821

    06/21/2021, 9:01 PM
    if we use webpack for component testing then it shouldnt be an issue because the smae webpack used by react is working fine? It fails only when I try to import a file which inturn imports an image file to run e2e testing
  • b

    bulky-sundown-74498

    06/21/2021, 10:56 PM
    Why don't you use the webpack file-preprocessor?
  • b

    bulky-sundown-74498

    06/21/2021, 10:56 PM
    https://www.npmjs.com/package/@cypress/webpack-preprocessor
  • b

    bulky-sundown-74498

    06/21/2021, 10:57 PM
    this way you are guaranteed to have loaders and tools that work in a modern toolchain
  • c

    cool-application-67821

    06/22/2021, 1:50 AM
    wow thanks so much, why didn i bump into this earlier. i wonder if cypress/browserify is mentioned somewhere in documetns
  • c

    cool-application-67821

    06/22/2021, 3:12 AM
    Using webpack preprocessor indeed did solve the issue, although the source maps are off now, although the devtools value is set in the webpack options it just doesnt seem to consider the cypress test files, I wonder if i should be specifying some entry for the webpack options
  • c

    cool-application-67821

    06/22/2021, 3:31 AM
    nvm got it to work
  • u

    user

    06/22/2021, 5:58 PM
    does anyone of Cypress know if the socketio is wss or ws? Or does it depends on the base url of the test cases?
  • w

    wide-london-24133

    06/23/2021, 7:58 AM
    Hi folks, I come across from https://www.reddit.com/r/QualityAssurance/comments/o5dnup/is_there_any_http_endpoints_test_project_that/? , and tried to kick off the first endpoint case as:
  • w

    wide-london-24133

    06/23/2021, 7:59 AM
    Copy code
    js
    cy.request('POST', 'http://int.oa.com:8080', { bookId: '383' }).then(
      (response) => {
        // response.body is automatically serialized into JSON
        expect(response.body).to.have.property('bookId', '383') // true
      }
    )
  • w

    wide-london-24133

    06/23/2021, 8:01 AM
    But I got an error when tried to run it in browser as
  • g

    gray-kilobyte-89541

    06/23/2021, 7:44 PM
    everything you do that calls
    cy...
    commands should be in a test. So put your
    cy.request
    inside an
    it('loads', () => ....)
    test
  • w

    wide-london-24133

    06/24/2021, 1:45 AM
    It works! You make my day, awesome thanks @User
  • g

    gray-kilobyte-89541

    06/24/2021, 1:08 PM
    That's what I do...
  • q

    quaint-autumn-18886

    06/24/2021, 1:25 PM
    Hi, I'm Sefi, A new cypress user, my goal is to define cypress tests to run on each pull request from the development team workflow, we use Bitbucket for the application repositories & Bitbucket for the cypress automation repository as well, we're working with the cypress dashboard. the cypress repository running the tests on a cypress predefined docker image & for each bitbucket pull request from the cypress repository the image up & runs the tests, now i need to define step in the bitbucket.yml for the applications repositories, how can i define cypress run tests from the cypress automation repository to run while the application bitbucket pull request happned?
  • f

    future-journalist-95278

    06/26/2021, 8:16 AM
    Is there a Cypress only way to mocking
    next/router
    like what is discussed here - https://github.com/vercel/next.js/issues/7479
  • f

    future-journalist-95278

    06/26/2021, 8:21 AM
    Or do I need to integrate jest to handle mocking within my component tests
  • u

    user

    06/28/2021, 10:34 AM
    How can i acess Cloudflare DDos protected sites in Cypress
  • b

    bulky-sundown-74498

    06/28/2021, 2:31 PM
    @User this is a great question. If you are using e2e testing, you should mock the routes directly using
    cy.intercept()
    . If you are using CT, then one can stub or spy on any module in mocha. Check out this example. https://github.com/elevatebart/cy-nextjs/blob/main/components/DisplayRoute/DisplayRoute.spec.jsx
  • b

    bulky-sundown-74498

    06/28/2021, 2:34 PM
    The only issue you will face here is that one can only mock a es5 module, not a es6 version. To fix this, you will have to babelify your code in testing.
  • f

    future-journalist-95278

    06/28/2021, 5:08 PM
    Applying this to my test was able to get it to render for a split second, then gives me the error
    Copy code
    Error: TypeError: router.prefetch is not a function
    . This is how I organized my test:
    Copy code
    js
    import { mount } from '@cypress/react'
    import * as nextRouter from 'next/router'
    import Navbar from '../../component/Navbar'
    
    const LINKS = [
      { text: 'Home', to: '/' },
      { text: 'About', to: '/about' },
      { text: 'Ninja Listing', to: '/ninjas' },
    ]
    
    describe('<Navbar />', () => {
      it.only('displays links', () => {
        cy.stub(nextRouter, 'useRouter').callsFake(() => ({ pathname: '/' }))
        mount(<Navbar links={LINKS} />)
      })
    })
  • b

    bulky-sundown-74498

    06/28/2021, 5:22 PM
    can you add
    prefetch()
    to the pathname ?
  • b

    bulky-sundown-74498

    06/28/2021, 5:23 PM
    cy.stub(nextRouter, 'useRouter').callsFake(() => ({ pathname: '/', prefetch: sinon.stub() }))
  • b

    bulky-sundown-74498

    06/28/2021, 5:24 PM
    the principle you want to follow is to fake all functions that will be using to have them be predictable
  • f

    few-musician-79351

    07/02/2021, 5:33 PM
    Hey guys, question about cypress. I'm testing a game I made and this line of code it doesn't work as I expected: arrMatchingCards = Object.values(cardsMap)
  • w

    wonderful-match-15836

    07/02/2021, 6:06 PM
    What I think is happening here is not cypress specific ...
    getMatchingCards
    returns an empty object right away, because
    matchingCards
    is initialized as empty and the work to populate it all happening asynchronously. So the
    Object.values(arrMatchingCards)
    is called when
    arrMatchingCards
    is still just
    {}
    - which would explain the empty array at that point. Meanwhile everything in the
    .then
    of your
    cards.each
    is happening asynchronously, and since the JS console is showing a live representation of the object, those property assignments appear in the console even though they actually happened to the object after line 41 ran. If this is right, something like
    console.log(JSON.stringify(cardsMap))
    instead of logging the raw object would verify, as it would log an empty object. Same issue would apply where you console log
    matchingCards
    inside your function - it's logging a reference to the live object.
  • f

    few-musician-79351

    07/03/2021, 3:12 PM
    Thank u @User . This's what i did
  • f

    few-musician-79351

    07/05/2021, 7:26 PM
    Does anyone know why this happens?
  • f

    faint-bear-92677

    07/05/2021, 8:49 PM
    I've run into this error and a couple just like this. I found this article to be helpful in understanding what's happening: https://www.cypress.io/blog/2021/01/26/when-can-the-test-blink/
  • u

    user

    07/05/2021, 10:22 PM
    how do you assert without/skipping cy.get?
1...101112...127Latest