Jasmine 문법
1810 단어 ASM
describe('My Function', function() {
var t;
//Similar to setup
beforeEach(function() {
t = true;
});
afterEach(function() {
t = null;
});
it('should perform action 1', function() {
expect(t).toBeTruthy();
});
it('should perform action 2', function() {
var expectedValue = true;
expect(t).toEqual(expectedValue);
});
});
Useful Jasmine Matcher
toEqual:
takes a second value and does a deep equality check between the two objects. In the case of an object, all the fields have to match. In the case of an array, all the array elements have to match.
toBe:
checks for reference, and expects both items passed to the expect and the matcher to be the exact same object reference.
toBeTruthy
toBeFalsy
toBeDefined
toBeUndefined
toBeNull
toBeNaN
toBeGreaterThan
toBeLessThan
toBeCloseTo
toContain:
Checks if the array passed to the expect contains the element passed to the matcher.
toMatch:
Used for regular expression checks when the first argument to the expect is a string that needs to match a specific regular expression pattern.
toThrow
toHaveBeenCalled
toHaveBeenCalledWith
not:
.not.toEqual
.not.toContain:
spyOn
beforeEach
afterEach
x
jasmine.any
expect(rand()).toEqual(jasmine.any(Number));
expect('Hello World").toEqual(jasmine.any(String));
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Why does there exist DB_UNKNOWN directory on ASM disk?Today I found a glitch about my database instance.When I browsed my files on ASM disks,I found this file,which path was ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.