0

I use Cypress with my local web app. I followed install and run instructions:

https://github.com/gothinkster/react-mobx-realworld-example-app

Tests work fine until I wanted to reset database state according to the instructions:

https://docs.cypress.io/guides/references/best-practices.html#State-reset-should-go-before-each-test

I always get same error:

TypeError: cy.resetDb is not a function

Any reccomendations how to fix that?

1
  • Do you actually have a resetDb command?
    – jonrsharpe
    Commented Jul 8, 2019 at 11:21

1 Answer 1

2

You can use the beforeEach function to execute actions before every single test.

The Cypress documentation gives an example of how you can use beforeEach, but it expects you to implement the resetDb function. This is not a generic function supplied by Cypress.

Either remove the call to resetDb or implement it as a Cypress Custom Command.

2
  • Thank you for your answer. So, I assume there is no generic function to force use database in the same state at it used to be before star testing? Backend developer should prepare me one or there is any simpler solution for that?
    – Piecho3a
    Commented Jul 8, 2019 at 10:54
  • @Piecho3a well how would Cypress know how to reset the database? It doesn't even know what DBMS you're using.
    – jonrsharpe
    Commented Jul 8, 2019 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.