7.2 C
New York
Wednesday, October 16, 2024

automated testing – The best way to resolve “Error: TypeScript compilation failed.” situation in Gitlab CI?


I am making an attempt to study to create a pipeline in Gitlab. All my assessments fail due to the compilation situation. My code is included under together with the error message.

import loginPage from "../PageObjects/loginPage";

fixture('Login Checks')
.web page('https://www.saucedemo.com/');

take a look at('Consumer Login to the web site', async (t) => {
    await loginPage.loginWebsite('performance_glitch_user','secret_sauce');
}); 
import { Selector, t } from "testcafe";

class loginPage{
    userName: Selector;
    password: Selector;
    loginBtn: Selector;
    pageName: Selector;
    
    constructor(){
        this.userName = Selector('#user-name');
        this.password = Selector('#password');
        this.loginBtn = Selector('#login-button');
        this.pageName = Selector('.title');
    }

    async loginWebsite(username, password){
        await t
        .typeText(this.userName, username)
        .typeText(this.password, password)
        .click on(this.loginBtn)
        .anticipate(Selector(this.pageName).innerText).eql('Merchandise');
    }
}

export default new loginPage;

package deal.json

{
  "identify": "testcafeproj",
  "model": "1.0.0",
  "description": "Task",
  "foremost": "index.js",
  "scripts": {
    "take a look at": "testcafe chrome assessments/**/*",
    "test2": "testcafe edge assessments/**/*",
    "take a look at:chrome:headless": "testcafe chrome:headless assessments/**/*",
    "take a look at:chrome:studies": "testcafe chrome assessments/* --reporter html:studies/report.html",
    "take a look at:chrome:studies:ss": "testcafe chrome assessments/*.ts -s takeOnFails=true --reporter html:studies/report.html"
  },
  "writer": "take a look at",
  "license": "ISC",
  "devDependencies": {
    "faker": "^5.5.3",
    "faker-js": "^1.0.0",
    "testcafe": "^2.4.0",
    "typescript": "^4.9.5"
  },
  "dependencies": {
    "@faker-js/faker": "^7.6.0",
    "testcafe-reporter-html": "^1.4.6"
  }
}

.gitlab-ci.yml

levels:
  - take a look at

test_job:
  picture: cypress/browsers:node18.12.0-chrome107
  stage: take a look at
  script:
    - npm ci
    - npm run take a look at:chrome:headless

That is the error message in CI
GITLAB ERROR

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles