Closed nivedhamanoharan closed 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
});
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.
Hi @Zaista , I tried in both describe and it level, but the database is not getting connected.
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
@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
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.