mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
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:
parent
29e01fcd21
commit
447b19eea0
@ -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 => {
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user