I've a Testing framework with node, cypress, mocha, mochawesome and mochawesome-merge as below with this github repo :
and in my package.json I have two scripts as
`"scripts": {
"cy": "./node_modules/.bin/cypress open",
"cy_test": "node cypress.js"
},`
If I run npm run cy_test
it works fine in headless state, but if I run npm run cy
i get following error:
But If I remove cypress.js from my project then it works as expected.
cypress.js
const cypress = require('cypress')
const marge = require('mochawesome-report-generator')
const { merge } = require('mochawesome-merge')
const currRunTimestamp = getTimeStamp();
const mergedReport = {
reportDir: 'mochawesome-report',
}
const finalReport = {
reportDir: 'reports',
}
cypress.run({
reporter: 'mochawesome',
reporterOptions: {
reportDir: 'mochawesome-report',
overwrite: false,
html: true,
json: true
}
}).then(
() => {
generateReport()
},
error => {
generateReport()
console.error(error)
process.exit(1)
}
)
function generateReport(options) {
return merge(mergedReport).then(report => marge.create(report, finalReport))
}
I think this is a problem with npm
on Windows that is messing with file names, because npm
is trying to run the script as binary instead of getting it from ./node_modules/.bin
.
So, I'll suggest, as first try, if you can, change the name of the cypress.js
to something other than cypress
. I think this can solve your problem.
If not, as a workaround remove .JS
from PATHEXT
environment variable and restart the processes that are running the script, including your IDE, if applicable.
Hope it works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.