In the Angular documentation they write this:
expect(scope.counter).toEqual(0);
and this was written in many places like here.
I just want to know what it does
Simply put you can use $q. defer() to create a Promise. A Promise is a function that returns a single value or error in the future. So whenever you have some asynchronous process that should return a value or an error, you can use $q. defer() to create a new Promise.
Promises in AngularJS are provided by the built-in $q service. They provide a way to execute asynchronous functions in series by registering them with a promise object. {info} Promises have made their way into native JavaScript as part of the ES6 specification.
describe defines a test suite, and it defines a "spec" or a test. From the Jasmine documentation: A test suite begins with a call to the global Jasmine function describe with two parameters: a string and a function. The string is a name or title for a spec suite - usually what is under test.
This is Jasmine unit testing framework syntax for unit tests. Angular uses, promotes and encourages unit testing practices.
Testability is taken very seriously in AngularJS and the authors of the framework make sure that code written using AngularJS is easy to test:
AngularJS has also a solution for higher-level, end-to-end testing. E2e tests use a very similar syntax (so you will also notice the expect
keyword) but those are not Jasmine tests. More info can be found here: https://stackoverflow.com/a/13213262/1418796
Here is the documentation for expect
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With