TypeScript aliases not recognized when tsconfig.json file is in Cypress folder
See original GitHub issueCurrent behavior
When trying to import an Enum
alias from a Typescript file within the Cypress folder as described in the docs, the webpack cannot resolve the alias, even though it is defined in the tsconfig.json
file
Desired behavior
Properly import aliases from tsconfig.json
files in the Cypress folder without needing to place tsconfig.json
with at root project directory.
Test code to reproduce
https://github.com/shawn-e-harris/typeScriptAlias.git
Cypress Version
8.2.0
Other
Error: Webpack Compilation Error
./cypress/support/helper/helpers.js
Module not found: Error: Can't resolve '@alias-example/sub-folder/app-code.ts' in '/Users/joel.whalen/Documents/src/reproducers/alias-error-cypress/cypress/support/helper'
resolve '@alias-example/sub-folder/app-code.ts' in '/Users/joel.whalen/Documents/src/reproducers/alias-error-cypress/cypress/support/helper'
Parsed request is a module
using description file: /Users/joel.whalen/Documents/src/reproducers/alias-error-cypress/package.json (relative path: ./cypress/support/helper)
Field 'browser' doesn't contain a valid alias configuration
Looked for and couldn't find the file at the following paths:
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Using TypeScript aliases in Cypress tests - Gleb Bahmutov
We can rename our test file from spec.js to spec.ts - and it should run the same. Since the tsconfig.json file is only...
Read more >Specify tsconfig.json location for Cypress - Stack Overflow
It is build with create-react-app and TypeScript. The tsconfig.json used for Cypress is located in the cypress directory. It is possible you ...
Read more >TypeScript - Cypress Documentation
Configure tsconfig.json · Open the command palette (Mac: cmd+shift+p , Windows: ctrl+shift+p ) · Type "restart ts" and select the "TypeScript: Restart TS...
Read more >API - ESBuild
The build API call operates on one or more files in the file system. ... an alias, the resulting import path is resolved...
Read more >Typescript does not resolve modules through tsconfig.json's ...
The problem is that you have "files":[] section that only includes a file from typings. If there is a 'files' section in tsconfig.json,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jennifer-shehane I see you’ve added the
existing workaround
label, could you point to that workaround?Is there a solution when there is a tsconfig that exists outside the cypress folder (in root), I want to create a few component tests, but blocked by this issue. I have tried to use the ts-loader, but to no avail
the folder stricture is root cypress/ -all the cypress goodies including a tsconfig file that extends the root tsconfig file -tsconfig.json (where the paths exist)