cypress-select-tests
cypress-select-tests copied to clipboard
[Question] Does cypress-select-tests support Typescript?
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));
+1, facing the same issue
@bahmutov any chance you can do a quick fix? Seems like a handful of us are having this issue
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.
@rvowles was this merged to master already?
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.
Got it. Thank you so much for the update on this
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").
@rvowles I finally got around to this. It seems to be failing with this error though
Any ideas what it could be?
If it is acorn your issue is that it is treating whatever that file is as JavaScript and parsing it using acorn and falafel.
@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)
Maybe ask this question on my repo instead of here?
you don't have Issues enabled on your repo :(
Any update ?
I would love Typescript to be supported by this plug-in. Thanks for all the hard work on this one!
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.