問題描述
我希望有人可以向我解釋它"在 AngularJS 或純 JavaScript 中的作用(用于)什么(我不確定它是否特定于 Angular).事實證明,這對谷歌來說是一件困難的事情,被命名為它"等等.我已經(jīng)看到它在整個 AngularJS 文檔中使用.我會給你一個來自 ngShow 頁面的例子(它是隱藏/顯示包含大拇指或大拇指向下).
I'm hoping somebody could explain to me what "it" does (is used for) in AngularJS or just plain JavaScript (I'm not sure if it's specific to Angular). This, turns out, is a difficult thing to Google for, being named "it" and all. I've seen it used throughout the AngularJS docs. I'll give you an example from the ngShow page (it's code to hide/show a div containing a thumbs up or thumbs down).
var thumbsUp = element(by.css('span.glyphicon-thumbs-up'));
var thumbsDown = element(by.css('span.glyphicon-thumbs-down'));
it('should check ng-show / ng-hide', function() {
expect(thumbsUp.isDisplayed()).toBeFalsy();
expect(thumbsDown.isDisplayed()).toBeTruthy();
element(by.model('checked')).click();
expect(thumbsUp.isDisplayed()).toBeTruthy();
expect(thumbsDown.isDisplayed()).toBeFalsy();
});
推薦答案
參見 Jasmine 測試框架.
it(...)
函數(shù)定義了一個測試用例(又名規(guī)范").
See the Jasmine testing framework.
The it(...)
function defines a test case (aka a "spec").
describe("A suite", function() {
it("contains spec with an expectation", function() {
expect(true).toBe(true);
});
});
請注意,AngularJS E2E 測試...
... 使用 Jasmine 作為其測試語法.
... uses Jasmine for its test syntax.
這篇關(guān)于“它"是什么意思?這段代碼中的功能是什么?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!