Getting the TypeError [ERR_INVALID_URL error in my WebdriverIO-Typescript-Bdd framework

1k Views Asked by At

Project Structure Image

Team, getting the below error in my WebdriverIO-Typescript-Bdd framework :

TypeError [ERR_INVALID_URL]: Invalid URL at new NodeError (node:internal/errors:387:5) at URL.onParseError (node:internal/url:565:9) at new URL (node:internal/url:641:5) at new URL (node:internal/url:638:22) at processTicksAndRejections (node:internal/process/task_queues:96:5)

Any insights on this ?

Package.json file :

{
  "name": "new_framework_poc",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "wdio": "wdio run ./wdio.conf.ts",
    "prepare": "husky install"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@sinonjs/fake-timers": "^10.0.2",
    "@wdio/cli": "^8.3.10",
    "@wdio/cucumber-framework": "^8.3.0",
    "@wdio/local-runner": "^8.3.10",
    "@wdio/selenium-standalone-service": "^8.3.2",
    "@wdio/spec-reporter": "^8.3.0",
    "chromedriver": "^110.0.0",
    "husky": "^8.0.3",
    "ts-node": "^10.9.1",
    "typescript": "^4.9.5",
    "wdio-chromedriver-service": "^8.1.1",
    "webdriverio": "^8.3.10"
  }
}


tsconfig : 

{
    "compilerOptions": {
        "outDir": "./.tsbuild/",
        "baseUrl": "www.google.com",
        "rootDir": "./",
        "sourceMap": true,
        "declaration": false,
        "downlevelIteration": true,
        "experimentalDecorators": true,
        "moduleResolution": "node",
        "typeRoots": ["node_modules/@types", "./node_modules/@types"],
        "importHelpers": true,
        "target": "ES2018",
        "module": "commonjs",
        "esModuleInterop": true, 
        "allowJs": true, 
        "types": ["node", "@wdio/globals/types"],
        "lib": [
          "es2015",
          "es2017",
          "es2018",
          "es2020",
          "es6",
          "dom"
        ],
        "allowSyntheticDefaultImports":true
    },
    "exclude": [
        "node_modules",
        "./node_modules",
        "./node_modules/*",
        "node",
        "./node",
        "./node/*",
        "target",
        "./target"
      ],
}
1

There are 1 best solutions below

2
On

TypeError [ERR_INVALID_URL]:

Invalid URL at new NodeError (node:internal/errors:387:5) at URL.onParseError (node:internal/url:565:9) at new URL (node:internal/url:641:5) at new URL (node:internal/url:638:22) at processTicksAndRejections (node:internal/process/task_queues:96:5)

You should change the value of the baseUrl to a directory path in tsconfig like below and better to use the url in your test file.

"baseUrl": "./my-project",