Test Environment
The environment configuration for these tests comes from two different sources: environment variables and an encrypted secrets file.
Environment Variables
Most non-sensitive runtime configuration comes from environment variables. All of our environment variables have fallback defaults.
For example:
VIEWPORT_NAME=mobile yarn jest specs/<etc>
The list of supported environment variables are found in env-variables.ts. This file also adds static type checking and is the most up-to-date resource. The Environment Variables page may be out of date but will contain explanations of what the individual variables mean.
To use:
import { envVariables } from '@automattic/calypso-e2e';
// Later
if ( envVariables.VIEWPORT_NAME === 'mobile' ) {
// Do x ;
}
Secrets File
Decrypting the Secrets
Within @automattic/calypso-e2e/src/secrets is an encrypted file that holds various sensitive secrets, such as API keys and test account information. This must be decrypted prior to use.
Automatticians: please refer to the Field Guide page - PCYsg-vnR-p2 for more information.
Trialmatticians: please contact a team member in your Slack chat for the decryption key.
First set the environment variable E2E_SECRETS_KEY to the "Calypso E2E Config decode key" from the Automattic secret store.
export E2E_SECRETS_KEY='<Calypso E2E Config decode key from the secret store>'
Then run the following command to decrypt the secrets:
# If within test/e2e directory
yarn decrypt-secrets
# If at repo root
yarn workspace wp-e2e-tests decrypt-secrets
The decrypted file must NEVER be committed. There are .gitignore rules to protect against this, but be vigilant nonetheless!
Using the Secrets
The secrets are read and validated at runtime. They are accessed through the SecretsManager static class, which presents the secrets with static typings.
To use:
import { SecretsManager } from '@automattic/calypso-e2e';
// Later in the spec
const credentials = SecretsManager.secrets.testAccounts.<test_account_name>;