practicalmeteor/spacejam

Option to keep spacejam running, and rerun tests on change

Closed this issue · 9 comments

It would be nice to have an option that keeps spacejam running like the standard meteor package test, and triggers the tinytests again on change. That could eliminate the opened browser from the workflow.

Hey, I actually like the open browser, it allows me to filter tests, and have the tests run in a real browser, not in phantomjs. We will not work on something like that, but will accept PRs for that, if someone wants to work on it. We already implemented something very similar for the velocity team, yet never published it, so you can use it as a base. I can get on skype / google hangout to show you what needs to be changed:

https://github.com/spacejamio/test-in-velocity

That would be a perfect addition to my notifier package for a TDD workflow. I'll look into it, thanks for the info.

Finally I got some time to look into it. It is not yet pushed, but the idea is: use the already existing --watch flag, and create a custom script based on phantomjs-test-in-console, and it simply not exits the phantomjs. That way both file change reloads and meteor crashes are handled well.

However, I'd like to take another step: the root cause of this is to be able to use notification on file save. Maybe it's because of I got used to that in Rails, I find extremely useful to get notifications on test state... I created a smart package that uses node-notifier, and hooks to tinytest.

I would like to add this feature to the runner. That would introduce a node-notifier dependency, but you could have a cool autotesting feature to use with spacejam. That way you could have both default package tests running by meteor, and a notification handled by spacejam.

If you are okay with the idea, I'll push the code soon, and make a PR - maybe also add an option to use access the feature in a more simple way then specifying --watch and custom phantomjs script.

Thoughts?

Hey, didn't quite understand what you're trying to do. Let's skype? ronenbabayoff

Will be busy this week (Craft conference) but will try to catch you in skype or hangouts and clarify things. Probably the upcoming evenings I can push some code to my fork, that may help as well.

Hey, here is the stuff (raw version)
aquator/spacejam@6182ca68725c1c46483eda696e66db3dad883efd is the simple phantomjs script that not exists (you should launch spacejam with both --phantomjs-script=phantomjs-watch-in-console and --watch arguments)

aquator/spacejam@95367a6a43ae2f7646774fd2fdd2d4d3c7590889 is a mod in Phantomjs.coffee to emit the test results (parsed from passed/expected/failed/total... line at the end of test run)

aquator/spacejam@ba532ee409cf9b6894b975316e8df54919541060 gives you notification support if you run spacejam with --notify

Meh, the bad thing is it will not re-rest if a server-only file is changed (both source and test files affected, if they are server only) I could use a hint on that.

Hey, I am a bit overwhelmed with other real life issues, but don't quit on this just yet. Do you have any idea how to trigger a phantomjs re-test if a sever only file is changed? That's pretty much the last thing to solve.

Hey, no need to use file system watch at all, you can just use meteor's builtin hot code pushes on code changes. Reason it doesn't work with spacejam is that spacejam uses meteor's test-in-console test driver, which doesn't include the autoupdate and reload packages. meteor's default test-in-browser test driver does, so you get hot code pushes for your tests in the browser when you run meteor test-packages.

What I recommend is creating another test driver package, which spacejam can then run using meteor's builtin support for:

meteor test-packages --driver-package ...

I've already created something for the velocity team to run tinytest package tests in velocity continuously, and even though it works, I never published it, since I don't use velocity internally, but you can use it as a reference, and even control the output and create your own reporters. Don't forget to add to the package a file like this to reload on server changes too:

https://github.com/meteor/meteor/blob/devel/packages/test-in-browser/autoupdate.js

Here is the driver package:

https://github.com/spacejamio/test-in-velocity

I've also showed Mike how to create his mocha for packages based on the same --driver-package concept, so we know this mechanism works.

If you want a quick and dirty solution, copy meteor's test-in-console, add the reload and autoupdate packages and add the autoupdate.js file.

Cheers

Thanks for the tip, what I missed is the autoupdate I guess. I used the watch to prevent script termination, but I'll take another try with the test-in-velocity once I'll have a few moments of something people call "free time" :D