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.
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com> © 2022
- @bahmutov
- glebbahmutov.com
- blog
- videos
- presentations
- cypress.tips
- Cypress Tips & Tricks Newsletter
- my Cypress courses
License: MIT - do anything with the code, but don't blame me if it does not work.