-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Out-of-the-box TypeScript Support #5906
Out-of-the-box TypeScript Support #5906
Conversation
Thanks for the contribution! Below are some guidelines Cypress uses when doing PR reviews.
PR Review ChecklistIf any of the following requirements can't be met, leave a comment in the review selecting 'Request changes', otherwise 'Approve'. User Experience
Functionality
Maintainability
Quality
Internal
|
I don't know why but stack trace message structures are a bit changed. So, updated snapshots. |
25ee491
to
aae6ce1
Compare
This comment has been minimized.
This comment has been minimized.
@jennifer-shehane It passed build this time. |
I have tested this PR locally against a new project, this is pretty incredible.
If you rename plugins or support file and restart the test runner, then it works, nice. But if you rename the plugins file to I am fine with including |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the functionality, I just think that if you rename plugins/index.js
to plugins/index.ts
while the test runner is running it should intelligently handle this.
Same for support file.
f7ed97b
to
d486202
Compare
|
Nice @sainthkh I will fix the AppVeyor - one of my collaborators on |
this.push(text) | ||
} else { | ||
this.push(ts.transpileModule(text, { | ||
compilerOptions: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this completely overrides specific configuration in tsconfig.json
, if i understand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(that seems reasonable honestly, just thinking about it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it does. Because for the speed, it ignores the type check. If we do type check, it takes about 7-10 sec to load a test file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks great!! i think i do wonder about: how users can extend the configuration we use to transpile, if they might need to.
this also makes me wonder whether we are emitting ts instead of js for examples on first install? if we're not maybe this unlocks a good opportunity to do that (we'd have to author examples in TS ofc)
They're tested in preprocessor.
28e5a12
to
9ad54d6
Compare
9ad54d6
to
3512f4d
Compare
|
This looks really good. I think the only thing left to do is update the documentation and recipes regarding TypeScript.
|
Gleb made a good point that users could be on an older version of Cypress, so we should keep the recipes around, just add a note that says if you're in version We don't need a similar note in the docs, since there's an underlying assumption with the docs that it relates to the latest version of Cypress. |
In the docs we can also add this note under history widget
…Sent from my iPhone
On Apr 13, 2020, at 10:41, Chris Breiding ***@***.***> wrote:
Gleb made a good point that users could be on an older version of Cypress, so we should keep the recipes around, just add a note that says if you're in version x.x.x or later, it's supported by default.
We don't need a similar note in the docs, since there's an underlying assumption with the docs that it relates to the latest version of Cypress.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Need to update the docs with this, but going to merge this in to try to get it into our release today and see how our tests run against it in our example projects in |
@jennifer-shehane Awesome! Do we know what version number this will be released with? Our team is looking at updating our version of Cypress and I'd love for this feature to be included. |
@kpittman-securus Already released in 4.4.0: https://github.com/cypress-io/cypress/releases |
@@ -99,6 +101,23 @@ class Project extends EE { | |||
|
|||
return scaffold.plugins(path.dirname(cfg.pluginsFile), cfg) | |||
} | |||
}).then((cfg) => { | |||
try { | |||
const tsPath = resolve.sync('typescript', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this PR has already been merged, but it is a bad idea to ever use sync
functions which read from the file system. this should use the async variant that does async fs
calls under the hood. this avoids potential EMFILE
errors.
@@ -173,9 +177,38 @@ module.exports = (ipc, pluginsFile) => { | |||
return false | |||
}) | |||
|
|||
if (!tsRegistered) { | |||
try { | |||
const tsPath = resolve.sync('typescript', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see other comment about EMFILE
} | ||
|
||
try { | ||
return resolve.sync('typescript', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see other comment about EMFILE
User facing changelog
You don't need to install TypeScript plugin to use Cypress. It works out-of-the-box.
Additional details
Why was this change necessary?
Many developers are now using TypeScript and want to use Cypress + TypeScript without any configuration.
What is affected by this change?
Bundle size will become a bit bigger because
ts-node
. (If it's a problem, we need to drop TypeScript support forplugins
.)Any implementation details to explain?
I've developed a small transform that transpiles the ts files.
How has the user experience changed?
ts
in plugins.ts
files. It works.PR Tasks
cypress-documentation
?type definitions
?cypress.schema.json
? -> No options added.