cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.79k stars 3.17k forks source link

Provide complete E2E TypeScript scaffolding #27603

Open MikeMcC399 opened 1 year ago

MikeMcC399 commented 1 year ago

What would you like?

If the npm module typescript is installed with no other TypeScript configuration files defined, Cypress E2E scaffolding should set up a minimum configuration to enable the basic E2E example to run successfully with no errors. This would include adding the file tsconfig.json to the scaffolded Folder Structure.

Why is this needed?

First-time TypeScript users should experience the same smooth set up as JavaScript users currently do when installing Cypress and using a default configuration.

Steps to reproduce

mkdir cy-ts-test
cd cy-ts-test
git init
npm init -y
npm install typescript -D
npm install cypress -D
npx cypress open --e2e --browser electron

Click "Continue" Click "Create new spec" Click "Create spec" Click "Okay, run the spec"

Note the error message

Error: Webpack Compilation Error
[tsl] ERROR
      TS18002: The 'files' list in config file 'tsconfig.json' is empty.

Note that if the line npm install typescript -D -E in the above steps is omitted, then scaffolding and running the example spec is successful.

Related issues

jennifer-shehane commented 1 year ago

@MikeMcC399 We did want to make this change, but don't have the time to implement it. I anticipate this work will be a lot more complex than one might think when they start to implement it with all the logic and UI visuals that would be involved. I'll leave this open as a consideration.

MikeMcC399 commented 3 days ago

Scaffolding a TypeScript project so it runs without editing should also support when package.json is configured with Node.js type field set to module (ESM).