“它"是什么意思?这段代码中的功能是什么?
我希望有人可以向我解释它"在 AngularJS 或纯 JavaScript 中的作用(用于)什么(我不确定它是否特定于 Angular).事实证明,这对谷歌来说是一件困难的事情,被命名为它"等等.我已经看到它在整个 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(...)
函数定义了一个测试用例(又名规范").
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.
相关文章