webdriverio: [๐ Bug]: Import giving error ERROR @wdio/runner: Error: Cannot find package with paths defined in tsconfig.json
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
WebdriverIO Version
8.14.4
Node.js Version
20.5.0
Mode
WDIO Testrunner
Which capabilities are you using?
capabilities: {
[0-0] alwaysMatch: {
[0-0] browserName: 'chrome',
[0-0] browserVersion: '112.0',
[0-0] proxy: [Object],
[0-0] 'goog:chromeOptions': [Object],
[0-0] 'goog:loggingPrefs': [Object],
[0-0] 'selenoid:options': [Object]
[0-0] },
[0-0] firstMatch: [ {} ]
[0-0] },
[0-0] desiredCapabilities: {
[0-0] browserName: 'chrome',
[0-0] browserVersion: '112.0',
[0-0] proxy: {
[0-0] proxyType: 'manual',
[0-0] httpProxy: 'localhost:39500',
[0-0] sslProxy: 'localhost:39500'
[0-0] },
[0-0] 'goog:chromeOptions': { prefs: [Object] },
[0-0] 'goog:loggingPrefs': { performance: 'ALL', browser: 'ALL', driver: 'ALL' },
[0-0] 'selenoid:options': {
[0-0] name: 'stag:loginTests:chrome',
[0-0] enableVNC: true,
[0-0] enableVideo: true,
[0-0] videoFrameRate: 24,
[0-0] videoCodec: 'mpeg4',
[0-0] perfLoggingPrefs: [Object],
[0-0] extensions: [Array],
[0-0] env: [Array],
[0-0] sessionTimeout: '900s'
[0-0] }
[0-0] }
[0-0] }
What happened?
Import giving error ERROR @wdio/runner: Error: Cannot find package with paths defined in tsconfig.json
I have defined path in tsconfig.json as:
โpathsโ: {
"@Util/*": [
"test/util/*"
]
}
Under Compiler options and I am using Import statement as:
import LoginUtil from โ@Util/LoginUtilโ;
but getting error:
[2023-08-03T12:09:15.747Z] 2023-08-03T12:09:15.747Z ERROR @wdio/runner: Error: Cannot find package โ@Util/LoginUtilโ imported from //test/util/LogoutUtil.ts [0-0] at packageResolve (/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:757:9) [0-0] at moduleResolve (/node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:798:18) [0-0] at Object.defaultResolve (//node_modules/ts-node/dist-raw/node-internal-modules-esm-resolve.js:912:11) [0-0] at /node_modules/ts-node/src/esm.ts:218:35 [0-0] at entrypointFallback (node_modules/ts-node/src/esm.ts:168:34) [0-0] at /node_modules/ts-node/src/esm.ts:217:14 [0-0] at addShortCircuitFlag (node_modules/ts-node/src/esm.ts:409:21) [0-0] at resolve (/node_modules/ts-node/src/esm.ts:197:12) [0-0] at nextResolve (node:internal/modules/esm/hooks:733:28) [0-0] at Hooks.resolve (node:internal/modules/esm/hooks:242:30)
I am using type: module in package.json and โmoduleโ: โesnextโ, in tsconfig.json.
In case I use relative path as :
import LoginUtil from โโฆ/util/LoginUtil.tsโ; then it works sucesfully.
What is your expected behavior?
Import statement should not throw any errors.
How to reproduce the bug.
Just try running basic test case where import of another package is required but specify the path of file from where we need to import with @PathValue/<Filename>.
Relevant log output
There should be no errors reported when import is used as:
import LoginUtil from '@Util/LoginUtil';
Code of Conduct
- I agree to follow this projectโs Code of Conduct
Is there an existing issue for this?
- I have searched the existing issues
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 20 (14 by maintainers)
Original description of issue already have reproducible example.
Using the
tsconfig-pathsdocumentation I was able to run the tests just fine by executing: