Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set baseUrl and another env via dotenv #1333

Closed
MadnezGirl opened this issue Dec 18, 2024 · 0 comments
Closed

Set baseUrl and another env via dotenv #1333

MadnezGirl opened this issue Dec 18, 2024 · 0 comments

Comments

@MadnezGirl
Copy link

MadnezGirl commented Dec 18, 2024

I want to set baseUrl with CYPRESS_BASE_URL via .env file in root folder that near cypress.config.ts.
It will be more comfortable instead setting it in cmd every time.
But it doesn't work. Why I cant do it?
I saw similar issue but it closed #174
Also I want overwrite "visit" command and use CYPRESS_PROXY_TOKEN env from .env file. BUT it also doesn't work. All environment variables are only available within the tests themselves.

My config:

const envLocal = dotenv.config({ path: path.resolve(process.cwd(), '.env') });

export default defineConfig({
......
env: {
...envLocal.parsed,
},
.....
});

My .env file:

CYPRESS_PR_AUTH_PROXY_TOKEN=1234556668897866
CYPRESS_BASE_URL=https://testsite.ru

My command "visit":

Cypress.Commands.overwrite('visit', (origFunc, url, options) => {
const qs = { token: Cypress.env('PR_AUTH_PROXY_TOKEN') };

document.cookie = `token=${Cypress.env('PR_AUTH_PROXY_API_TOKEN')};`;

return origFunc(url, { ...options, qs });

});

@MadnezGirl MadnezGirl changed the title Set baseUrl and another env via env file Set baseUrl and another env via dotenv Dec 18, 2024
@MadnezGirl MadnezGirl closed this as not planned Won't fix, can't repro, duplicate, stale Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant