37e1a3750e40f2937df616d4421495a7

4 posts by rogelio-alatorre

How to use object destructuring with the index over an array?

const names = ['Roy', 'Liz', 'Sofia', 'Clau']

const {
  0: zero,
  1: one,
  2: two,
  3: three,
} = names

console.log(zero) // 'Roy'

How to rebase all reachable commits including the first commit?

git rebase -i --root

How to run a single test from a file using Cypress

I can run all tests from a file with:

yarn run cypress:run -s path/to/file.spec.js

but what about when I want to run only one test case from that file and not all of them?

We could use only()

// path/to/file.spec.js

it.only('just run this test', () => { ... })

it('not run this test', () => { ... })

// we could also use describe.only() but IDK if that is a bug or a feature xD

Run again yarn run cypress:run -s path/to/file.spec.js to see how the it.only() test will run it

How to use my local browser and get access to the server on Circle CI with port-forwarding

This helped me to debug a failing test, that was only happening on the CircleCI Server.

How to do it?

  1. Go to Details Job Page on the Circle CI app and re-run the job as Rerun Job with SSH. image

  2. You should be able to find an additional step called Enable SSH, just expand it to see a command similar to this ssh -p 64625 ubuntu@54.221.135.43 but with minor differences (the port number and IP address will be different). Copy the command into your terminal.

  3. Paste it and append this -L 3000:localhost:4000. With this, every request happening on the port 4000 (CircleCI server) will be forwarded to my local computer in the port 3000, so my local browser can reach the CircleCI server directly.

    $ ssh -p 64625 ubuntu@54.221.135.43 -L 3000:localhost:4000

  4. Lastly, change of directory, go to your application folder and serve your app in port 4000.

    $ cd my-app-directory && <command to serve your app>

    In this example, I ran yarn run dev which runs a server on the port 4000.

  5. Go to the browser and visit the localhost:3000.