jamesplease / testing-with-babel

[Don't reference this]: Examples of using Babel with popular testing tools
MIT License
48 stars 4 forks source link

CLI example with AT and UT? #7

Open ghost opened 8 years ago

ghost commented 8 years ago

Hi. Great work!

To take it all out. What about a CLI example that runs browser and server tests. AT and UT and with coverage and html runner?

jamesplease commented 8 years ago

What's AT and UT?

I intend to have an example similar to what you've described...in a few days! I'm aiming to add 2-3 new examples per day.

ghost commented 8 years ago

AT = application tests. UT = unit tests

Or FT?

http://stackoverflow.com/questions/2741832/unit-tests-vs-functional-tests

jamesplease commented 8 years ago

I'd love to add "AT"s if you can elaborate more on what those might look like. If it helps, my current plan is to have examples like:

ghost commented 8 years ago

AT is what you are using now in the test folder. UT is example what React uses in the src folder.

Example

- tests     // AT

- src --
         |
         | - fancyStuff
           - __test__   // UT

The tests in the test folder is what you have now. The __test__ folder under fancyStuff only tests the file inside that folder. Say you have a jmeas file in that folder. Then the test will be to test all functionality for jmeas.

Link here: https://github.com/facebook/react/tree/master/src/renderers/dom/client

If you want to handle Karma + Rollup + Mocha, you will most likely not have any hair left on your head. You will get massive trouble because of the plugins Rollup needs, and issues with .babelrc etc. And without babelrc you can't run mocha tests for server. And with it, you can't use Rollup... I just scratched the surface!!

I solved this myself, so you can see how I did it here: https://github.com/Kflash/boily

jamesplease commented 8 years ago

AT is what you are using now in the test folder. UT is example what React uses in the src folder.

Ah, interesting. Do the contents of the tests change at all? I'm more interested in the configuration of the tools than preferences like the location of the test files. I do really like the approach of putting the tests right next to the source files, though.

If you want to handle Karma + Rollup + Mocha, you will most likely not have any hair left on your head.

lmao

I solved this myself, so you can see how I did it here: https://github.com/Kflash/boily

Nice! I'll check this out!

ghost commented 8 years ago

For AT and UT it's different testing tasks. AT mainly tests how the application works all together. UT tests each single file and it's functionality. The trick here will be to get both AT and UT to share the same coverage report.

I plan to start to look into this for my own project soon, so maybe I can share couple of ideas.

Off topic. For coverage report. I would say stay away from Istanbul and use Isparta - not Instrumental loader. Wrong line numbers will happen in the coverage report etc. So I make sure I didn't hurt anyone with that comment. This happen only with ES6 as far as I know.

And if you plan to use Karma, don't use the newest version YET! Big time issue with Coveralls. https://github.com/karma-runner/karma/issues/1768

ghost commented 8 years ago

@jmeas I implemented environment variable support and UT testing in my own project now. Not so hard. You can take a look.

jamesplease commented 8 years ago

Cool – I'll do that! Thanks @kflash.