Run only a specific test?

72 views
Skip to first unread message

Jason Hihn

unread,
Mar 30, 2015, 7:46:00 PM3/30/15
to jasmi...@googlegroups.com
In Test Driven Development, you write the tests first.
And since I am writing code for node.js, I would like to write the backend function (without the route handler) and test it. I was hoping then that I could use jasmine to be an archive of these functions. However, I wish only to run a specific function (test) at a time.
given:
 describe("A" function () { it("test1", function ()...)} )};

if I could run `jasmine A/test1` then that would be awesome because I could use the test harness as part of my development process. The only thing we would be missing is the req, resp and variable marshaling, which is pretty trivial. We could then get that via a actual HTTP request, but for engineering purposes I'm not conserned.

So is there a way to, given a complete test suite, invoke only a specific test? I know about xdescribe() and xit(), but I don't want to have to modify the test suite to test a specific function. 

Thanks

Greg Cobb

unread,
Mar 30, 2015, 7:48:02 PM3/30/15
to jasmi...@googlegroups.com
I believe you are looking for 'fit' and 'fdescribe.' They will focus Jasmine on a given spec/ suite.
--
You received this message because you are subscribed to the Google Groups "Jasmine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jasmine-js+...@googlegroups.com.
To post to this group, send email to jasmi...@googlegroups.com.
Visit this group at http://groups.google.com/group/jasmine-js.
For more options, visit https://groups.google.com/d/optout.

Jasper Blues

unread,
Mar 30, 2015, 7:50:16 PM3/30/15
to jasmi...@googlegroups.com
Does it cause the whole test suite to return a failing state, to prevent you from forgetting to unfocus when done? In the absence of using a specific IDE/tool that supports running a single test, this is a nice solution. 

Greg Cobb

unread,
Mar 31, 2015, 10:58:49 AM3/31/15
to jasmi...@googlegroups.com
They do not currently fail the build, but that seems like a reasonable feature request.

Also, if you are building your own test harness, you may be able to use Env.specFilter to focus on a specific spec/ suite. This is what the HTMLReporter uses to focus on a test when you click on it.

Gregg Van Hove

unread,
Mar 31, 2015, 11:07:02 AM3/31/15
to jasmi...@googlegroups.com
If you're using the jasmine npm, there is a `--filter` option coming in the next release that will let you filter by full description of specs and suites. This is on master if you want to try it out.

- Gregg

Jason Hihn

unread,
Mar 31, 2015, 11:41:03 AM3/31/15
to jasmi...@googlegroups.com
I don't see how this is supposed to work. I read the brief documentation. It looks like I need to re-write the test in a f* block?


On Monday, March 30, 2015 at 7:48:02 PM UTC-4, Greg Cobb wrote:
I believe you are looking for 'fit' and 'fdescribe.' They will focus Jasmine on a given spec/ suite.

On Monday, March 30, 2015, Jason Hihn <jaso...@gmail.com> wrote:
In Test Driven Development, you write the tests first.
And since I am writing code for node.js, I would like to write the backend function (without the route handler) and test it. I was hoping then that I could use jasmine to be an archive of these functions. However, I wish only to run a specific function (test) at a time.
given:
 describe("A" function () { it("test1", function ()...)} )};

if I could run `jasmine A/test1` then that would be awesome because I could use the test harness as part of my development process. The only thing we would be missing is the req, resp and variable marshaling, which is pretty trivial. We could then get that via a actual HTTP request, but for engineering purposes I'm not conserned.

So is there a way to, given a complete test suite, invoke only a specific test? I know about xdescribe() and xit(), but I don't want to have to modify the test suite to test a specific function. 

Thanks

--
You received this message because you are subscribed to the Google Groups "Jasmine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jasmine-js+unsubscribe@googlegroups.com.

Jason Hihn

unread,
Mar 31, 2015, 11:42:06 AM3/31/15
to jasmi...@googlegroups.com
This sounds like what I want. Where is it documented so that I know how to try it?

Thanks!

Ivan Rodriguez

unread,
Mar 31, 2015, 3:07:17 PM3/31/15
to jasmi...@googlegroups.com

You can use iit() for specific test and ddescribe() for specific test suite

Greg Cobb

unread,
Mar 31, 2015, 3:15:45 PM3/31/15
to jasmi...@googlegroups.com
'iit' and 'ddescribe' are not part of core jasmine. I believe most extensions of Jasmine using this syntax have moved to 'fit' and 'fdescribe'.

Jason Hihn

unread,
Apr 7, 2015, 10:11:32 AM4/7/15
to jasmi...@googlegroups.com
I'm bumpting this since I was not able to find documentation on this feature. I assume it should be available in edge?

Greg Cobb

unread,
Apr 7, 2015, 3:24:25 PM4/7/15
to jasmi...@googlegroups.com
Here is the PR that implemented the feature: https://github.com/jasmine/jasmine-npm/pull/35.  This should be added to the docs before 2.3 is released.

Reply all
Reply to author
Forward
0 new messages