Question
(Cypress) "list" argument must be an Array of Buffers
I'm trying to use the speakeasy library to authenticate with a Cypress Automation. This is the auth code generator code:
const token = speakeasy.totp({
secret: '(my secret key)',
encoding: 'base32'
});
getAuthCode = () => {
return token;
}
module.exports = { getAuthCode };
This script works just fine, and lets me log in in the website I want to use, but when I import it with Cypress I receive the "list" argument must be an Array of Buffers
error. I read a little bit about it and it seems that it's because of an issue with the code generator, but it works perfectly. By the way, here is the Cypress code, it's a simple code to test some functionalities so I still didn't do almost anything yet:
const { getAuthCode } = require('../support/authcodegen')
describe('Test', () => {
const emailInput = '[id = "email"]'
const passInput = '[id = "password"]'
const loginBtn = '[type = "submit"]'
it('Login Test', () => {
cy.on('uncaught:exception', (err, runnable) => {return false})
cy.visit('My Website');
cy.get(emailInput).type('My email');
cy.get(passInput).type('My Password');
cy.get(loginBtn).click();
const authCode = getAuthCode();
cy.log(authCode);
})
})
Do you find any defect in the code? I already tried to refactor the code a couple of times but the problems seems to be from Javascript, my other option would be to execute the console and get the result but that wouldn't be very professional...
The error traceback itself:
at Function.concat (webpack://automation/../../Library/Caches/Cypress/13.13.0/Cypress.app/Contents/Resources/app/node_modules/buffer/index.js:423)
at new Hmac (webpack://automation/../../Library/Caches/Cypress/13.13.0/Cypress.app/Contents/Resources/app/node_modules/create-hmac/browser.js:27)
at Object.createHmac (webpack://automation/../../Library/Caches/Cypress/13.13.0/Cypress.app/Contents/Resources/app/node_modules/create-hmac/browser.js:61)
at Object.digest (webpack://automation/./node_modules/speakeasy/index.js:56)
at Object.hotpGenerate (webpack://automation/./node_modules/speakeasy/index.js:95)
at Object.totpGenerate (webpack://automation/./node_modules/speakeasy/index.js:293)
at ./cypress/support/authcodegen.js (webpack://automation/./cypress/support/authcodegen.js:3:24)
at __webpack_require__ (webpack://automation/webpack/bootstrap:19)
at eval (webpack://automation/./cypress/e2e/cocoshome.cy.js:1:24)
at eval (http://localhost:49752/__cypress/tests?p=cypress/e2e/cocoshome.cy.js:39694:3)
From previous event:
at Promise.longStackTracesCaptureStackTrace [as _captureStackTrace] (http://localhost:49752/__cypress/runner/cypress_runner.js:3486:19)
at Promise._then (http://localhost:49752/__cypress/runner/cypress_runner.js:1239:17)
at Promise.then (http://localhost:49752/__cypress/runner/cypress_runner.js:1132:17)
at runScriptsFromUrls (http://localhost:49752/__cypress/runner/cypress_runner.js:111340:136)
at Object.runScripts (http://localhost:49752/__cypress/runner/cypress_runner.js:111381:12)
at $Cypress.onSpecWindow (http://localhost:49752/__cypress/runner/cypress_runner.js:40896:67)