I'm using googleapis inside my Cypress project as a util to interact with some Gmail messages. I just installed the library and implemented the following code:
const oAuth2Client: Auth.OAuth2Client = new google.auth.OAuth2(
credentials.client_id,
credentials.client_secret,
credentials.redirect_uri
);
export class GmailAPIHandler {
constructor() {
oAuth2Client.setCredentials({
refresh_token: REFRESH_TOKEN,
scope: SCOPES,
});
}
getLastEmailSnippet() {
const gmail = google.gmail({ version: "v1", auth: oAuth2Client });
var response: GmailMainResponse;
gmail.users.messages.list(
{
userId: "me",
},
(getEmailListErr, getEmailListRes) => {
if (getEmailListErr)
return console.log("The API returned an error ", getEmailListErr);
response = <GmailMainResponse>(<unknown>getEmailListRes);
return response.resp[0].data.snippet;
}
);
}
}
When the project is compiling the util_1.promisify is not a function error is shown.
I'm using typescrypt, node version 14.15.1 and npm version 6.14.8.
This is the traceback:
The following error originated from your test code, not from Cypress.
> util_1.promisify is not a function
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.
node_modules/google-auth-library/build/src/auth/identitypoolclient.js:25:1
23 | // src/index.ts.
24 | // Fallback to void function to avoid promisify throwing a TypeError.
> 25 | const readFile = util_1.promisify((_a = fs.readFile) !== null && _a !== void 0 ? _a : (() => { }));
| ^
26 | const realpath = util_1.promisify((_b = fs.realpath) !== null && _b !== void 0 ? _b : (() => { }));
27 | const lstat = util_1.promisify((_c = fs.lstat) !== null && _c !== void 0 ? _c : (() => { }));
28 | /**
View stack trace
Print to console
at Object.1909../baseexternalclient (node_modules/google-auth-library/build/src/auth/identitypoolclient.js:25:1)
at o (node_modules/browser-pack/_prelude.js:1:1)
at eval (node_modules/browser-pack/_prelude.js:1:1)
at Object.1906../awsclient (node_modules/google-auth-library/build/src/auth/externalclient.js:18:1)
at o (node_modules/browser-pack/_prelude.js:1:1)
at eval (node_modules/browser-pack/_prelude.js:1:1)
at Object.eval (node_modules/google-auth-library/build/src/auth/googleauth.js:29:1)
at Object.eval (https://portal-test.redibs.com/__cypress/tests?p=cypress\integration\features\regression-test\onboarding\onboarding_successful_registration.feature:177228:5)
at Object.1907.../crypto/crypto (https://portal-test.redibs.com/__cypress/tests?p=cypress\integration\features\regression-test\onboarding\onboarding_successful_registration.feature:177228:18)
at o (node_modules/browser-pack/_prelude.js:1:1)
From previous event:
at runScriptsFromUrls (https://portal-test.redibs.com/__cypress/runner/cypress_runner.js:160060:98)
at Object.runScripts (https://portal-test.redibs.com/__cypress/runner/cypress_runner.js:160074:11)
at $Cypress.onSpecWindow (https://portal-test.redibs.com/__cypress/runner/cypress_runner.js:149502:19)