-
-
Notifications
You must be signed in to change notification settings - Fork 149
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
TypeScript tests fail with ParseError: 'import' and 'export' may appear only with 'sourceType: module'
#61
Comments
can you try using require instead of import? |
I tried
|
that's not good. any chance for a simple reproduction? I would love to make this work with typescript. import might be tricky but everthing else should work. |
Do you want a Github repo, @lgandecki? Is there a sample base project on which to create a reproduction? |
Yeah github repo would be great, the simplest thing you can create that replicates the problem so I can jump in and see what’s going on |
Please see my reproduction in my |
Thanks, I will take a look Friday/Saturday :) |
ok.. I spent a couple hours on this, and it is much more work than I initially thought... I will have to pass on it for now. Maybe once we/I need to use typescript I will be able to spend more time to get this to work. If we were able to use babel7 with cypress (possibly soon), then we can use the plugin-transform-typescript in browserify to remove types from our output js file. At this point I can't think of a quick fix here. :-( Thanks for the reproduction and sorry couldn't help. If someone would like to pick it up - looks like the compile function in index.js produces a file with, possibly, valid typescript code. We would need to transpile it to javascript before passing it back to browserify.. |
Thanks for investigating, @lgandecki. Until TypeScript is actually supported, perhaps the README should be updated to remove TypeScript instructions. |
Hi @KeithGillette, |
@sloosch that looks really cool :-) Right now #52 is fixed, #51 should be finalized this week (we want to make sure that we get it right the first time around so we don't mess up peoples tests changing the tags API in the future), and having #52 done gets us a step closer towards using typescript. About.. #44 - could you elaborate a bit? what do you mean by overcoming it with beforeStep-hook? |
@lgandecki Of course this is a hack and we are all waiting for the user-managable state PR cypress-io/cypress#686 :) But it will make your manager happy to see the steps when you are trying to argue against established solutions like cucumber-jvm + selenium. |
@sloosch yeah, that sounds like a workable hack :-) I might try it. Btw, TypeScript works with 1.2.0! @KeithGillette These are the only changes You'd have to make in your repro to get your example to work:
|
Thanks, @sloosch & @lgandecki! I confirm that the diffs above allow use of some TypeScript with |
wow, what an ugly hack!! why would you want to infer 'given' instead of importing the type ? import and export make the most sense in typescript, solving the problem reported here makes me want to think 🤔 that I don't want to use cypress, ever. |
Attempting to set up
cypress-cucumber-preprocessor
withadd-typescript-to-cypress
, I receive the following error when running a.feature
test in Cypress whose step definitions are in asteps.ts
file containing animport
statement:Running a separate
spec.ts
file containing animport
using only@bahmutov/add-typescript-to-cypress
incypress/plugins/index.js
works fine, but as soon as I addon('file:preprocessor', cucumber());
TypeScript tests containingimport
fail with the same error.I see other open issues related to that same error but for ES6, not TypeScript (targeting ES5), so I am opening this case.
Versions:
The text was updated successfully, but these errors were encountered: