Use cy.exec() to talk to the database

- Cypress says "To talk to your database or server you need to use the
  cy.exec(), cy.task(), or cy.request() commands. That means you will
need to expose a way to seed and setup your database." https://docs.cypress.io/guides/references/trade-offs.html#Inside-the-browser
This commit is contained in:
mattwr18 2020-02-20 10:52:36 +01:00
parent 29e01fcd21
commit 447b19eea0
2 changed files with 11 additions and 17 deletions

View File

@ -238,16 +238,16 @@ Given("we have the following comments in our database:", table => {
});
Given("we have the following posts in our database:", table => {
table.hashes().forEach((attributesOrOptions, i) => {
cy.factory().build("post", {
...attributesOrOptions,
deleted: Boolean(attributesOrOptions.deleted),
disabled: Boolean(attributesOrOptions.disabled),
pinned: Boolean(attributesOrOptions.pinned),
}, {
...attributesOrOptions,
});
})
table.hashes().forEach((attributesOrOptions, i) => {
cy.factory().build("post", {
...attributesOrOptions,
deleted: Boolean(attributesOrOptions.deleted),
disabled: Boolean(attributesOrOptions.disabled),
pinned: Boolean(attributesOrOptions.pinned),
}, {
...attributesOrOptions,
});
})
})
Then("I see a success message:", message => {

View File

@ -9,13 +9,7 @@ const neo4jConfigs = {
}
const neodeInstance = getNeode(neo4jConfigs)
export const cleanDatabase = () => {
return new Cypress.Promise((resolve, _reject) => {
return neodeInstance.cypher(' MATCH (everything) DETACH DELETE everything;')
.then(() => resolve())
})
}
beforeEach(() => cleanDatabase())
beforeEach(() => cy.exec('yarn run db:reset'))
Cypress.Commands.add('neode', () => {
return neodeInstance