bhauman / devcards

Devcards aims to provide a visual REPL experience for ClojureScript
1.53k stars 116 forks source link

Run test fixtures #76

Open pieter-van-prooijen opened 8 years ago

pieter-van-prooijen commented 8 years ago

Hello Bruce,

When running tests in a devcard it the fixtures associated with that test are not executed. This PR changes that by running the tests using the var created by deftest and using the deftest fixture machinery in cljs.test/test-vars-block. It differs from a normal clsj.test run in the following ways:

Kind regards,

Pieter van Prooijen

bhauman commented 8 years ago

This is interesting.

I'm going to look at this some more. However right off the bat all devcard code needs to work in advanced compilation. This is a Devcards requirement so that folks can deploy reference material and examples to the web. This also allows folks to see if their tests still run in different compilation modes.

We could say that well only fixtures don't work in advanced compilation but ... slippery slope eh?

pieter-van-prooijen commented 8 years ago

Hello Bruce,

I've incorporated the use-fixtures macro into devcards so it marks the fixture symbols as exportable and they don't get munged by the Closure compiler. Seems to work, I can now run the fixtures in advanced compilation mode.

bhauman commented 8 years ago

So, I've been looking at this and I have found some errors. Please refer to the devdemos.testing ns. See how it functions before your commits and then after.

The timeout doesn't seem to fire. The mid-test documentation isn't getting output.

Thank you for working on this but another approach may be required.... Still looking at it.

pieter-van-prooijen commented 8 years ago

Hi Bruce,

The timeout in devdemos.testing doesn't fire because an async block should always be the last expression in a deftest, due to the way cljs.test detects and schedules async tests. The test now works because devcards runs each form in a deftest individually, not as a whole as cljs.test does it. In my branch of devdemos.testing, I've moved the async block to the end of deftest and that seems to do the trick. I've also re-added the dc/tests macro, so the last devcard on that page also works.

I'm afraid I don't have a solution for rendering the test doc strings in the middle of a deftest, (other than using the "testing" macro), bcause deftest doesn't support this.