Seed tasks executed but database is not affected #21624
Answered
by
nemanjam
nemanjam
asked this question in
Questions and Help
-
I have seed singleton class that works when called from backend code or as yarn script but fails only when called as Cypress task. And to be more weird seed/teardown functions are called, console.logs are executed but Prisma calls fail silently without exceptions and // cypress/plugins/index.js
on('task', {
'db:seed': async () => {
await seedInstance.handledSeed(); // both functions work from backend and as yarn seed
return null;
},
'db:teardown': async () => {
await seedInstance.handledDeleteAllTables();
return null;
},
});
// call in cypress/e2e/post.test.ts
before(() => {
cy.task('db:seed'); // js invoked but sql not affected
cy.loginAsAdmin();
});
after(() => {
cy.task('db:teardown'); // same
}); Here is example log:
|
Beta Was this translation helpful? Give feedback.
Answered by
nemanjam
Jun 1, 2022
Replies: 1 comment
-
I see where is the mistake, I passed wrong It can be seen npb-db-dev in the log above:
I will close this discussion. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
nemanjam
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I see where is the mistake, I passed wrong
.env
file and connected to dev database instead of test database.It can be seen npb-db-dev in the log above:
I will close this discussion.