Last active
June 10, 2021 15:01
Cypress Tips/Tricks - Typing Environment Variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Can import types from other files using TypeScript's typed imports functionality | |
type TestEnvironment = import('../utils/testEnv').TestEnvironment; | |
// Or you can define the types here as well in this type definition file | |
type ApiHost = "https://staging.api.com" | "https://testing.api.com" | string; | |
declare namespace Cypress { | |
interface Cypress { | |
// This types out our Cypress.env("key") calls better | |
env(key: 'apiHost'): ApiHost | undefined; | |
env(key: 'testEnv'): TestEnvironment | undefined; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment