https://cypress.io logo
Join Discord
Powered by
# help
  • u

    user

    05/25/2021, 7:49 PM
    yeah, that's what I thought 🙂
  • u

    user

    05/25/2021, 7:49 PM
    ty anyway 🙂
  • s

    stocky-dream-36427

    05/25/2021, 7:50 PM
    Ah
  • s

    stocky-dream-36427

    05/25/2021, 7:50 PM
    This is what you want https://github.com/bahmutov/cypress-movie
  • s

    stocky-dream-36427

    05/25/2021, 7:50 PM
    I wasn't sure if this did it.
  • u

    user

    05/25/2021, 7:52 PM
    yeah, that's the idea 🙂 I maybe need to try it to check if it works better
  • u

    user

    05/25/2021, 7:52 PM
    thanks
  • u

    user

    05/25/2021, 8:10 PM
    @User it makes a lot more than mine but it doesn't seems to work earlier
  • u

    user

    05/25/2021, 8:11 PM
    but I found a better place to import it (even if it isn't that much earlier: just import it once into support
  • u

    user

    05/25/2021, 8:12 PM
    instead of into each integration script
  • u

    user

    05/25/2021, 8:13 PM
    but since
    cypress-movie
    exists, is still any interest to make a new plugin that makes only that?
  • s

    stocky-dream-36427

    05/25/2021, 8:49 PM
    Not particularly. I would just try to submit a PR to fix the actual issues.
  • u

    user

    05/25/2021, 8:49 PM
    great, ty 🙂
  • f

    flat-electrician-52949

    05/26/2021, 7:14 AM
    I have been trying like a mad man to figure out how to do this with my NextJS project. Want to inject my environment variables into
    process.env
    like @User recipe (https://github.com/cypress-io/cypress/issues/1358#issuecomment-832215458)
    Copy code
    import injectDevServer from '@cypress/react/plugins/next'
    
    module.exports = (on, config) => {
      injectDevServer(on, config)
    
      const configWithDotenv = require('dotenv').config({ path: '.env.test' })
      if (configWithDotenv.error) {
        throw configWithDotenv.error
      }
      const env = { ...config.env, ...configWithDotenv.parsed }
      process.env = env
    
      return { ...config, env }
    }
    This only gives me access to
    Cypress.env('SOME_ENV_VAR')
    but not
    process.env.SOME_ENV_VAR
    ???
  • q

    quick-evening-73979

    05/26/2021, 8:46 AM
    Hello, does anyone knows how to resolve issue of company security policies conflicting with cypres user_data for browser? Cant run any tests, as everything becomes unreachable if apply user data to browser session:
    --user-data-dir=C:\\Users\\user\\AppData\\Roaming\\Cypress\\cy\\production\\browsers\\chrome-stable\\interactive
    The browser is managed by organization, so I blame extension of some security policy conflict. Is there a way to find what exactly breaks user-data? Does anyone experienced such issue or have an idea how to investigate. Cypress: 7.4.0 Chrome 90, Edge 90 doesnt work Electron 89 doesnt work as well, thou it might be a different issue, not sure.
  • u

    user

    05/26/2021, 9:35 AM
    @User \o/ just finished my first scripted video 😛 thanks again 🙂
  • u

    user

    05/26/2021, 10:38 AM
    (finally, I don't use the browser console, since it doesn't show the etched flag on the objects, like the node.js console makes, then I wrote my own logger)
  • u

    user

    05/26/2021, 10:41 AM
    your tool is really a fun way to do some technical videos 😛
  • u

    user

    05/26/2021, 11:56 AM
    Final version
  • u

    user

    05/26/2021, 2:52 PM
    hello there 👋 I asked this question https://twitter.com/giuseppegurgone/status/1395726561928781826 on Twitter and @User asked me to join the discord community.
  • s

    stocky-dream-36427

    05/26/2021, 7:47 PM
    Ahhh did you post on le Twitter?
  • s

    stocky-dream-36427

    05/26/2021, 7:50 PM
    ❤️ https://twitter.com/_jessicasachs/status/1397641212279115787?s=20
  • s

    stocky-dream-36427

    05/26/2021, 7:50 PM
    https://www.cypress.io/blog/2020/07/22/do-not-get-too-detached/ > Here you go. It's not ideal and we're patching it in the future (actively experimenting), but retrying the
    get
    is kinda tricky to fix because of how we enqueue the cy.* commands.
  • u

    user

    05/26/2021, 8:07 PM
    just done 🙂
  • g

    gray-kilobyte-89541

    05/27/2021, 1:34 AM
    Take a look at https://slides.com/bahmutov/testing-mistakes and https://slides.com/bahmutov/cypress-beyond-the-hello-world - spec runs in the browser, plugin file runs in Node, so if you want to pass something from the plugin to the spec you use config.env which later you access via
    Cypress.env()
    in the spec file
  • f

    flat-electrician-52949

    05/27/2021, 6:42 AM
    @User thank you for the links. I do understand that I was doing some "bad practice" with env and cypress (and NextJS because I was trying to use
    NODE_ENV
    ). After spending a day of troubleshooting and finally tracking the flow I think I got to a decent solution with your
    start-server-and-test
    package.
  • f

    flat-electrician-52949

    05/27/2021, 6:43 AM
    Think I got it now
  • f

    flat-electrician-52949

    05/27/2021, 6:48 AM
    Only missing a way to start stripe cli to listen to events and forward the web-hooks to port 3000 - currently I doing this in another terminal tab by
    stripe listen --forward-to localhost:3000/api/webhook
  • f

    flat-electrician-52949

    05/27/2021, 6:50 AM
    this does much of the simplifications (only have to pass an env when starting up)
    Copy code
    ts
    export default function env(key: TEnvKey): string {
      try {
        // have to try catch because of Cypress reference error
        return Cypress.env(key)
      } catch {
        switch (key) {
          case 'STRIPE_SECRET_KEY':
            return process.env.STRIPE_SECRET_KEY
          case 'NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY':
            return process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
          case 'NEXT_PUBLIC_STRIPE_RESTAURANT_TAX_ID':
            return process.env.NEXT_PUBLIC_STRIPE_RESTAURANT_TAX_ID
    
          case 'NEXT_PUBLIC_FIREBASE_API_KEY':
            return process.env.NEXT_PUBLIC_FIREBASE_API_KEY
          case 'NEXT_PUBLIC_FIREBASE_PROJECT_ID':
            return process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID
          case 'NEXT_PUBLIC_FIREBASE_ROOT_REF':
            return process.env.DB_MODE || process.env.NEXT_PUBLIC_FIREBASE_ROOT_REF
    
          default:
            return undefined
        }
      }
    }
  • f

    flat-electrician-52949

    05/27/2021, 6:51 AM
    that is simplified by the package.json script
    Copy code
    json
      "scripts": {
        "dev": "next dev",
        "dev:test": "DB_MODE=test next dev",
        "build": "next build",
        "start": "next start",
        "cy:open-ct": "cypress open-ct",
        "cy:open": "cypress open",
        "test:e2e": "start-server-and-test dev:test http://localhost:3000 cy:open",
        "cy:open:dev": "cypress open --env DB_MODE=development",
        "test:e2e:dev": "start-server-and-test dev http://localhost:3000 cy:open:dev",
        "types": "node envTypeWriter.mjs"
      },
    ...
1...171819...252Latest