What does the “it” function do in this code?

后端 未结 2 1325
一个人的身影
一个人的身影 2021-01-31 14:35

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

相关标签:
2条回答
  • 2021-01-31 15:16

    So 'it' is referring to when you're testing your application, and only when you're testing. The point of testing is that you can have the test runner automate a bunch of the regular tasks your users would normally do then validate all the responses/events from those tasks work correctly. What your code is saying is that your test 'should check ng-show/ng-hide' and validate that they're working properly. You'll only see 'it' used in test runner like Karma or Jasmine.

    0 讨论(0)
  • 2021-01-31 15:29

    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);
      });
    });
    

    Note that AngularJS E2E Testing...

    ... uses Jasmine for its test syntax.

    0 讨论(0)
提交回复
热议问题