How to start Aurelia site before Cypress testing?


I need to know How to run “start” command in Aurelia project in the background and run cypress for e2e testing.


I tried these commands but does not work.

npm run start && ./node_modules/.bin/cypress run

npm run start & ./node_modules/.bin/cypress run

npm-run-all --serial \"start\" \"test:e2e\"

"concurrently \"start\" \"test:e2e\""

It seems that the start command is not allowed to run cypress command.

I want to run the site before e2e testing in automatic mode (not manually in separated consoles).


We had this issue with one of our projects. We ended up using gulp to orchestrate the running of the app as well as running the Cypress tests. That way, we are able to tear down the app after the Cypress tests.

Let me see if I’m able to post some snippets for you.


I think all of Aurelia CLI scenarios work on Gulp !!! Please share an example or snippet code.



Here you go. I do hope you find it useful!


Thanks @rowellx68

We added your snippet code as au command in this repository.

The command to use is au cy.
The project is based on the great @huochunpeng plugin system in here.
But we have a problem, seems the site does not start well on port 8080.

May I ask you to check this repository?


Here’s the image :


Shouldn’t this be ${PORT}?



You right It should be. I fixed it but It is not the solution :frowning:


I have found the difference as to why it worked with our project.

server = spawn(process.argv[0], ["server.js"], {
    detached: true,
    stdio: "ignore"

The snippet above is what we have within the startServer method. It turns out process.argv[0] is node and in turn that runs server.js serving our compiled application.

I tried replacing the params to "npm.cmd", ["start"]...and that seems to have done it, but it wasn’t able to teardown the server after the test has run.



You rock!

but it wasn’t able to teardown the server after the test has run.

It is too bad for CI/CD scenarios, Is it possible to find process id and kill it?

I find a solution, however, It is not good but better than nothing!

function killServer(done) {

  // Kill all node.exe processes
  const killall = exec('taskkill /f /im node.exe', (error, stdout, stderr) => {
    console.log(`stdout: ${stdout}`);
    console.log(`stderr: ${stderr}`);
    if (error !== null) {
      console.log(`exec error: ${error}`);

Another question: Is it possible to disable opening browser (headless)?


There were multiple ways which the project could be ran, one uses PORT and the other on 8080, I was checking with both and to o avail. anyway, thanks for mentioning :pray:


spawn should include a bunch of properties. You might be able get the process id there, the issue however is that using npm.cmd spawns other processes… those you won’t be able to get the process id.

I will have a look at our server.js file when I get time and get back to you.

As for running Cypress headless, you can look inside gulp-cypress.ts and replace the browser with electron. Currently, that’s the only way to run a headless browser.