avajs / ava-codemods

Codemods for AVA
https://ava.li
MIT License
68 stars 16 forks source link

Automatic detection of existing test framework. #2

Closed jamestalmage closed 5 years ago

jamestalmage commented 8 years ago

Automatically detect which test framework a user is currently using.

Scanning the require statements should work for tap and tape.

Scanning for describe / it, etc. Should work for mocha.

sindresorhus commented 8 years ago

Scanning for describe / it, etc. Should work for mocha.

Jasmine also uses describe/it.

jamestalmage commented 8 years ago

Jasmine also uses describe/it.

Good point. Jasmine's assertion API differs from chai enough that I think we could make it automatic.

We could combine with examining devDependencies. That would be pretty reliable.


Also, we could just abandon this and give them a prompt. People are going to use these pretty rarely, so it may be better to just focus on providing really good, really smart transforms than focusing on little niceties that save them a few keystrokes. Actually, I think that is probably the better choice.

sindresorhus commented 8 years ago

@jamestalmage Why not just check devDependencies? I can't think of a more reliable way than that.

jamestalmage commented 8 years ago

You technically could have multiple test frameworks used in a large project (and the codemods become more and more valuable, the larger the project)

sindresorhus commented 8 years ago

That honestly sounds like an extreme edge-case and premature concern, but if you really think this could be an issue, just fall back to requiring the user to specify which framework if it's ambiguous.

jfmengels commented 8 years ago

Also, we could just abandon this and give them a prompt

:+1: , don't see the value of trying to detect it. Feels error-prone and potentially hard (what if the user has two tests frameworks in a pretty big project, wouldn't want to prevent him to apply both transforms)