fix .env loading

This commit is contained in:
Ulf Gebhardt 2023-06-02 13:44:43 +02:00
parent 810e1c085b
commit 3ad8588d6f
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
2 changed files with 8 additions and 3 deletions

View File

@ -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
});

View File

@ -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 }))
})
})
})