An error is raised when launching the tests using a custom reporter (e.g., mochawesome) that is only installed locally.
This is the cypress run output:
Could not load reporter by name: mochawesome
We searched for the reporter in these paths:
- /e2e/mochawesome
- /e2e/node_modules/mochawesome
The error we received was:
SyntaxError: /e2e/mochawesome.json: Unexpected end of JSON input
at JSON.parse (<anonymous>:null:null)
at Object.Module._extensions..json (module.js:661:27)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:504:12)
at Function.Module._load (module.js:496:3)
at Module.require (module.js:586:17)
at require (internal/module.js:11:18)
at Function.Reporter.loadReporter (/root/.cache/Cypress/3.4.1/Cypress/resources/app/packages/server/lib/reporter.js:378:16)
at Project.watchSettingsAndStartWebsockets (/root/.cache/Cypress/3.4.1/Cypress/resources/app/packages/server/lib/project.js:266:20)
at /root/.cache/Cypress/3.4.1/Cypress/resources/app/packages/server/lib/project.js:146:39
at tryCatcher (/root/.cache/Cypress/3.4.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/root/.cache/Cypress/3.4.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:507:35)
at Promise._settlePromise (/root/.cache/Cypress/3.4.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:567:18)
at Promise._settlePromise0 (/root/.cache/Cypress/3.4.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:612:10)
at Promise._settlePromises (/root/.cache/Cypress/3.4.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:691:18)
at Promise._fulfill (/root/.cache/Cypress/3.4.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:636:18)
at PromiseArray._resolve (/root/.cache/Cypress/3.4.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise_array.js:125:19)
at PromiseArray._promiseFulfilled (/root/.cache/Cypress/3.4.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise_array.js:143:14)
at PromiseArray._iterate (/root/.cache/Cypress/3.4.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise_array.js:113:31)
at PromiseArray.init [as _init] (/root/.cache/Cypress/3.4.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise_array.js:77:10)
at Promise._settlePromise (/root/.cache/Cypress/3.4.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:564:21)
at Promise._settlePromise0 (/root/.cache/Cypress/3.4.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:612:10)
at Promise._settlePromises (/root/.cache/Cypress/3.4.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/promise.js:691:18)
at Async._drainQueue (/root/.cache/Cypress/3.4.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/root/.cache/Cypress/3.4.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/root/.cache/Cypress/3.4.1/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:789:20)
at tryOnImmediate (timers.js:751:5)
at processImmediate [as _immediateCallback] (timers.js:722:5)
I would like Cypress to search the required module also in the globally-installed packages. This would make it possible to extend the Cypress docker image (where Cypress is installed globally) with custom reporters and use them.
create a new docker image like this
FROM cypress/included:3.4.1
RUN npm install -g [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]
then launch the tests with docker run using a cypress.json based on
{
...
"reporter": "mochawesome",
"reporterOptions": {
"reportDir": "cypress/results",
"overwrite": false,
"html": true,
"json": true
}
}
Following the stacktrace I guess the problem is here:
https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/reporter.coffee#L310
but I'm not sure if not trying a direct require of the custom module is a design choice or not
Cypress 3.4.1
I am facing exactly the same issue.
I get the same issue. Can't use mochawesome for now. Using the workaround i found for this is annoying.
Same! Anyone know a workaround for this for now?
I have even more weird issue but I expect it to be connected with this one.
I have cypress installed globally. Then I want to use mocha dot or nyan reporter.
So I set a reporter in the config.
And then I have mixed output from default spec reporter with the reporter I have set-up.
For some reason spec still outputs and my specified reporter adds dots or cats in between.
Running into the same issue. Running Cypress in a docker container with the custom reporter and its dependencies installed on the image itself.
similarly, this is an issue if you run Cypress in a monorepo and the dependency is hoisted to a parent directory
This is due to Cypress not using node module resolution for in the following code, and instead just looking for the module in 2 locations:
Most helpful comment
I am facing exactly the same issue.