I have this hook in my cypress.config.ts
:
...
on('after:run', async () => {
console.log('override after:run')
await exec('touch ./cypress/reports/test.txt')
await exec(
'npx jrm ./cypress/reports/junitreport.xml ./cypress/reports/junit/*.xml'
)
await afterRunHook()
})
...
The touch
command works fine, but the jre
don’t produce the junitreport.xml
file or any other output.
If I run npx jrm ./cypress/reports/junitreport.xml ./cypress/reports/junit/*.xml
on the command line it works just fine.
I have also tried with ./node_modules/.bin/jre
instead of npx jrm
as well as node ./node_modules/.bin/jre
but to no avail.
What am I missing here?
2
Answers
Using the
execSync()
instead ofexec()
works:If you use
execSync()
you can drop the async/await decoration.In the original code,
exec()
returns no promise, soawait
has no effect. It uses callbacks to respond.You could use util.promisify to make
exec()
work in the context ofafter:run
.