DEV Community

Cover image for How to poll a Gmail inbox using cypress.io
Lev
Lev

Posted on

1 2

How to poll a Gmail inbox using cypress.io

Hey! Read about my experience writing custom tasks for the cypress framework.
Read the article on Medium: https://medium.com/@levz0r/how-to-poll-a-gmail-inbox-in-cypress-io-a4286cfdb888

Top comments (5)

Collapse
 
marcostreng profile image
Marco Streng • Edited

Great work! Thank you so much!

Do you already have an idea how to integrate it into a build pipeline?
My first thought was to store the keys and tokens as secret environment variables and build the configuration objects inside the script. But as i see, i always need to provide a path to the json files and can't call gmail.get_messages() directly with the config objects.

EDIT: I've created a small script, which writes the .json files from the environment variables during the test step in the build pipeline.

Collapse
 
levz0r profile image
Lev

Hi Marco,

We have a pre-build step which copies the files from an external source into our build environment.

You have to init gmail-tester on your machine, upload the credentials files to the build machine, then define the pre-build step.

Another solution is to have templates of the credentials files and to inject the tokens from env. variables. This solution requires some coding/scripting.

Collapse
 
marcostreng profile image
Marco Streng

Thanks for your quick response Lev!

I think my solution corresponds to your second suggestion and works well so far. Thank you!

Collapse
 
shayaman profile image
shaYaman

How do i extend the interval of the token? as far as i understood the token will not refresh if older then 24h, so injecting the old token from .env doesnt solve our problem, correct?

Collapse
 
levz0r profile image
Lev

Update: The story was featured on docs.cypress.io/examples/media/blo...

Thanks all!

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay