I am currently utilizing Cypress.io alongside TypeScript for test automation and attempting to perform simple tasks. I want to import a class from one file to another without repeating the code.
p.s. Despite trying several solutions on Stack Overflow, none of them have been successful for me.
Files: File System
Code:
loginPage.ts
export class LogIn {
//Launch app: http://localhost:6400/
cy.visit('localhost:6400')
//Press on menu item.
cy.get('.navbar-burger').click()
//Press "Client" menu item near "Login As:".
cy.get('#navbarMenu a').contains("Client").click()
//TODO
}
and client_NewJob.ts
import { LogIn } from '../helpers/loginPage';
import * as ChaiString from 'chai-string';
chai.use(ChaiString);
const lg = new LogIn();
//beforeEach
describe('BeforeEachTestLogIn', () =>{
beforeEach(() =>{
lg.LogIn()
})
})
//Test
describe('New job page', function() {
it('newJobCreation', function() {
//TODO
})
})
When I try to execute the client_NewJob.ts script via Cypress, I encounter an error message:
./cypress/helpers/loginPage.ts | TS1005: ';' expected.
./cypress/helpers/loginPage.ts TS1003: Identifier expected.
./cypress/helpers/loginPage.ts TS1144: '{' or ';' expected
I keep receiving similar error messages... How can I resolve this issue with importing the class?