ability to use html test runner files #66

Closed
opened 2011-09-21 18:31:37 +00:00 by deleteme · 14 comments
deleteme commented 2011-09-21 18:31:37 +00:00 (Migrated from github.com)

It would be nice to have the option to use html files instead of yml files to define a suite.

The html file would be useful because it would allow you to use a browser's debugging tools. Another benefit would be that I wouldn't have to define both a yml and html test runner files.

It would be nice to have the option to use html files instead of yml files to define a suite. The html file would be useful because it would allow you to use a browser's debugging tools. Another benefit would be that I wouldn't have to define both a yml and html test runner files.
johnbintz commented 2011-09-21 18:54:40 +00:00 (Migrated from github.com)

How would you envision this working? The runner builds a lot of support JavaScript into the HTML pages it creates to make things work -- things like Jasmine itself, a custom reporter, information on the files being tested for reporting purposes, and object inspection code. What would you put into the HTML file you're providing to JHW so that you would be able to take advantage of all of this?

How would you envision this working? The runner builds a lot of support JavaScript into the HTML pages it creates to make things work -- things like Jasmine itself, a custom reporter, information on the files being tested for reporting purposes, and object inspection code. What would you put into the HTML file you're providing to JHW so that you would be able to take advantage of all of this?
deleteme commented 2011-09-21 19:12:25 +00:00 (Migrated from github.com)

I guess there would need to be a JHW js file linked in the html page that would do this.

If it helps, here's some backstory. I started a project using jasmine-headless-webkit with it's coffeescript options. Then I encountered some bugs in my code that required deeper inspection. So I created my own HTML file for running the tests, and it used the coffeescript js to convert the compile the code over. Then that became problematic, because inspecting the dynamically generated js was a pain, so I abandoned coffeescript altogether.

Now I'm using straight javascript and developing/testing within the HTML test runner first because of the visibility I get from the debugging tools. After I get it to a point where I want to deal with it, I'll update the yml file and modify the code to work headlessly. This means that any markup that my tests depend upon has to be created with js.

So, I started out thinking I could get away with a quick headless TDD solution, but it turns out that the headless runner is more useful to check for regressions after I've done the development. And I have to modify the tests to run properly in it.

Right now, jasmine-headless-webkit is great for pure javascript unit tests, but it's a bit more involved when working with the DOM.

If I could point jasmine-headless-webkit at an html test runner, then it would alleviate these pains.

I guess there would need to be a JHW js file linked in the html page that would do this. If it helps, here's some backstory. I started a project using jasmine-headless-webkit with it's coffeescript options. Then I encountered some bugs in my code that required deeper inspection. So I created my own HTML file for running the tests, and it used the coffeescript js to convert the compile the code over. Then that became problematic, because inspecting the dynamically generated js was a pain, so I abandoned coffeescript altogether. Now I'm using straight javascript and developing/testing within the HTML test runner first because of the visibility I get from the debugging tools. After I get it to a point where I want to deal with it, I'll update the yml file and modify the code to work headlessly. This means that any markup that my tests depend upon has to be created with js. So, I started out thinking I could get away with a quick headless TDD solution, but it turns out that the headless runner is more useful to check for regressions after I've done the development. And I have to modify the tests to run properly in it. Right now, jasmine-headless-webkit is great for pure javascript unit tests, but it's a bit more involved when working with the DOM. If I could point jasmine-headless-webkit at an html test runner, then it would alleviate these pains.
johnbintz commented 2011-09-21 19:28:07 +00:00 (Migrated from github.com)

The better solution would be to use the generated HTML file from JHW in your browser, however that needs some work to make work nicely, since I have a custom reporter in there. It's impractical to find some way to "import" an arbitrary HTML file and have it all work cleanly -- there's too much room for error. I'll ponder the best way to export a file that a browser can use with no modifications (or feel free to dive into the code and experiment).

The second best solution is to improve the inspection capabilities of JHW. Are you using jQuery? Backbone.js? If you're using jQuery, jasmine-jquery is pretty much a requirement. The latest master HEAD has some huge improvements to introspection that aren't in a gem release yet. Do any of the changes in there make a difference? I improved the line number feedback for CoffeeScript files, though it's impossible to get those 100% accurate. The one thing that I know is missing is stack traces, but I've been unable to build a copy of QtWebKit with V8 or with some new patches that enable proper stack traces in JavaScriptCore. :(

The better solution would be to use the generated HTML file from JHW in your browser, however that needs some work to make work nicely, since I have a custom reporter in there. It's impractical to find some way to "import" an arbitrary HTML file and have it all work cleanly -- there's too much room for error. I'll ponder the best way to export a file that a browser can use with no modifications (or feel free to dive into the code and experiment). The second best solution is to improve the inspection capabilities of JHW. Are you using jQuery? Backbone.js? If you're using jQuery, `jasmine-jquery` is pretty much a requirement. The latest master HEAD has some huge improvements to introspection that aren't in a gem release yet. Do any of the changes in there make a difference? I improved the line number feedback for CoffeeScript files, though it's impossible to get those 100% accurate. The one thing that I know is missing is stack traces, but I've been unable to build a copy of QtWebKit with V8 or with some new patches that enable proper stack traces in JavaScriptCore. :(
johnbintz commented 2011-09-30 14:49:18 +00:00 (Migrated from github.com)

I now have a hankerin' to start messing with this. I have another use case that would need generated files that I want to start experimenting with. I'll play with it a bit this weekend/next week and see what I can get going.

I now have a hankerin' to start messing with this. I have another use case that would need generated files that I want to start experimenting with. I'll play with it a bit this weekend/next week and see what I can get going.
deleteme commented 2011-09-30 15:38:03 +00:00 (Migrated from github.com)

Cool. If you're going to experiment with outputting an html file, I have a suggestion:

I would like to be able to specify the filename in the yml file.

In my particular project, I have several yml files to test various interface's scripts. So in one yml file, I would name the rendered html file admin.html, and another may be mobile.html.

Cool. If you're going to experiment with outputting an html file, I have a suggestion: I would like to be able to specify the filename in the yml file. In my particular project, I have several yml files to test various interface's scripts. So in one yml file, I would name the rendered html file `admin.html`, and another may be `mobile.html`.
johnbintz commented 2011-10-10 18:13:19 +00:00 (Migrated from github.com)

I've started on this with this commit, which cleaned up a lot of infrastructure to make writing out report files easier and cleaner: 0be7b9e20c

I'll work on the rest of it in the coming days.

I've started on this with this commit, which cleaned up a lot of infrastructure to make writing out report files easier and cleaner: 0be7b9e20c0c995f46736985e7c6be58635fec0d I'll work on the rest of it in the coming days.
johnbintz commented 2011-10-11 12:58:27 +00:00 (Migrated from github.com)

OK you can now define a runner_output value in your jasmine.yml file and get a copy of the runner wherever you specify. You can also override this from the command line with the --runner-out option.

Both of these output a browser-friendly runner, using Jasmine's HtmlReporter. Try it and let me know what you think.

OK you can now define a `runner_output` value in your `jasmine.yml` file and get a copy of the runner wherever you specify. You can also override this from the command line with the `--runner-out` option. Both of these output a browser-friendly runner, using Jasmine's `HtmlReporter`. Try it and let me know what you think.
johnbintz commented 2011-10-17 15:17:00 +00:00 (Migrated from github.com)

Have you had a chance to try this out? If this is working for you, I'm going to end up doing a release today or tomorrow.

Have you had a chance to try this out? If this is working for you, I'm going to end up doing a release today or tomorrow.
deleteme commented 2011-10-17 15:26:37 +00:00 (Migrated from github.com)

Awesome! No, I haven't had a chance yet. It'll probably be the end of the week before I can get to it. Don't wait on me to push out a new release :)

Regardless, I'll let you know how it works out.

Awesome! No, I haven't had a chance yet. It'll probably be the end of the week before I can get to it. Don't wait on me to push out a new release :) Regardless, I'll let you know how it works out.
divoxx commented 2011-11-10 16:27:07 +00:00 (Migrated from github.com)

Quick question: will the runner automatically pickup changes to the specs? Or you need to run it in the terminal to get a static runner?

Cheers,

Quick question: will the runner automatically pickup changes to the specs? Or you need to run it in the terminal to get a static runner? Cheers,
johnbintz commented 2011-11-10 16:29:03 +00:00 (Migrated from github.com)

@divoxx, the command line tool needs to be run in order to generate a new HTML file that contains your specs and Jasmine. Coupling with Guard makes that regeneration process a lot easier.

@divoxx, the command line tool needs to be run in order to generate a new HTML file that contains your specs and Jasmine. Coupling with Guard makes that regeneration process a lot easier.
divoxx commented 2011-11-10 16:32:36 +00:00 (Migrated from github.com)

Cool, thanks for the quick answer ;)

Cool, thanks for the quick answer ;)
johnbintz commented 2011-11-24 16:07:19 +00:00 (Migrated from github.com)

This is working for me, I put it through its paces when testing app conversions to Sprockets, so I'm closing it. Reopen if there's still issues.

This is working for me, I put it through its paces when testing app conversions to Sprockets, so I'm closing it. Reopen if there's still issues.
deleteme commented 2012-01-11 21:07:10 +00:00 (Migrated from github.com)

@johnbintz I gotta say that runner_output works like a charm. Upgrading was easy, and this really is going to be useful. Thank you!

@johnbintz I gotta say that `runner_output` works like a charm. Upgrading was easy, and this really is going to be useful. Thank you!
Sign in to join this conversation.
No Label
bug
doc
feature
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: github-migration/jasmine-headless-webkit#66
No description provided.