bahmutov / cypress-select-tests

User space solution for picking Cypress tests to run
97 stars 14 forks source link

[Question] Does cypress-select-tests support Typescript? #133

Open git-malu opened 4 years ago

git-malu commented 4 years ago

I guess cypress-select-tests does not support Typescript so far. Because when I try to use cypress-select-tests together with Typescript, I get the error below.

SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (17:0)

My Cypress package works well with Typescript if I comment out this plugin.

// on('file:preprocessor', selectTestsWithGrep(config));

sagar-ganatra commented 4 years ago

+1, facing the same issue

csalazar1 commented 4 years ago

@bahmutov any chance you can do a quick fix? Seems like a handful of us are having this issue

rvowles commented 4 years ago

It wasn't a quick fix. The library uses falafel to parse the source code and rewrite steps with .skip. I have swapped it to use the typescript compiler (which will of course read javascript) and rewrite it in the same fashion, but it also needs to turn typescript on as this library wipes out the normal cypress ability to process typescript.

csalazar1 commented 4 years ago

@rvowles was this merged to master already?

rvowles commented 4 years ago

No, I haven't pushed it up and I don't think @bahmutov will want it given it swaps from falafel to typescript. Its currently under review where I work.

csalazar1 commented 4 years ago

Got it. Thank you so much for the update on this

rvowles commented 4 years ago

Ok @csalazar1 - my "branch" is over here but I'm not issuing a PR because I don't think @bahmutov will be that interested. https://github.com/rvowles/cypress-select-tests

It does a few things - it always enables typescript, it uses a ts parser for typescript and javascript one for javascript. We only use typescript here, so I left the js one for the tests.

Further it has a preprocessor that reads the cypress.json file, applies your filtering and updates the cypress.json file into a cypress-grep.json file, which then includes the filtering but removes any files in your spec list that wouldn't be run as they have no tests.

One thing you probably won't like is that it actively removes tests that are not run rather than leaving them pending. Pending on our case implies there is some action that needs to be done on them, confusing the reporting. In typescript, this removes the step and replaces it with a placeholder ("true").

csalazar1 commented 3 years ago

@rvowles I finally got around to this. It seems to be failing with this error though

error

Any ideas what it could be?

rvowles commented 3 years ago

If it is acorn your issue is that it is treating whatever that file is as JavaScript and parsing it using acorn and falafel.

biltongza commented 3 years ago

@rvowles we're trying to use your plugin, stock standard config (i.e. on('file:preprocessor', selectTestsWithGrep(config));) and we keep getting SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' no matter what we change. We've tried messing with tsconfig files but nothing seems to work. How do we tell this thing that we are using typescript files? It's like it isn't finding our tsconfig file (which is in the cypress directory)

rvowles commented 3 years ago

Maybe ask this question on my repo instead of here?

biltongza commented 3 years ago

image you don't have Issues enabled on your repo :(

onimougwo commented 3 years ago

Any update ?

estefafdez commented 3 years ago

I would love Typescript to be supported by this plug-in. Thanks for all the hard work on this one!

NeetuHundal commented 3 years ago

Does anyone was able to resolve this error SyntaxError: 'import' and 'export' may appear only with 'sourceType: module'? If yes, please guide how did you do.Really appreciate. Thank you.