Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there something like a jasmine `toNotContain` acceptance criteria for tests?

Jasmin comes with many functions for checking the expected values for validating specifications and tests.

Is there besides

getJasmineRequireObj().toContain = function() { ... }; 

somthing like a

getJasmineRequireObj().toNotContain = function() { ... }; 

?

If not, how to add an extension or plugin to deliver this feature also to our community of developers?

like image 247
Michael Czechowski Avatar asked May 27 '16 12:05

Michael Czechowski


People also ask

Which matter is used in Jasmine to check whether the result is equal to true or false?

Perhaps the simplest matcher in Jasmine is toEqual . It simply checks if two things are equal (and not necessarily the same exact object, as you'll see in Chapter 5).

What is ToBeTruthy Jasmine?

ToBeTruthy() This Boolean matcher is used in Jasmine to check whether the result is equal to true or false.

Why is Jasmine tested?

Jasmine follows Behavior Driven Development (BDD) procedure to ensure that each line of JavaScript statement is properly unit tested. By following BDD procedure, Jasmine provides a small syntax to test the smallest unit of the entire application instead of testing it as a whole.

Which of the following Jasmine matchers can be used for matching a regular expression?

It checks whether something is matched for a regular expression. You can use the toMatch matcher to test search patterns.


1 Answers

According to the documentation, you can use not:

getJasmineRequireObj().not.toContain 

This example is from here:

describe("The 'toBe' matcher compares with ===", function() { 

Matchers

Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.

    it("and has a positive case", function() {         expect(true).toBe(true);     }); 

Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.

    it("and can have a negative case", function() {         expect(false).not.toBe(true);     }); }); 
like image 70
meskobalazs Avatar answered Sep 28 '22 18:09

meskobalazs