Wednesday, March 12, 2025

automated testing – Learn how to resolve “Error: TypeScript compilation failed.” concern in Gitlab CI?


I am attempting to study to create a pipeline in Gitlab. All my assessments fail due to the compilation concern. My code is included beneath together with the error message.

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

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

check('Person 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)
        .count on(Selector(this.pageName).innerText).eql('Merchandise');
    }
}

export default new loginPage;

bundle.json

{
  "identify": "testcafeproj",
  "model": "1.0.0",
  "description": "Task",
  "important": "index.js",
  "scripts": {
    "check": "testcafe chrome assessments/**/*",
    "test2": "testcafe edge assessments/**/*",
    "check:chrome:headless": "testcafe chrome:headless assessments/**/*",
    "check:chrome:reviews": "testcafe chrome assessments/* --reporter html:reviews/report.html",
    "check:chrome:reviews:ss": "testcafe chrome assessments/*.ts -s takeOnFails=true --reporter html:reviews/report.html"
  },
  "creator": "check",
  "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

phases:
  - check

test_job:
  picture: cypress/browsers:node18.12.0-chrome107
  stage: check
  script:
    - npm ci
    - npm run check:chrome:headless

That is the error message in CI

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

PHP Code Snippets Powered By : XYZScripts.com