Check out our Angular Book Series.

How do I tell Jasmine to ignore a test?

Today I learned you can tell Jasmine to ignore a unit test. A normal unit test would be something like this:


it("True is True", () =>
{
expect("True").toBe("True");
});

When running a unit test file with this inside the test will run., You could comment it out if you wish, but that can get confusing for larger unit tests with embedded oomments. Instead you can use xit() instead of it():


xit("True is True", () =>
{
expect("True").toBe("True");
});

Now when you run your unit test, this test will be marked as viewed as pending and will not be run.

You can use the same thing to disable a full suite with describe():


xdescribe("Some Test Suite"()=>
{
it("True is True", () =>{
expect("True").toBe("True");
});
});

This is pretty handy, but something I overlooked when learning all about unit testing.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
All Content Copyright 2005, 2006, 2007, 2008, 2009 Jeffry Houser. May not be reused without permission
BlogCFC was created by Raymond Camden. This blog is running version 5.9.2.002.