bahmutov / cypress-as-a-example

Parsing objects injected using the as-a utility

Home Page:https://glebbahmutov.com/blog/inject-env/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cypress-as-a-example

Parsing objects injected using the as-a utility

To run: create a file .as-a.ini and place a JSON object with the user properties

; inject these environment variables
; using https://github.com/bahmutov/as-a utility
; Cypress automatically grabs the environment variables
; that start with CYPRESS_ prefix and parses them
[cypress-user]
; get this parsed object with Cypress.env('user')
CYPRESS_user={"username":"...", "password": "...", "age": number, "valid": boolean}

Cypress spec at cypress/e2e/spec.cy.js

📝 Read the blog post How To Inject Environment Variables Into Cypress Tests 📺 Watch the video Inject Entire Objects Into Cypress Tests Using as-a Utility.

Small print

Author: Gleb Bahmutov <gleb.bahmutov@gmail.com> © 2022

License: MIT - do anything with the code, but don't blame me if it does not work.

About

Parsing objects injected using the as-a utility

https://glebbahmutov.com/blog/inject-env/


Languages

Language:JavaScript 100.0%