我的
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()
})
...
touch
命令工作正常,但jre
不会生成junitreport.xml
文件或任何其他输出。
如果我在命令行上运行
npx jrm ./cypress/reports/junitreport.xml ./cypress/reports/junit/*.xml
,它就可以正常工作。
我也尝试过用
./node_modules/.bin/jre
而不是 npx jrm
以及
node ./node_modules/.bin/jre
但无济于事。
我在这里缺少什么?
使用
execSync()
代替 exec()
有效:
on('after:run', async () => {
console.log('override after:run')
await execSync(
'node ./node_modules/.bin/jrm ./cypress/reports/junitreport.xml ./cypress/reports/junit/*.xml > ./cypress/reports/jrm-log.txt 2>&1'
)
await afterRunHook()
})