Shopware 6: Cypress test - reset database failed

144 Views Asked by At

I try to cleanup my database with command cy.cleanUpPreviousState:

// mytest.cy.js
...
beforeEach(() => {
    cy.cleanUpPreviousState()
})
...

the request was response with error:

CypressError
cy.request() failed trying to load:

http://my-route.dev.localhost:8005/cleanup

The app runs in docker container, using shyim/shopware-docker

Questions

  • What is wrong with my request/route?
  • Which controller has to take this request?
1

There are 1 best solutions below

0
On

To find out what is wrong, have a log at the network tab request log.

Answering your second question: There is a special server spun up for this action. It is not a normal Shopware route.

See in the cypress.js - it is supposed to use psh.phar to clean-up when this URL is called.

const requestedUrl = request.url;
if (requestedUrl !== "/cleanup") {
    response.end();
    return;
}

return childProcess.exec(
    `${PROJECT_ROOT}/psh.phar e2e:cleanup`,

[...]

server.listen(8005);

So things to check are:

  1. Is that port forwarded to your docker container?
  2. Are you using the development template and is psh.phar existing?