Skip to content

Latest commit

 

History

History
61 lines (48 loc) · 1.15 KB

prefer-jasmine-matcher.md

File metadata and controls

61 lines (48 loc) · 1.15 KB

Enforce jasmine matchers are used instead of comparison within expect (prefer-jasmine-matcher).

This rule enforces that within expect jasmine matchers are used instead of comparison operators such as ===, ==, !==, !=, >, <, >=, <=. Standard jasmine matcher include : toEqual, toBe, toBeLessThan, toBeGreaterThan, toThrowError, toContain, toBeNull, toBeUndefined etc.

Rule details

This rule triggers a warning (is set to 1 by default).

The following patterns are considered a warning:

describe("", function() {
  it("", function() {
    var a = 1;
    expect(a > 0).toBe(true);
  });
});
describe("", function() {
  it("", function() {
    var a = "abc";
    expect(a.length === 3).toBe(true);
  });
});

The following patterns are not warnings:

describe("", function() {
  it("", function() {
    var a = false;
    expect(a).not.toBe(true);
  });
});
describe("", function() {
  it("", function() {
    var a = "abc";
    expect(a.length).toBe(3);
  });
});
describe("", function() {
  it("", function() {
    var a = 1;

    expect(a).toBeGreaterThan(0);
  });
});