Get group name from within the test file

7 views
Skip to first unread message

Gabriel Castillo

unread,
Mar 20, 2014, 3:49:26 PM3/20/14
to bust...@googlegroups.com
Is there a way to detect which test group is running from within my test so that I can then determine if I should skip some tests?

TLDR;

I might be going about this this the wrong way, so I'd be open to a better way of doing things if there is one.

Basically, I have 2 test groups: one runs on the pre-built file, the other runs on the post-built [minified] file.

There are a few WIP files in the pre-built group that are being tested, however, I don't want them in my post-built file.  During the build phase, these files do not get added to the post-built file and during the test phase, I do not load the test file that relate to these WIP files.

My problem is that there are a couple of tests scattered around some of my other files that break if the WIP files are not loaded.

Is there a way to detect which test group is running from within my test so that I can then determine if I should skip some tests?

From within a test file, I'm imagining something like:

if (buster.group.name === 'development') {
     // do stuff
}

Christian Johansen

unread,
Mar 21, 2014, 4:06:05 AM3/21/14
to bust...@googlegroups.com
I'm sure if I completely understand your setup, but the short answer is "no". At least not for now. I also suspect you could solve this in a better way.

Groups can have individual file sets, so I suspect your problem is that you're either sharing test file configuration between the groups when you really shouldn't, or that your glob patterns are too greedy. A dev/compiled setup might look like this:

var config = module.exports;

config.development = {
    sources: ["src/*.js", "wip/*.js"],
    tests: ["test/*.js"]
};

config.production = {
    sources: ["dist/*.min.js", "wip/*.js"],
    tests: ["test/*.js"]
};

In other words: Use the configuration to filter what tests get loaded, don't load tests you don't want to run and then filter them out.

Christian


--
You received this message because you are subscribed to the Google Groups "Buster.JS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to busterjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages