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

Need feasibility to connect to different database in a single test. #32

Closed
nivedhamanoharan opened this issue Apr 8, 2023 · 5 comments

Comments

@nivedhamanoharan
Copy link

As our application touches 2-3 databases while writing e2e tests, currently the feasibility does not exists for this plugin. Please enable a connect/disconnect method which will be useful in connecting and disconnecting the databases whenever required.

@Zaista
Copy link
Owner

Zaista commented Apr 10, 2023

I'm not sure when is this going to be properly supported, but there is a workaround for it already.
You can override env variables on the it level (also on context or describe levels):

it('Change env variables on the fly', {env: {mongodb: { uri: 'mongodb://localhost:12345', collection: 'xxx', database: 'xxx'}}}, () => {
  // your test on database localhost:12345
});

it('Default env', () => {
  // your test on database defined in cypress.config.js
});

@Zaista Zaista closed this as completed Apr 10, 2023
@nivedhamanoharan
Copy link
Author

Hi @Zaista , But I have the need to use 2 different databases in a single test.
Let me try if I can find a solution for it with the above given options.

@nivedhamanoharan
Copy link
Author

Hi @Zaista , I tried in both describe and it level, but the database is not getting connected.

@Zaista
Copy link
Owner

Zaista commented May 23, 2023

It might be related to this problem: #35
Just a long shot though, I'll take some time this week to investigate this issues

@Zaista
Copy link
Owner

Zaista commented May 27, 2023

@nivedhamanoharan any news from your side perhaps and was it related the the issue above?
I just tested it again with mongodb v6 and cypress v12.13.0, had no problems at all.

Regarding the different databases within the same it block, unfortunately impossible with current implementation, I'll see that I rework it in a future release

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

2 participants