Skip to content

Instantly share code, notes, and snippets.

@tatsuro-ueda
Created December 11, 2012 00:53
Show Gist options
  • Save tatsuro-ueda/4254779 to your computer and use it in GitHub Desktop.
Save tatsuro-ueda/4254779 to your computer and use it in GitHub Desktop.
Jasmine Matchers

Jasmine Matchers

「JS開発におけるTDDと自動テストツール利用の勘所 」より引用。

http://www.slideshare.net/KojiNakamura/jstdd

  • notで否定のMatcherとなる
  • expect(x).toEqual(y)
  • expect(x).not.toEqual(y)
  • expect(x).toBe(y)
  • expect(x).toMatch(pattern)
  • expect(x).toBeDefined() toBeは === による等値チェック
  • expect(x).toBeUndefined()
  • expect(x).toBeNull()
  • expect(x).toBeNaN()
  • expect(x).toBeTruthy()
  • expect(x).toBeFalsy()
  • expect(x).toContain(y)
  • expect(x).toBeLessThan(y)
  • expect(x).toBeGreaterThan(y)
  • expect(x).toBeCloseTo(y, precision)
  • expect(function(){fn();}).toThrow(e)
  • expect(spy).toHaveBeenCalled()
  • expect(spy).toHaveBeenCalledWith(arguments)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment