Reputation: 21730
One of the developers on our team (me) keeps accidentally checking in fdescribe
and fit
in Jasmine tests. Which sometimes results in masking broken tests.
Is there an easy way to either fail a build (TFS) if fdescribe
is used, or (better?) configure jasmine server side to treat fdescribe
(and fit
) as regular describe
(and it
)?
I would rather use those then fall back to ?spec
approach.
I also would like to take this opportunity to apologize for doing that.
Upvotes: 4
Views: 2170
Reputation: 13309
If you actually want to make fit
and fdescribe
behave like it
and describe
respectively, you can override one with the other in a separate file and insert it before your actual specs (how to insert depends on your test runner):
// assuming Jasmine is already loaded and has published it's public API
fit = it;
fdescribe = describe;
But I would not suggest to use this approach, because if you really want to focus some spec, you'd have to comment these things or exclude the file from a runner. I would rather add this as another step for the build process, if you have one, or pre-commit hook, which would run some tool, like @alecxe has suggested, analyzing the code for existing fit
and fdescribe
and fail a build / reject a commit.
Upvotes: 1
Reputation: 473833
We've approached it with static code analysis and eslint
.
There is a specific plugin: eslint-plugin-jasmine
, see:
Sample output:
test/e2e/specs/test.spec.js
5:0 error Unexpected fdescribe jasmine/no-focused-tests
Currently, the plugin also checks for disabled tests and duplicate suite names.
Upvotes: 4