I'm trying to use Cypress w/ Typescript but Cypress can't find the tsconfig.json
file I've created for it. I also have a custom directory structure (because I hate when there's a bunch of config files in the root, so I put them in a config directory).
Project Directory Structure
/
├── package.json
├── configs/
│ ├── cypress.json
├── src/
│ ├── cypress/
│ │ ├── tsconfig.json
Cypress Open command
// package.json
"scripts": {
"cypress:open": "cypress open --config-file configs/cypress.json"
},
In the script above, the --config-file
flag tells cypress the location of the cypress.json
config file, which is AWESOME because I can put that file anywhere I want it. However, now I need to instruct Cypress on where to find it's tsconfig.json
file.
/configs/cypress.json (tells Cypress where the cypress/
directory is)
{
"fixturesFolder": "src/cypress/fixtures",
"integrationFolder": "src/cypress/integration",
"pluginsFile": "src/cypress/plugins/index.js",
"screenshotsFolder": "src/cypress/screenshots",
"videosFolder": "src/cypress/videos",
"supportFile": "src/cypress/support/index.js"
}
// is there no option to set tsconfig.json path????
The official documentation says to just put it in the cypress/
directory. According to the docs, that should be at /cypress/tsconfig.json
, but in my project it's in /src/cypress/tsconfig.json
.
Here's the location I've tried to put the tsconfig.json
file:
/src/cypress/tsconfig.json //Error: "Couldn't find tsconfig.json. tsconfig-paths will be skipped"
/src/tsconfig.json //Error: "Couldn't find tsconfig.json. tsconfig-paths will be skipped"
/cypress/tsconfig.json //Error: "Couldn't find tsconfig.json. tsconfig-paths will be skipped"
/tsconfig.json // Works!! But not where I want this file to live...
How can I instruct Cypress on where to look for the tsconf.json file I want it to use? Is there an option in the cypress.json
config file, or a CLI flag I can use????
I don't want to clutter my project root with miscellaneous config files, and I actually have separate tsconfig files for my project and my test suite. It would be great to set the file path explicitly.