I am trying so send a video after each run in Cypress. I’m need to send the video of the spec run to google drive and get the weblink back. I’m using the googleapis package to send it. So, in the Before Hook inside the file e2e.js. When I put this line:
const { google } = require("googleapis");
And I’m getting the error:
1) An uncaught error was detected outside of a test:
TypeError: The following error originated from your test code, not from Cypress.
> Cannot destructure property 'HTTP2_HEADER_CONTENT_ENCODING' of 'http2.constants' as it is undefined.
When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
Cypress could not associate this error to any specific test.
We dynamically generated a new test to display this failure.
at Object.eval (webpack:///./node_modules/googleapis-common/build/src/http2.js:25:7)
at ./node_modules/googleapis-common/build/src/http2.js (http://localhost:61374/__cypress/tests?p=cypresssupporte2e.js:62097:30)
at __webpack_require__ (webpack:///webpack/bootstrap:19:0)
at Object.eval (webpack:///./node_modules/googleapis-common/build/src/apirequest.js:23:11)
at ./node_modules/googleapis-common/build/src/apirequest.js (http://localhost:61374/__cypress/tests?p=cypresssupporte2e.js:61490:30)
at __webpack_require__ (webpack:///webpack/bootstrap:19:0)
at ./node_modules/googleapis-common/build/src/index.js (webpack:///./node_modules/googleapis-common/build/src/index.js:32:19)
at __webpack_require__ (webpack:///webpack/bootstrap:19:0)
at ./node_modules/googleapis/build/src/apis/abusiveexperiencereport/index.js (webpack:///./node_modules/googleapis/build/src/apis/abusiveexperiencereport/index.js:17:28)
at __webpack_require__ (webpack:///webpack/bootstrap:19:0)
Does anyone have any solution or alternative so that I can send the video of the execution of each test to google drive
2
Answers
Assuming this is not a problem coming from googleapis setup, it could be related to running this code in a limited browser context (from e2e file). I would suggest trying it from cypress.config.js file which executes from node context hence has access to files on the machine (like videos).
Here’s an official example how to manipulate video files, which you could tailor to your needs:
https://docs.cypress.io/api/plugins/after-spec-api#Delete-the-recorded-video-if-the-spec-passed
The Google APIs Node.js Client is designed to run in Nodejs, which means in Cypress you need to use it via a task.
For example: