From 3ad8588d6ff776677aae68f84aee5ba981cee64f Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 2 Jun 2023 13:44:43 +0200 Subject: [PATCH] fix .env loading --- cypress/cypress.config.js | 5 +++++ cypress/support/commands.js | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cypress/cypress.config.js b/cypress/cypress.config.js index c84903321..04a5decf8 100644 --- a/cypress/cypress.config.js +++ b/cypress/cypress.config.js @@ -1,3 +1,4 @@ +const dotenv = require('dotenv') const { defineConfig } = require("cypress"); const browserify = require("@badeball/cypress-cucumber-preprocessor/browserify"); const { addCucumberPreprocessorPlugin } = require("@badeball/cypress-cucumber-preprocessor"); @@ -30,6 +31,9 @@ async function setupNodeEvents(on, config) { return config; } +// Import backend .env (smart)? +const { parsed } = dotenv.config({ path: '../backend/.env' }) + module.exports = defineConfig({ e2e: { projectId: "qa7fe2", @@ -44,4 +48,5 @@ module.exports = defineConfig({ video: false, setupNodeEvents, }, + env: parsed }); \ No newline at end of file diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 7d3738a3d..67d9aadd8 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -15,7 +15,7 @@ /* globals Cypress cy */ import "cypress-file-upload"; import { GraphQLClient, request } from 'graphql-request' -import config from '../../backend/src/config' +import CONFIG from '../../backend/src/config' const authenticatedHeaders = (variables) => { const mutation = ` @@ -24,7 +24,7 @@ const authenticatedHeaders = (variables) => { } ` return new Cypress.Promise((resolve, reject) => { - request(config.GRAPHQL_URI, mutation, variables).then((response) => { + request(CONFIG.GRAPHQL_URI, mutation, variables).then((response) => { resolve({ authorization: `Bearer ${response.login}` }) }) }) @@ -40,7 +40,7 @@ Cypress.Commands.add( ({email, password}) => { return new Cypress.Promise((resolve, reject) => { authenticatedHeaders({ email, password }).then((headers) => { - resolve(new GraphQLClient(config.GRAPHQL_URI, { headers })) + resolve(new GraphQLClient(CONFIG.GRAPHQL_URI, { headers })) }) }) })