Zaista / cypress-mongodb

Cypress MongoDB plugin
MIT License
17 stars 8 forks source link

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

Closed nivedhamanoharan closed 1 year ago

nivedhamanoharan commented 1 year ago

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 commented 1 year ago

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
});
nivedhamanoharan commented 1 year ago

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 commented 1 year ago

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

Zaista commented 1 year ago

It might be related to this problem: https://github.com/Zaista/cypress-mongodb/issues/35 Just a long shot though, I'll take some time this week to investigate this issues

Zaista commented 1 year ago

@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