Cypress can't import custom command
commands.js
Cypress.Commands.add('generateToken', ({secret}) => {
const totp = require('totp-generator');
const token = totp(secret);
});
support/index.js
import './commands'
test.spec.ts
/// <reference types="Cypress" />
context('Actions', () => {
beforeEach(() => {})
})
it('Main test', () => {
cy.generateToken('XXXX');
})
All the time generateToken() is underlined in test.spec.ts and error appears:
Property 'generateToken' does not exist on type 'cy'.
index.js and commands.js were not moved from original directories. cypress.json file is empty.