问题
I need to execute some code after all tests run. I add this test on after hook. But this task needs the report to be created, but on after hook, the report is not created yet.
I also tried to use
 on('run:end', () => {
        console.log("gdfgfdsafkañjsdfjñaldfkjsñkasfdñlassfjdskafmjassd");
  });
but it does nothing.
回答1:
You can't, there is an open issue for that.
At the moment you can only leverage a package.json post hook. So, if you have a dedicated command in your package.json file
"scripts": {
  "cy:run": "cypress run"
}
you can add a postcy:run script
"scripts": {
  "cy:run": "cypress run",
  "postcy:run": "<YOUR_COMMAND>"
}
I hope it helps you 😊
回答2:
Be aware that the post hook might not run when the tests fail. I'm currently using a global after hook in support/index.ts for running after all tests 
I'm currently using a global after hook in support/index.ts 
after(() => {
  // something here
});
来源:https://stackoverflow.com/questions/56006940/executing-a-task-after-all-test-are-launch-cypress