<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Sngala</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Sngala"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Sngala"/>
	<updated>2026-05-22T10:01:59Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91773</id>
		<title>CSC/ECE 517 Fall 2014/final design doc M1451 hsss</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91773"/>
		<updated>2014-11-11T22:58:32Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Design patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains details on the planned course of actions for the project on [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project is about implementing a protocol to define rules regarding the nature of data being sent/receive between the web page and the server built on a Mozilla Framework. We started by creating a WebSocket interface and its corresponding Rust implementation. The constructor of this interface returns a WebSocket object which will help us in establishing a basic HTTP connection to the server. Thereafter we plan to implement methods like close, open on the API along with the onopen and onclose events. &lt;br /&gt;
&lt;br /&gt;
This WebSocket interface runs on a Servo engine. It is basically a prototype web browser engine written in the Rust language. It is currently developed on 64bit OS X and 64bit Linux. Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a&lt;br /&gt;
solid, embedded engine.&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/WebSocket-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
1. The initial step required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Then we had to build the rust compiler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. To build the servo, we cloned the source code into the local repository.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Then we created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/comms.html&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
9. After making all the changes we build are changes into servo. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
10. This was Part One of our project, which was a part of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
11. Part Two is our final project and is an extension of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
12. Now we will create a constructor which will return an WebSocket object and initiate a basic connection with the server. There are couple of sub parts we will need here:&lt;br /&gt;
*A ws scheme protocol handler (just as we have an http scheme protocol handler) that will implement the WS-specific parts of the connection process.&lt;br /&gt;
&lt;br /&gt;
*The ws protocol load method should transparently delegate the initial HTTP connection to http_loader::factory(); this way we do not need to duplicate the HTTP protocol code.&lt;br /&gt;
&lt;br /&gt;
*Using the same technique as the MIME sniffing project, the WS load method should intercept the response from the HTTP load. This will allow us to look at the HTTP response and verify the presence of the required Upgrade header as described in the spec before sending the connection results to the WebSocket implementation&lt;br /&gt;
&lt;br /&gt;
13. In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
14. We have to implement closing of connection along with on open and inclose events. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
15. Furthermore, we have to implement sending simple short strings that fit within a single frame, receiving simple data and sending fragmented payloads across multiple frames.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Singleton Pattern ===&lt;br /&gt;
We are using &amp;quot;Singleton Pattern&amp;quot; because it will confine the instantiation of class 'WebSocket' to only one object. This ensures that the instance can be accessed from everywhere and hence provide a global point of access.&lt;br /&gt;
&lt;br /&gt;
=== Adapter Pattern ===&lt;br /&gt;
We are using &amp;quot;Adapter Pattern&amp;quot; to convert the interface of class 'WebSocket' into another interface that the caller expects. &amp;quot;Adapter pattern&amp;quot; allows other classes with incompatible interfaces to work together with class 'WebSocket', which is solely responsible to enable Web applications to maintain bidirectional communications with server-side processes.&lt;br /&gt;
&lt;br /&gt;
== UML diagrams (Eg use case diagram, class diagrams) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91772</id>
		<title>CSC/ECE 517 Fall 2014/final design doc M1451 hsss</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91772"/>
		<updated>2014-11-11T22:58:05Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Adapter Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains details on the planned course of actions for the project on [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project is about implementing a protocol to define rules regarding the nature of data being sent/receive between the web page and the server built on a Mozilla Framework. We started by creating a WebSocket interface and its corresponding Rust implementation. The constructor of this interface returns a WebSocket object which will help us in establishing a basic HTTP connection to the server. Thereafter we plan to implement methods like close, open on the API along with the onopen and onclose events. &lt;br /&gt;
&lt;br /&gt;
This WebSocket interface runs on a Servo engine. It is basically a prototype web browser engine written in the Rust language. It is currently developed on 64bit OS X and 64bit Linux. Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a&lt;br /&gt;
solid, embedded engine.&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/WebSocket-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
1. The initial step required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Then we had to build the rust compiler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. To build the servo, we cloned the source code into the local repository.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Then we created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/comms.html&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
9. After making all the changes we build are changes into servo. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
10. This was Part One of our project, which was a part of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
11. Part Two is our final project and is an extension of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
12. Now we will create a constructor which will return an WebSocket object and initiate a basic connection with the server. There are couple of sub parts we will need here:&lt;br /&gt;
*A ws scheme protocol handler (just as we have an http scheme protocol handler) that will implement the WS-specific parts of the connection process.&lt;br /&gt;
&lt;br /&gt;
*The ws protocol load method should transparently delegate the initial HTTP connection to http_loader::factory(); this way we do not need to duplicate the HTTP protocol code.&lt;br /&gt;
&lt;br /&gt;
*Using the same technique as the MIME sniffing project, the WS load method should intercept the response from the HTTP load. This will allow us to look at the HTTP response and verify the presence of the required Upgrade header as described in the spec before sending the connection results to the WebSocket implementation&lt;br /&gt;
&lt;br /&gt;
13. In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
14. We have to implement closing of connection along with on open and inclose events. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
15. Furthermore, we have to implement sending simple short strings that fit within a single frame, receiving simple data and sending fragmented payloads across multiple frames.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Singleton Pattern ===&lt;br /&gt;
We are using &amp;quot;Singleton Pattern&amp;quot; because it will confine the instantiation of class ' WebSocket ' to only one object. This ensures that the instance can be accessed from everywhere and hence provide a global point of access.&lt;br /&gt;
&lt;br /&gt;
=== Adapter Pattern ===&lt;br /&gt;
We are using &amp;quot;Adapter Pattern&amp;quot; to convert the interface of class ' WebSocket ' into another interface that the caller expects. &amp;quot;Adapter pattern&amp;quot; allows other classes with incompatible interfaces to work together with class ' WebSocket ', which is solely responsible to enable Web applications to maintain bidirectional communications with server-side processes.&lt;br /&gt;
&lt;br /&gt;
== UML diagrams (Eg use case diagram, class diagrams) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91771</id>
		<title>CSC/ECE 517 Fall 2014/final design doc M1451 hsss</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91771"/>
		<updated>2014-11-11T22:57:29Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Adaptor Pattern */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains details on the planned course of actions for the project on [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project is about implementing a protocol to define rules regarding the nature of data being sent/receive between the web page and the server built on a Mozilla Framework. We started by creating a WebSocket interface and its corresponding Rust implementation. The constructor of this interface returns a WebSocket object which will help us in establishing a basic HTTP connection to the server. Thereafter we plan to implement methods like close, open on the API along with the onopen and onclose events. &lt;br /&gt;
&lt;br /&gt;
This WebSocket interface runs on a Servo engine. It is basically a prototype web browser engine written in the Rust language. It is currently developed on 64bit OS X and 64bit Linux. Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a&lt;br /&gt;
solid, embedded engine.&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/WebSocket-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
1. The initial step required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Then we had to build the rust compiler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. To build the servo, we cloned the source code into the local repository.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Then we created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/comms.html&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
9. After making all the changes we build are changes into servo. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
10. This was Part One of our project, which was a part of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
11. Part Two is our final project and is an extension of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
12. Now we will create a constructor which will return an WebSocket object and initiate a basic connection with the server. There are couple of sub parts we will need here:&lt;br /&gt;
*A ws scheme protocol handler (just as we have an http scheme protocol handler) that will implement the WS-specific parts of the connection process.&lt;br /&gt;
&lt;br /&gt;
*The ws protocol load method should transparently delegate the initial HTTP connection to http_loader::factory(); this way we do not need to duplicate the HTTP protocol code.&lt;br /&gt;
&lt;br /&gt;
*Using the same technique as the MIME sniffing project, the WS load method should intercept the response from the HTTP load. This will allow us to look at the HTTP response and verify the presence of the required Upgrade header as described in the spec before sending the connection results to the WebSocket implementation&lt;br /&gt;
&lt;br /&gt;
13. In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
14. We have to implement closing of connection along with on open and inclose events. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
15. Furthermore, we have to implement sending simple short strings that fit within a single frame, receiving simple data and sending fragmented payloads across multiple frames.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Singleton Pattern ===&lt;br /&gt;
We are using &amp;quot;Singleton Pattern&amp;quot; because it will confine the instantiation of class ' WebSocket ' to only one object. This ensures that the instance can be accessed from everywhere and hence provide a global point of access.&lt;br /&gt;
&lt;br /&gt;
=== Adapter Pattern ===&lt;br /&gt;
We are using &amp;quot; Adapter Pattern &amp;quot; to convert the interface of class ' WebSocket ' into another interface that the caller expects. &amp;quot; Adapter pattern &amp;quot; allows other classes with incompatible interfaces to work together with class ' WebSocket ', which is solely responsible to enable Web applications to maintain bidirectional communications with server-side processes.&lt;br /&gt;
&lt;br /&gt;
== UML diagrams (Eg use case diagram, class diagrams) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91770</id>
		<title>CSC/ECE 517 Fall 2014/final design doc M1451 hsss</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91770"/>
		<updated>2014-11-11T22:46:55Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Design patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains details on the planned course of actions for the project on [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project is about implementing a protocol to define rules regarding the nature of data being sent/receive between the web page and the server built on a Mozilla Framework. We started by creating a WebSocket interface and its corresponding Rust implementation. The constructor of this interface returns a WebSocket object which will help us in establishing a basic HTTP connection to the server. Thereafter we plan to implement methods like close, open on the API along with the onopen and onclose events. &lt;br /&gt;
&lt;br /&gt;
This WebSocket interface runs on a Servo engine. It is basically a prototype web browser engine written in the Rust language. It is currently developed on 64bit OS X and 64bit Linux. Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a&lt;br /&gt;
solid, embedded engine.&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/WebSocket-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
1. The initial step required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Then we had to build the rust compiler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. To build the servo, we cloned the source code into the local repository.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Then we created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/comms.html&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
9. After making all the changes we build are changes into servo. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
10. This was Part One of our project, which was a part of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
11. Part Two is our final project and is an extension of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
12. Now we will create a constructor which will return an WebSocket object and initiate a basic connection with the server. There are couple of sub parts we will need here:&lt;br /&gt;
*A ws scheme protocol handler (just as we have an http scheme protocol handler) that will implement the WS-specific parts of the connection process.&lt;br /&gt;
&lt;br /&gt;
*The ws protocol load method should transparently delegate the initial HTTP connection to http_loader::factory(); this way we do not need to duplicate the HTTP protocol code.&lt;br /&gt;
&lt;br /&gt;
*Using the same technique as the MIME sniffing project, the WS load method should intercept the response from the HTTP load. This will allow us to look at the HTTP response and verify the presence of the required Upgrade header as described in the spec before sending the connection results to the WebSocket implementation&lt;br /&gt;
&lt;br /&gt;
13. In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
14. We have to implement closing of connection along with on open and inclose events. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
15. Furthermore, we have to implement sending simple short strings that fit within a single frame, receiving simple data and sending fragmented payloads across multiple frames.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Singleton Pattern ===&lt;br /&gt;
We are using &amp;quot;Singleton Pattern&amp;quot; because it will confine the instantiation of class ' WebSocket ' to only one object. This ensures that the instance can be accessed from everywhere and hence provide a global point of access.&lt;br /&gt;
&lt;br /&gt;
=== Adaptor Pattern ===&lt;br /&gt;
We are using &amp;quot;Adaptor Pattern&amp;quot; to convert the interface of class ' WebSocket ' into another interface that the caller expects. Adaptor pattern allows other classes with incompatible interfaces to work together with class ' WebSocket ', which is solely responsible to enable Web applications to maintain bidirectional communications with server-side processes.&lt;br /&gt;
&lt;br /&gt;
== UML diagrams (Eg use case diagram, class diagrams) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91769</id>
		<title>CSC/ECE 517 Fall 2014/final design doc M1451 hsss</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91769"/>
		<updated>2014-11-11T22:44:34Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Design patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains details on the planned course of actions for the project on [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project is about implementing a protocol to define rules regarding the nature of data being sent/receive between the web page and the server built on a Mozilla Framework. We started by creating a WebSocket interface and its corresponding Rust implementation. The constructor of this interface returns a WebSocket object which will help us in establishing a basic HTTP connection to the server. Thereafter we plan to implement methods like close, open on the API along with the onopen and onclose events. &lt;br /&gt;
&lt;br /&gt;
This WebSocket interface runs on a Servo engine. It is basically a prototype web browser engine written in the Rust language. It is currently developed on 64bit OS X and 64bit Linux. Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a&lt;br /&gt;
solid, embedded engine.&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/WebSocket-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
1. The initial step required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Then we had to build the rust compiler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. To build the servo, we cloned the source code into the local repository.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Then we created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/comms.html&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
9. After making all the changes we build are changes into servo. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
10. This was Part One of our project, which was a part of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
11. Part Two is our final project and is an extension of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
12. Now we will create a constructor which will return an WebSocket object and initiate a basic connection with the server. There are couple of sub parts we will need here:&lt;br /&gt;
*A ws scheme protocol handler (just as we have an http scheme protocol handler) that will implement the WS-specific parts of the connection process.&lt;br /&gt;
&lt;br /&gt;
*The ws protocol load method should transparently delegate the initial HTTP connection to http_loader::factory(); this way we do not need to duplicate the HTTP protocol code.&lt;br /&gt;
&lt;br /&gt;
*Using the same technique as the MIME sniffing project, the WS load method should intercept the response from the HTTP load. This will allow us to look at the HTTP response and verify the presence of the required Upgrade header as described in the spec before sending the connection results to the WebSocket implementation&lt;br /&gt;
&lt;br /&gt;
13. In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
14. We have to implement closing of connection along with on open and inclose events. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
15. Furthermore, we have to implement sending simple short strings that fit within a single frame, receiving simple data and sending fragmented payloads across multiple frames.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Singleton Pattern ===&lt;br /&gt;
We are using &amp;quot;Singleton Pattern&amp;quot; because it will confine the instantiation of class 'WebSocket' to only one object. This ensures that the instance can be accessed from everywhere and hence provide a global point of access.&lt;br /&gt;
&lt;br /&gt;
=== Adaptor Pattern ===&lt;br /&gt;
We are using &amp;quot;Adaptor Pattern&amp;quot; to convert the interface of class 'WebSocket' into another interface that the caller expects. Adaptor pattern allows other classes with incompatible interfaces to work together with class 'WebSocket', which is solely responsible to enable Web applications to maintain bidirectional communications with server-side processes.&lt;br /&gt;
&lt;br /&gt;
== UML diagrams (Eg use case diagram, class diagrams) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91768</id>
		<title>CSC/ECE 517 Fall 2014/final design doc M1451 hsss</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91768"/>
		<updated>2014-11-11T22:40:42Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Design patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains details on the planned course of actions for the project on [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project is about implementing a protocol to define rules regarding the nature of data being sent/receive between the web page and the server built on a Mozilla Framework. We started by creating a WebSocket interface and its corresponding Rust implementation. The constructor of this interface returns a WebSocket object which will help us in establishing a basic HTTP connection to the server. Thereafter we plan to implement methods like close, open on the API along with the onopen and onclose events. &lt;br /&gt;
&lt;br /&gt;
This WebSocket interface runs on a Servo engine. It is basically a prototype web browser engine written in the Rust language. It is currently developed on 64bit OS X and 64bit Linux. Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a&lt;br /&gt;
solid, embedded engine.&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/WebSocket-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
1. The initial step required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Then we had to build the rust compiler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. To build the servo, we cloned the source code into the local repository.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Then we created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/comms.html&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
9. After making all the changes we build are changes into servo. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
10. This was Part One of our project, which was a part of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
11. Part Two is our final project and is an extension of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
12. Now we will create a constructor which will return an WebSocket object and initiate a basic connection with the server. There are couple of sub parts we will need here:&lt;br /&gt;
*A ws scheme protocol handler (just as we have an http scheme protocol handler) that will implement the WS-specific parts of the connection process.&lt;br /&gt;
&lt;br /&gt;
*The ws protocol load method should transparently delegate the initial HTTP connection to http_loader::factory(); this way we do not need to duplicate the HTTP protocol code.&lt;br /&gt;
&lt;br /&gt;
*Using the same technique as the MIME sniffing project, the WS load method should intercept the response from the HTTP load. This will allow us to look at the HTTP response and verify the presence of the required Upgrade header as described in the spec before sending the connection results to the WebSocket implementation&lt;br /&gt;
&lt;br /&gt;
13. In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
14. We have to implement closing of connection along with on open and inclose events. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
15. Furthermore, we have to implement sending simple short strings that fit within a single frame, receiving simple data and sending fragmented payloads across multiple frames.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
'''Singleton Pattern'''&lt;br /&gt;
&lt;br /&gt;
We are using &amp;quot;Singleton Pattern&amp;quot; because it will confine the instantiation of class 'WebSocket' to only one object. This ensures that the instance can be accessed from everywhere and hence provide a global point of access.&lt;br /&gt;
&lt;br /&gt;
'''Adaptor Pattern'''&lt;br /&gt;
&lt;br /&gt;
We are using &amp;quot;Adaptor Pattern&amp;quot; to convert the interface of class 'WebSocket' into another interface that the caller expects. Using adaptor pattern allows other classes with incompatible interfaces work together with class 'WebSocket'.&lt;br /&gt;
&lt;br /&gt;
== UML diagrams (Eg use case diagram, class diagrams) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91767</id>
		<title>CSC/ECE 517 Fall 2014/final design doc M1451 hsss</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91767"/>
		<updated>2014-11-11T22:40:17Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Design patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains details on the planned course of actions for the project on [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project is about implementing a protocol to define rules regarding the nature of data being sent/receive between the web page and the server built on a Mozilla Framework. We started by creating a WebSocket interface and its corresponding Rust implementation. The constructor of this interface returns a WebSocket object which will help us in establishing a basic HTTP connection to the server. Thereafter we plan to implement methods like close, open on the API along with the onopen and onclose events. &lt;br /&gt;
&lt;br /&gt;
This WebSocket interface runs on a Servo engine. It is basically a prototype web browser engine written in the Rust language. It is currently developed on 64bit OS X and 64bit Linux. Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a&lt;br /&gt;
solid, embedded engine.&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/WebSocket-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
1. The initial step required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Then we had to build the rust compiler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. To build the servo, we cloned the source code into the local repository.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Then we created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/comms.html&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
9. After making all the changes we build are changes into servo. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
10. This was Part One of our project, which was a part of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
11. Part Two is our final project and is an extension of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
12. Now we will create a constructor which will return an WebSocket object and initiate a basic connection with the server. There are couple of sub parts we will need here:&lt;br /&gt;
*A ws scheme protocol handler (just as we have an http scheme protocol handler) that will implement the WS-specific parts of the connection process.&lt;br /&gt;
&lt;br /&gt;
*The ws protocol load method should transparently delegate the initial HTTP connection to http_loader::factory(); this way we do not need to duplicate the HTTP protocol code.&lt;br /&gt;
&lt;br /&gt;
*Using the same technique as the MIME sniffing project, the WS load method should intercept the response from the HTTP load. This will allow us to look at the HTTP response and verify the presence of the required Upgrade header as described in the spec before sending the connection results to the WebSocket implementation&lt;br /&gt;
&lt;br /&gt;
13. In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
14. We have to implement closing of connection along with on open and inclose events. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
15. Furthermore, we have to implement sending simple short strings that fit within a single frame, receiving simple data and sending fragmented payloads across multiple frames.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
'''Singleton Pattern'''&lt;br /&gt;
We are using &amp;quot;Singleton Pattern&amp;quot; because it will confine the instantiation of class 'WebSocket' to only one object. This ensures that the instance can be accessed from everywhere and hence provide a global point of access.&lt;br /&gt;
&lt;br /&gt;
'''Adaptor Pattern'''&lt;br /&gt;
We are using &amp;quot;Adaptor Pattern&amp;quot; to convert the interface of class 'WebSocket' into another interface that the caller expects. Using adaptor pattern allows other classes with incompatible interfaces work together with class 'WebSocket'.&lt;br /&gt;
&lt;br /&gt;
== UML diagrams (Eg use case diagram, class diagrams) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91766</id>
		<title>CSC/ECE 517 Fall 2014/final design doc M1451 hsss</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/final_design_doc_M1451_hsss&amp;diff=91766"/>
		<updated>2014-11-11T22:39:19Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Design patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains details on the planned course of actions for the project on [https://github.com/servo/servo/wiki/WebSocket-student-project Implement WebSocket API] for the Mozilla research project [http://github.com/servo/servo/wiki/Design Servo].&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This project is about implementing a protocol to define rules regarding the nature of data being sent/receive between the web page and the server built on a Mozilla Framework. We started by creating a WebSocket interface and its corresponding Rust implementation. The constructor of this interface returns a WebSocket object which will help us in establishing a basic HTTP connection to the server. Thereafter we plan to implement methods like close, open on the API along with the onopen and onclose events. &lt;br /&gt;
&lt;br /&gt;
This WebSocket interface runs on a Servo engine. It is basically a prototype web browser engine written in the Rust language. It is currently developed on 64bit OS X and 64bit Linux. Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a&lt;br /&gt;
solid, embedded engine.&lt;br /&gt;
&lt;br /&gt;
== Architecture of system &amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/Design#task-supervision-diagram&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
=== Task Supervision Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskSupervision.png]]&lt;br /&gt;
&lt;br /&gt;
=== Task Communication Diagram ===&lt;br /&gt;
&lt;br /&gt;
[[File:TaskCommunication.png]]&lt;br /&gt;
&lt;br /&gt;
The above diagrams gives us an overview of the Servo's architecture.&lt;br /&gt;
*Each box represents a Rust task.&lt;br /&gt;
*Primary tasks are the ones which are represented by blue boxes.&lt;br /&gt;
*Gray boxes are for auxiliary tasks.&lt;br /&gt;
*White boxes are for worker tasks. Each such box represents several tasks, the precise number of which are decided by the workload.&lt;br /&gt;
*Supervisor relationships are shown by dashed lines.&lt;br /&gt;
*Communication channels are shown by solid lines.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Requirement analysis&amp;lt;ref&amp;gt;https://github.com/servo/servo/wiki/WebSocket-student-project&amp;lt;/ref&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
1. The initial step required downloading and building the Rust compiler. To install Rust on the machine, clone the Rust source code from Mozilla's repository on GitHub.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Then we had to build the rust compiler.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. To build the servo, we cloned the source code into the local repository.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Then we created a WebSocket.webidl file in the /servo/components/script/dom/webidls/ directory. This file was added in order to create a new interface for the web socket.This interface is inherited from the EventTarget interface in servo.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5. We added several attributes and methods to the WebSocket.webidl file which we plan to execute during the course of the project&amp;lt;ref&amp;gt;https://html.spec.whatwg.org/multipage/comms.html&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
6. We created a corresponding websocket.rs file in the /servo/components/script/dom/ directory. In this file we have currently created a constructor that takes a url as an argument. We have a stub function to return the url that is used for initializing the web socket object through the constructor.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
7. We added The WebSocketTypeId to the struct in the eventtarget.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. We added the websocket module that we created to the lib.rs file.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
9. After making all the changes we build are changes into servo. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
10. This was Part One of our project, which was a part of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
11. Part Two is our final project and is an extension of our OSS project.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
12. Now we will create a constructor which will return an WebSocket object and initiate a basic connection with the server. There are couple of sub parts we will need here:&lt;br /&gt;
*A ws scheme protocol handler (just as we have an http scheme protocol handler) that will implement the WS-specific parts of the connection process.&lt;br /&gt;
&lt;br /&gt;
*The ws protocol load method should transparently delegate the initial HTTP connection to http_loader::factory(); this way we do not need to duplicate the HTTP protocol code.&lt;br /&gt;
&lt;br /&gt;
*Using the same technique as the MIME sniffing project, the WS load method should intercept the response from the HTTP load. This will allow us to look at the HTTP response and verify the presence of the required Upgrade header as described in the spec before sending the connection results to the WebSocket implementation&lt;br /&gt;
&lt;br /&gt;
13. In order to allow writing more data to the existing socket connection, we plan to make the stream member in the BufferedResponse in rust-http public. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
14. We have to implement closing of connection along with on open and inclose events. &lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
15. Furthermore, we have to implement sending simple short strings that fit within a single frame, receiving simple data and sending fragmented payloads across multiple frames.&lt;br /&gt;
&lt;br /&gt;
== Data and component design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Design patterns ==&lt;br /&gt;
&lt;br /&gt;
=== Singleton Pattern ===&lt;br /&gt;
We are using &amp;quot;Singleton Pattern&amp;quot; because it will confine the instantiation of class 'WebSocket' to only one object. This ensures that the instance can be accessed from everywhere and hence provide a global point of access.&lt;br /&gt;
&lt;br /&gt;
=== Adaptor Pattern ===&lt;br /&gt;
We are using &amp;quot;Adaptor Pattern&amp;quot; to convert the interface of class 'WebSocket' into another interface that the caller expects. Using adaptor pattern allows other classes with incompatible interfaces work together with class 'WebSocket'.&lt;br /&gt;
&lt;br /&gt;
== UML diagrams (Eg use case diagram, class diagrams) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Proposed Test Cases ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_M1452_jns&amp;diff=89977</id>
		<title>CSC/ECE 517 Fall 2014/oss M1452 jns</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_M1452_jns&amp;diff=89977"/>
		<updated>2014-10-27T19:17:04Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Servo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Integrating an XML Parser =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Background Information =&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla Research. The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are handled by fine-grained, isolated tasks. The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rust ==&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a systems language for writing high performance applications that are usually written in C or C++ but it was developed to prevent some of the problems related to invalid memory accesses that generate segmentation faults. It covers imperative, functional and object-oriented programming.&lt;br /&gt;
It's designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety. &amp;lt;ref name=Rust&amp;gt;[https://www.mozilla.org/en-US/research/projects/ Overview of Mozilla Research Projects]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory. &amp;lt;ref name=Rust&amp;gt;[https://www.mozilla.org/en-US/research/projects/ Overview of Mozilla Research Projects]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo ==&lt;br /&gt;
[https://github.com/servo/servo Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. With Servo, Mozilla are rethinking the browser at every level of the technology stack — from input parsing to page layout to graphics rendering — to optimize for power efficiency and maximum parallelism.&lt;br /&gt;
&lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Memory safety at the core of the platform ensures a high degree of assurance in the browser’s trusted computing base. Rust’s lightweight task mechanism also promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation.&amp;lt;ref name=Rust&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''Task Supervision Diagram''&lt;br /&gt;
&lt;br /&gt;
[[File:Diagram1.jpg]]&lt;br /&gt;
&lt;br /&gt;
''Task Projection Diagram''&lt;br /&gt;
&lt;br /&gt;
[[File:Diagram2.jpg]]&lt;br /&gt;
&lt;br /&gt;
•	'' Each box '' represents a Rust task.&lt;br /&gt;
&lt;br /&gt;
•	'' Blue boxes '' represent the primary tasks in the browser pipeline.&lt;br /&gt;
&lt;br /&gt;
•	'' Gray boxes '' represent tasks auxiliary to the browser pipeline.&lt;br /&gt;
&lt;br /&gt;
•	'' White boxes '' represent worker tasks. Each such box represents several tasks, the precise number of which will vary with the workload.&lt;br /&gt;
&lt;br /&gt;
•	'' Dashed lines '' indicate supervisor relationships.&lt;br /&gt;
&lt;br /&gt;
•	'' Solid lines '' indicate communication channels.&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
'''Installing Dependencies for Servo'''  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The list of commands to install the dependencies on various platforms are&amp;lt;ref name = github&amp;gt;[https://github.com/servo/servo Servo Github]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On OS X (homebrew):&lt;br /&gt;
&lt;br /&gt;
    brew install automake pkg-config python glfw3 cmake&lt;br /&gt;
    pip install virtualenv&lt;br /&gt;
&lt;br /&gt;
On OS X (MacPorts):&lt;br /&gt;
&lt;br /&gt;
    sudo port install python27 py27-virtualenv cmake&lt;br /&gt;
&lt;br /&gt;
On Debian-based Linuxes:&lt;br /&gt;
&lt;br /&gt;
    sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&lt;br /&gt;
On Fedora:&lt;br /&gt;
&lt;br /&gt;
    sudo yum install curl freeglut-devel libtool gcc-c++ libXi-devel \&lt;br /&gt;
        freetype-devel mesa-libGL-devel glib2-devel libX11-devel libXrandr-devel gperf \&lt;br /&gt;
        fontconfig-devel cabextract ttmkfdir python python-virtualenv expat-devel \&lt;br /&gt;
        rpm-build openssl-devel glfw-devel cmake&lt;br /&gt;
    pushd .&lt;br /&gt;
    cd /tmp&lt;br /&gt;
    wget http://corefonts.sourceforge.net/msttcorefonts-2.5-1.spec&lt;br /&gt;
    rpmbuild -bb msttcorefonts-2.5-1.spec&lt;br /&gt;
    sudo yum install $HOME/rpmbuild/RPMS/noarch/msttcorefonts-2.5-1.noarch.rpm&lt;br /&gt;
    popd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On Arch Linux:&lt;br /&gt;
&lt;br /&gt;
    sudo pacman -S base-devel git python2 python2-virtualenv mesa glfw ttf-font cmake&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Building Servo''' &lt;br /&gt;
&lt;br /&gt;
''Normal Build''&lt;br /&gt;
&lt;br /&gt;
    git clone https://github.com/servo/servo&lt;br /&gt;
    cd servo&lt;br /&gt;
    ./mach build&lt;br /&gt;
    ./mach run tests/html/about-mozilla.html &lt;br /&gt;
&lt;br /&gt;
''Building for Android target''&lt;br /&gt;
&lt;br /&gt;
    git clone https://github.com/servo/servo&lt;br /&gt;
    cd servo&lt;br /&gt;
    ANDROID_TOOLCHAIN=/path/to/toolchain ANDROID_NDK=/path/to/ndk PATH=$PATH:/path/to/toolchain/bin ./mach build --android&lt;br /&gt;
    cd ports/android&lt;br /&gt;
    ANDROID_SDK=/path/to/sdk make install&lt;br /&gt;
&lt;br /&gt;
= Steps of Implementation =&lt;br /&gt;
&lt;br /&gt;
→ Created a new file mod.rs in the following directory:   &amp;lt;code&amp;gt; servo/components/script/parse/mod.rs&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
→ Created a Parser Trait with the parse_chunk method in this mod.rs&lt;br /&gt;
&lt;br /&gt;
    pub mod html;&lt;br /&gt;
    pub trait Parser {&lt;br /&gt;
        fn parse_chunk(&amp;amp;self,input: String);&lt;br /&gt;
        fn finish(&amp;amp;self);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
→ Implementation of this Parser trait for the ServoHTML Parser struct is in the servo &amp;lt;code&amp;gt;/components/script/dom/servohtmlparser.rs&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    impl Parser for ServoHTMLParser{&lt;br /&gt;
        fn parse_chunk(&amp;amp;self, input: String) {&lt;br /&gt;
  	    self.tokenizer().borrow_mut().feed(input);&lt;br /&gt;
        }&lt;br /&gt;
        fn finish(&amp;amp;self){&lt;br /&gt;
  	    self.tokenizer().borrow_mut().end();&lt;br /&gt;
        }  &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
→ Modified &amp;lt;code&amp;gt;servo/components/script/parse/html.rs&amp;lt;/code&amp;gt; to invoke the parse_chunk method appropriately.&lt;br /&gt;
&lt;br /&gt;
     InputString(s) =&amp;gt; {&lt;br /&gt;
            parser.parse_chunk(s);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    InputUrl(url) =&amp;gt; {&lt;br /&gt;
            let load_response = load_response.unwrap();&lt;br /&gt;
            match load_response.metadata.content_type {&lt;br /&gt;
                Some((ref t, _)) if t.as_slice().eq_ignore_ascii_case(&amp;quot;image&amp;quot;) =&amp;gt; {&lt;br /&gt;
                    let page = format!(&amp;quot;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;img src='{:s}' /&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&amp;quot;, base_url.as_ref().unwrap().serialize());&lt;br /&gt;
                    parser.parse_chunk(page);&lt;br /&gt;
                },&lt;br /&gt;
    &lt;br /&gt;
    Payload(data) =&amp;gt; {&lt;br /&gt;
                                // FIXME: use Vec&amp;lt;u8&amp;gt; (html5ever #34)&lt;br /&gt;
                                let data = UTF_8.decode(data.as_slice(), DecodeReplace).unwrap();&lt;br /&gt;
                                parser.parse_chunk(data);&lt;br /&gt;
                            }&lt;br /&gt;
&lt;br /&gt;
= Design Patterns =&lt;br /&gt;
We have followed “Programming to Interfaces, not an implementation” design principle while implementing initial step of our project. We have modified the code of html.rs to invoke Parser trait’s parse_chunk method instead of directly invoking instead of directly invoking the methods of ServoHtmlParser .Thereby in future , if in case we use any other parser instance instead of ServoHtmlParser , we need not modify the invocation logic in html.rs function.(Traits are similar  to interfaces in other languages).&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references&amp;gt;&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_M1452_jns&amp;diff=89976</id>
		<title>CSC/ECE 517 Fall 2014/oss M1452 jns</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_M1452_jns&amp;diff=89976"/>
		<updated>2014-10-27T19:16:44Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Servo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Integrating an XML Parser =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Background Information =&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla Research. The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are handled by fine-grained, isolated tasks. The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rust ==&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a systems language for writing high performance applications that are usually written in C or C++ but it was developed to prevent some of the problems related to invalid memory accesses that generate segmentation faults. It covers imperative, functional and object-oriented programming.&lt;br /&gt;
It's designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety. &amp;lt;ref name=Rust&amp;gt;[https://www.mozilla.org/en-US/research/projects/ Overview of Mozilla Research Projects]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory. &amp;lt;ref name=Rust&amp;gt;[https://www.mozilla.org/en-US/research/projects/ Overview of Mozilla Research Projects]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo ==&lt;br /&gt;
[https://github.com/servo/servo Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. With Servo, Mozilla are rethinking the browser at every level of the technology stack — from input parsing to page layout to graphics rendering — to optimize for power efficiency and maximum parallelism.&lt;br /&gt;
&lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Memory safety at the core of the platform ensures a high degree of assurance in the browser’s trusted computing base. Rust’s lightweight task mechanism also promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation.&amp;lt;ref name=Rust&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''Task Supervision Diagram''&lt;br /&gt;
&lt;br /&gt;
[[File:Diagram1.jpg]]&lt;br /&gt;
&lt;br /&gt;
''Task Projection Diagram''&lt;br /&gt;
&lt;br /&gt;
[[File:Diagram2.jpg]]&lt;br /&gt;
&lt;br /&gt;
•	'' Each box '' represents a Rust task.&lt;br /&gt;
&lt;br /&gt;
•	'' Blue boxes '' represent the primary tasks in the browser pipeline.&lt;br /&gt;
•	'' Gray boxes '' represent tasks auxiliary to the browser pipeline.&lt;br /&gt;
•	'' White boxes '' represent worker tasks. Each such box represents several tasks, the precise number of which will vary with the workload.&lt;br /&gt;
•	'' Dashed lines '' indicate supervisor relationships.&lt;br /&gt;
•	'' Solid lines '' indicate communication channels.&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
'''Installing Dependencies for Servo'''  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The list of commands to install the dependencies on various platforms are&amp;lt;ref name = github&amp;gt;[https://github.com/servo/servo Servo Github]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On OS X (homebrew):&lt;br /&gt;
&lt;br /&gt;
    brew install automake pkg-config python glfw3 cmake&lt;br /&gt;
    pip install virtualenv&lt;br /&gt;
&lt;br /&gt;
On OS X (MacPorts):&lt;br /&gt;
&lt;br /&gt;
    sudo port install python27 py27-virtualenv cmake&lt;br /&gt;
&lt;br /&gt;
On Debian-based Linuxes:&lt;br /&gt;
&lt;br /&gt;
    sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&lt;br /&gt;
On Fedora:&lt;br /&gt;
&lt;br /&gt;
    sudo yum install curl freeglut-devel libtool gcc-c++ libXi-devel \&lt;br /&gt;
        freetype-devel mesa-libGL-devel glib2-devel libX11-devel libXrandr-devel gperf \&lt;br /&gt;
        fontconfig-devel cabextract ttmkfdir python python-virtualenv expat-devel \&lt;br /&gt;
        rpm-build openssl-devel glfw-devel cmake&lt;br /&gt;
    pushd .&lt;br /&gt;
    cd /tmp&lt;br /&gt;
    wget http://corefonts.sourceforge.net/msttcorefonts-2.5-1.spec&lt;br /&gt;
    rpmbuild -bb msttcorefonts-2.5-1.spec&lt;br /&gt;
    sudo yum install $HOME/rpmbuild/RPMS/noarch/msttcorefonts-2.5-1.noarch.rpm&lt;br /&gt;
    popd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On Arch Linux:&lt;br /&gt;
&lt;br /&gt;
    sudo pacman -S base-devel git python2 python2-virtualenv mesa glfw ttf-font cmake&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Building Servo''' &lt;br /&gt;
&lt;br /&gt;
''Normal Build''&lt;br /&gt;
&lt;br /&gt;
    git clone https://github.com/servo/servo&lt;br /&gt;
    cd servo&lt;br /&gt;
    ./mach build&lt;br /&gt;
    ./mach run tests/html/about-mozilla.html &lt;br /&gt;
&lt;br /&gt;
''Building for Android target''&lt;br /&gt;
&lt;br /&gt;
    git clone https://github.com/servo/servo&lt;br /&gt;
    cd servo&lt;br /&gt;
    ANDROID_TOOLCHAIN=/path/to/toolchain ANDROID_NDK=/path/to/ndk PATH=$PATH:/path/to/toolchain/bin ./mach build --android&lt;br /&gt;
    cd ports/android&lt;br /&gt;
    ANDROID_SDK=/path/to/sdk make install&lt;br /&gt;
&lt;br /&gt;
= Steps of Implementation =&lt;br /&gt;
&lt;br /&gt;
→ Created a new file mod.rs in the following directory:   &amp;lt;code&amp;gt; servo/components/script/parse/mod.rs&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
→ Created a Parser Trait with the parse_chunk method in this mod.rs&lt;br /&gt;
&lt;br /&gt;
    pub mod html;&lt;br /&gt;
    pub trait Parser {&lt;br /&gt;
        fn parse_chunk(&amp;amp;self,input: String);&lt;br /&gt;
        fn finish(&amp;amp;self);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
→ Implementation of this Parser trait for the ServoHTML Parser struct is in the servo &amp;lt;code&amp;gt;/components/script/dom/servohtmlparser.rs&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    impl Parser for ServoHTMLParser{&lt;br /&gt;
        fn parse_chunk(&amp;amp;self, input: String) {&lt;br /&gt;
  	    self.tokenizer().borrow_mut().feed(input);&lt;br /&gt;
        }&lt;br /&gt;
        fn finish(&amp;amp;self){&lt;br /&gt;
  	    self.tokenizer().borrow_mut().end();&lt;br /&gt;
        }  &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
→ Modified &amp;lt;code&amp;gt;servo/components/script/parse/html.rs&amp;lt;/code&amp;gt; to invoke the parse_chunk method appropriately.&lt;br /&gt;
&lt;br /&gt;
     InputString(s) =&amp;gt; {&lt;br /&gt;
            parser.parse_chunk(s);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    InputUrl(url) =&amp;gt; {&lt;br /&gt;
            let load_response = load_response.unwrap();&lt;br /&gt;
            match load_response.metadata.content_type {&lt;br /&gt;
                Some((ref t, _)) if t.as_slice().eq_ignore_ascii_case(&amp;quot;image&amp;quot;) =&amp;gt; {&lt;br /&gt;
                    let page = format!(&amp;quot;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;img src='{:s}' /&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&amp;quot;, base_url.as_ref().unwrap().serialize());&lt;br /&gt;
                    parser.parse_chunk(page);&lt;br /&gt;
                },&lt;br /&gt;
    &lt;br /&gt;
    Payload(data) =&amp;gt; {&lt;br /&gt;
                                // FIXME: use Vec&amp;lt;u8&amp;gt; (html5ever #34)&lt;br /&gt;
                                let data = UTF_8.decode(data.as_slice(), DecodeReplace).unwrap();&lt;br /&gt;
                                parser.parse_chunk(data);&lt;br /&gt;
                            }&lt;br /&gt;
&lt;br /&gt;
= Design Patterns =&lt;br /&gt;
We have followed “Programming to Interfaces, not an implementation” design principle while implementing initial step of our project. We have modified the code of html.rs to invoke Parser trait’s parse_chunk method instead of directly invoking instead of directly invoking the methods of ServoHtmlParser .Thereby in future , if in case we use any other parser instance instead of ServoHtmlParser , we need not modify the invocation logic in html.rs function.(Traits are similar  to interfaces in other languages).&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references&amp;gt;&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_M1452_jns&amp;diff=89975</id>
		<title>CSC/ECE 517 Fall 2014/oss M1452 jns</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_M1452_jns&amp;diff=89975"/>
		<updated>2014-10-27T19:15:13Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Integrating an XML Parser =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Background Information =&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla Research. The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are handled by fine-grained, isolated tasks. The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rust ==&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a systems language for writing high performance applications that are usually written in C or C++ but it was developed to prevent some of the problems related to invalid memory accesses that generate segmentation faults. It covers imperative, functional and object-oriented programming.&lt;br /&gt;
It's designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety. &amp;lt;ref name=Rust&amp;gt;[https://www.mozilla.org/en-US/research/projects/ Overview of Mozilla Research Projects]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory. &amp;lt;ref name=Rust&amp;gt;[https://www.mozilla.org/en-US/research/projects/ Overview of Mozilla Research Projects]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo ==&lt;br /&gt;
[https://github.com/servo/servo Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. With Servo, Mozilla are rethinking the browser at every level of the technology stack — from input parsing to page layout to graphics rendering — to optimize for power efficiency and maximum parallelism.&lt;br /&gt;
&lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Memory safety at the core of the platform ensures a high degree of assurance in the browser’s trusted computing base. Rust’s lightweight task mechanism also promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation.&amp;lt;ref name=Rust&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''Task Supervision Diagram''&lt;br /&gt;
&lt;br /&gt;
[[File:Diagram1.jpg]]&lt;br /&gt;
&lt;br /&gt;
''Task Projection Diagram''&lt;br /&gt;
&lt;br /&gt;
[[File:Diagram2.jpg]]&lt;br /&gt;
&lt;br /&gt;
•	Each box represents a Rust task.&lt;br /&gt;
•	Blue boxes represent the primary tasks in the browser pipeline.&lt;br /&gt;
•	Gray boxes represent tasks auxiliary to the browser pipeline.&lt;br /&gt;
•	White boxes represent worker tasks. Each such box represents several tasks, the precise number of which will vary with the workload.&lt;br /&gt;
•	Dashed lines indicate supervisor relationships.&lt;br /&gt;
•	Solid lines indicate communication channels.&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
'''Installing Dependencies for Servo'''  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The list of commands to install the dependencies on various platforms are&amp;lt;ref name = github&amp;gt;[https://github.com/servo/servo Servo Github]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On OS X (homebrew):&lt;br /&gt;
&lt;br /&gt;
    brew install automake pkg-config python glfw3 cmake&lt;br /&gt;
    pip install virtualenv&lt;br /&gt;
&lt;br /&gt;
On OS X (MacPorts):&lt;br /&gt;
&lt;br /&gt;
    sudo port install python27 py27-virtualenv cmake&lt;br /&gt;
&lt;br /&gt;
On Debian-based Linuxes:&lt;br /&gt;
&lt;br /&gt;
    sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&lt;br /&gt;
On Fedora:&lt;br /&gt;
&lt;br /&gt;
    sudo yum install curl freeglut-devel libtool gcc-c++ libXi-devel \&lt;br /&gt;
        freetype-devel mesa-libGL-devel glib2-devel libX11-devel libXrandr-devel gperf \&lt;br /&gt;
        fontconfig-devel cabextract ttmkfdir python python-virtualenv expat-devel \&lt;br /&gt;
        rpm-build openssl-devel glfw-devel cmake&lt;br /&gt;
    pushd .&lt;br /&gt;
    cd /tmp&lt;br /&gt;
    wget http://corefonts.sourceforge.net/msttcorefonts-2.5-1.spec&lt;br /&gt;
    rpmbuild -bb msttcorefonts-2.5-1.spec&lt;br /&gt;
    sudo yum install $HOME/rpmbuild/RPMS/noarch/msttcorefonts-2.5-1.noarch.rpm&lt;br /&gt;
    popd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On Arch Linux:&lt;br /&gt;
&lt;br /&gt;
    sudo pacman -S base-devel git python2 python2-virtualenv mesa glfw ttf-font cmake&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Building Servo''' &lt;br /&gt;
&lt;br /&gt;
''Normal Build''&lt;br /&gt;
&lt;br /&gt;
    git clone https://github.com/servo/servo&lt;br /&gt;
    cd servo&lt;br /&gt;
    ./mach build&lt;br /&gt;
    ./mach run tests/html/about-mozilla.html &lt;br /&gt;
&lt;br /&gt;
''Building for Android target''&lt;br /&gt;
&lt;br /&gt;
    git clone https://github.com/servo/servo&lt;br /&gt;
    cd servo&lt;br /&gt;
    ANDROID_TOOLCHAIN=/path/to/toolchain ANDROID_NDK=/path/to/ndk PATH=$PATH:/path/to/toolchain/bin ./mach build --android&lt;br /&gt;
    cd ports/android&lt;br /&gt;
    ANDROID_SDK=/path/to/sdk make install&lt;br /&gt;
&lt;br /&gt;
= Steps of Implementation =&lt;br /&gt;
&lt;br /&gt;
→ Created a new file mod.rs in the following directory:   &amp;lt;code&amp;gt; servo/components/script/parse/mod.rs&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
→ Created a Parser Trait with the parse_chunk method in this mod.rs&lt;br /&gt;
&lt;br /&gt;
    pub mod html;&lt;br /&gt;
    pub trait Parser {&lt;br /&gt;
        fn parse_chunk(&amp;amp;self,input: String);&lt;br /&gt;
        fn finish(&amp;amp;self);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
→ Implementation of this Parser trait for the ServoHTML Parser struct is in the servo &amp;lt;code&amp;gt;/components/script/dom/servohtmlparser.rs&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    impl Parser for ServoHTMLParser{&lt;br /&gt;
        fn parse_chunk(&amp;amp;self, input: String) {&lt;br /&gt;
  	    self.tokenizer().borrow_mut().feed(input);&lt;br /&gt;
        }&lt;br /&gt;
        fn finish(&amp;amp;self){&lt;br /&gt;
  	    self.tokenizer().borrow_mut().end();&lt;br /&gt;
        }  &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
→ Modified &amp;lt;code&amp;gt;servo/components/script/parse/html.rs&amp;lt;/code&amp;gt; to invoke the parse_chunk method appropriately.&lt;br /&gt;
&lt;br /&gt;
     InputString(s) =&amp;gt; {&lt;br /&gt;
            parser.parse_chunk(s);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    InputUrl(url) =&amp;gt; {&lt;br /&gt;
            let load_response = load_response.unwrap();&lt;br /&gt;
            match load_response.metadata.content_type {&lt;br /&gt;
                Some((ref t, _)) if t.as_slice().eq_ignore_ascii_case(&amp;quot;image&amp;quot;) =&amp;gt; {&lt;br /&gt;
                    let page = format!(&amp;quot;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;img src='{:s}' /&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&amp;quot;, base_url.as_ref().unwrap().serialize());&lt;br /&gt;
                    parser.parse_chunk(page);&lt;br /&gt;
                },&lt;br /&gt;
    &lt;br /&gt;
    Payload(data) =&amp;gt; {&lt;br /&gt;
                                // FIXME: use Vec&amp;lt;u8&amp;gt; (html5ever #34)&lt;br /&gt;
                                let data = UTF_8.decode(data.as_slice(), DecodeReplace).unwrap();&lt;br /&gt;
                                parser.parse_chunk(data);&lt;br /&gt;
                            }&lt;br /&gt;
&lt;br /&gt;
= Design Patterns =&lt;br /&gt;
We have followed “Programming to Interfaces, not an implementation” design principle while implementing initial step of our project. We have modified the code of html.rs to invoke Parser trait’s parse_chunk method instead of directly invoking instead of directly invoking the methods of ServoHtmlParser .Thereby in future , if in case we use any other parser instance instead of ServoHtmlParser , we need not modify the invocation logic in html.rs function.(Traits are similar  to interfaces in other languages).&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references&amp;gt;&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_M1452_jns&amp;diff=89967</id>
		<title>CSC/ECE 517 Fall 2014/oss M1452 jns</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_M1452_jns&amp;diff=89967"/>
		<updated>2014-10-27T18:53:02Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Design Patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Integrating an XML Parser =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Background Information =&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla Research. The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are handled by fine-grained, isolated tasks. The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rust ==&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a systems language for writing high performance applications that are usually written in C or C++ but it was developed to prevent some of the problems related to invalid memory accesses that generate segmentation faults. It covers imperative, functional and object-oriented programming.&lt;br /&gt;
It's designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety. &amp;lt;ref name=Rust&amp;gt;[https://www.mozilla.org/en-US/research/projects/ Overview of Mozilla Research Projects]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory. &amp;lt;ref name=Rust&amp;gt;[https://www.mozilla.org/en-US/research/projects/ Overview of Mozilla Research Projects]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo ==&lt;br /&gt;
[https://github.com/servo/servo Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. With Servo, Mozilla are rethinking the browser at every level of the technology stack — from input parsing to page layout to graphics rendering — to optimize for power efficiency and maximum parallelism.&lt;br /&gt;
&lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Memory safety at the core of the platform ensures a high degree of assurance in the browser’s trusted computing base. Rust’s lightweight task mechanism also promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation.&amp;lt;ref name=Rust&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
'''Installing Dependencies for Servo'''  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The list of commands to install the dependencies on various platforms are&amp;lt;ref name = github&amp;gt;[https://github.com/servo/servo Servo Github]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On OS X (homebrew):&lt;br /&gt;
&lt;br /&gt;
    brew install automake pkg-config python glfw3 cmake&lt;br /&gt;
    pip install virtualenv&lt;br /&gt;
&lt;br /&gt;
On OS X (MacPorts):&lt;br /&gt;
&lt;br /&gt;
    sudo port install python27 py27-virtualenv cmake&lt;br /&gt;
&lt;br /&gt;
On Debian-based Linuxes:&lt;br /&gt;
&lt;br /&gt;
    sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&lt;br /&gt;
On Fedora:&lt;br /&gt;
&lt;br /&gt;
    sudo yum install curl freeglut-devel libtool gcc-c++ libXi-devel \&lt;br /&gt;
        freetype-devel mesa-libGL-devel glib2-devel libX11-devel libXrandr-devel gperf \&lt;br /&gt;
        fontconfig-devel cabextract ttmkfdir python python-virtualenv expat-devel \&lt;br /&gt;
        rpm-build openssl-devel glfw-devel cmake&lt;br /&gt;
    pushd .&lt;br /&gt;
    cd /tmp&lt;br /&gt;
    wget http://corefonts.sourceforge.net/msttcorefonts-2.5-1.spec&lt;br /&gt;
    rpmbuild -bb msttcorefonts-2.5-1.spec&lt;br /&gt;
    sudo yum install $HOME/rpmbuild/RPMS/noarch/msttcorefonts-2.5-1.noarch.rpm&lt;br /&gt;
    popd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On Arch Linux:&lt;br /&gt;
&lt;br /&gt;
    sudo pacman -S base-devel git python2 python2-virtualenv mesa glfw ttf-font cmake&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Building Servo''' &lt;br /&gt;
&lt;br /&gt;
''Normal Build''&lt;br /&gt;
&lt;br /&gt;
    git clone https://github.com/servo/servo&lt;br /&gt;
    cd servo&lt;br /&gt;
    ./mach build&lt;br /&gt;
    ./mach run tests/html/about-mozilla.html &lt;br /&gt;
&lt;br /&gt;
''Building for Android target''&lt;br /&gt;
&lt;br /&gt;
    git clone https://github.com/servo/servo&lt;br /&gt;
    cd servo&lt;br /&gt;
    ANDROID_TOOLCHAIN=/path/to/toolchain ANDROID_NDK=/path/to/ndk PATH=$PATH:/path/to/toolchain/bin ./mach build --android&lt;br /&gt;
    cd ports/android&lt;br /&gt;
    ANDROID_SDK=/path/to/sdk make install&lt;br /&gt;
&lt;br /&gt;
= Steps of Implementation =&lt;br /&gt;
&lt;br /&gt;
→ Created a new file mod.rs in the following directory:   &amp;lt;code&amp;gt; servo/components/script/parse/mod.rs&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
→ Created a Parser Trait with the parse_chunk method in this mod.rs&lt;br /&gt;
&lt;br /&gt;
    pub mod html;&lt;br /&gt;
    pub trait Parser {&lt;br /&gt;
        fn parse_chunk(&amp;amp;self,input: String);&lt;br /&gt;
        fn finish(&amp;amp;self);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
→ Implementation of this Parser trait for the ServoHTML Parser struct is in the servo &amp;lt;code&amp;gt;/components/script/dom/servohtmlparser.rs&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    impl Parser for ServoHTMLParser{&lt;br /&gt;
        fn parse_chunk(&amp;amp;self, input: String) {&lt;br /&gt;
  	    self.tokenizer().borrow_mut().feed(input);&lt;br /&gt;
        }&lt;br /&gt;
        fn finish(&amp;amp;self){&lt;br /&gt;
  	    self.tokenizer().borrow_mut().end();&lt;br /&gt;
        }  &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
→ Modified &amp;lt;code&amp;gt;servo/components/script/parse/html.rs&amp;lt;/code&amp;gt; to invoke the parse_chunk method appropriately.&lt;br /&gt;
&lt;br /&gt;
     InputString(s) =&amp;gt; {&lt;br /&gt;
            parser.parse_chunk(s);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    InputUrl(url) =&amp;gt; {&lt;br /&gt;
            let load_response = load_response.unwrap();&lt;br /&gt;
            match load_response.metadata.content_type {&lt;br /&gt;
                Some((ref t, _)) if t.as_slice().eq_ignore_ascii_case(&amp;quot;image&amp;quot;) =&amp;gt; {&lt;br /&gt;
                    let page = format!(&amp;quot;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;img src='{:s}' /&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&amp;quot;, base_url.as_ref().unwrap().serialize());&lt;br /&gt;
                    parser.parse_chunk(page);&lt;br /&gt;
                },&lt;br /&gt;
    &lt;br /&gt;
    Payload(data) =&amp;gt; {&lt;br /&gt;
                                // FIXME: use Vec&amp;lt;u8&amp;gt; (html5ever #34)&lt;br /&gt;
                                let data = UTF_8.decode(data.as_slice(), DecodeReplace).unwrap();&lt;br /&gt;
                                parser.parse_chunk(data);&lt;br /&gt;
                            }&lt;br /&gt;
&lt;br /&gt;
= Design Patterns =&lt;br /&gt;
We have followed “Programming to Interfaces, not an implementation” design principle while implementing initial step of our project. We have modified the code of html.rs to invoke Parser trait’s parse_chunk method instead of directly invoking instead of directly invoking the methods of ServoHtmlParser .Thereby in future , if in case we use any other parser instance instead of ServoHtmlParser , we need not modify the invocation logic in html.rs function.(Traits are similar  to interfaces in other languages).&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references&amp;gt;&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_M1452_jns&amp;diff=89966</id>
		<title>CSC/ECE 517 Fall 2014/oss M1452 jns</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_M1452_jns&amp;diff=89966"/>
		<updated>2014-10-27T18:49:17Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Steps of Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Integrating an XML Parser =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Background Information =&lt;br /&gt;
Servo is an experimental web browser layout engine being developed by Mozilla Research. The prototype seeks to create a highly parallel environment, in which many components (such as rendering, layout, HTML parsing, image decoding, etc.) are handled by fine-grained, isolated tasks. The project has a symbiotic relationship with the Rust programming language, in which it is being developed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rust ==&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a systems language for writing high performance applications that are usually written in C or C++ but it was developed to prevent some of the problems related to invalid memory accesses that generate segmentation faults. It covers imperative, functional and object-oriented programming.&lt;br /&gt;
It's designed to support concurrency and parallelism in building platforms that take full advantage of modern hardware. Its static type system is safe and expressive and it provides strong guarantees about isolation, concurrency execution and memory safety. &amp;lt;ref name=Rust&amp;gt;[https://www.mozilla.org/en-US/research/projects/ Overview of Mozilla Research Projects]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rust combines powerful and flexible modern programming constructs with a clear performance model to make program efficiency predictable and manageable. One important way it achieves this is by allowing fine-grained control over memory allocation through contiguous records and stack allocation. This control is balanced with the absolute requirement of safety: Rust’s type system and runtime guarantee the absence of data races, buffer overflow, stack overflow or access to uninitialized or deallocated memory. &amp;lt;ref name=Rust&amp;gt;[https://www.mozilla.org/en-US/research/projects/ Overview of Mozilla Research Projects]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Servo ==&lt;br /&gt;
[https://github.com/servo/servo Servo] is an experimental project to build a Web browser engine for a new generation of hardware: mobile devices, multi-core processors and high-performance GPUs. With Servo, Mozilla are rethinking the browser at every level of the technology stack — from input parsing to page layout to graphics rendering — to optimize for power efficiency and maximum parallelism.&lt;br /&gt;
&lt;br /&gt;
Servo builds on top of Rust to provide a secure and reliable foundation. Memory safety at the core of the platform ensures a high degree of assurance in the browser’s trusted computing base. Rust’s lightweight task mechanism also promises to allow fine-grained isolation between browser components, such as tabs and extensions, without the need for expensive runtime protection schemes, like operating system process isolation.&amp;lt;ref name=Rust&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
'''Installing Dependencies for Servo'''  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The list of commands to install the dependencies on various platforms are&amp;lt;ref name = github&amp;gt;[https://github.com/servo/servo Servo Github]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On OS X (homebrew):&lt;br /&gt;
&lt;br /&gt;
    brew install automake pkg-config python glfw3 cmake&lt;br /&gt;
    pip install virtualenv&lt;br /&gt;
&lt;br /&gt;
On OS X (MacPorts):&lt;br /&gt;
&lt;br /&gt;
    sudo port install python27 py27-virtualenv cmake&lt;br /&gt;
&lt;br /&gt;
On Debian-based Linuxes:&lt;br /&gt;
&lt;br /&gt;
    sudo apt-get install curl freeglut3-dev \&lt;br /&gt;
    libfreetype6-dev libgl1-mesa-dri libglib2.0-dev xorg-dev \&lt;br /&gt;
    msttcorefonts gperf g++ cmake python-virtualenv \&lt;br /&gt;
    libssl-dev libglfw-dev&lt;br /&gt;
&lt;br /&gt;
On Fedora:&lt;br /&gt;
&lt;br /&gt;
    sudo yum install curl freeglut-devel libtool gcc-c++ libXi-devel \&lt;br /&gt;
        freetype-devel mesa-libGL-devel glib2-devel libX11-devel libXrandr-devel gperf \&lt;br /&gt;
        fontconfig-devel cabextract ttmkfdir python python-virtualenv expat-devel \&lt;br /&gt;
        rpm-build openssl-devel glfw-devel cmake&lt;br /&gt;
    pushd .&lt;br /&gt;
    cd /tmp&lt;br /&gt;
    wget http://corefonts.sourceforge.net/msttcorefonts-2.5-1.spec&lt;br /&gt;
    rpmbuild -bb msttcorefonts-2.5-1.spec&lt;br /&gt;
    sudo yum install $HOME/rpmbuild/RPMS/noarch/msttcorefonts-2.5-1.noarch.rpm&lt;br /&gt;
    popd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On Arch Linux:&lt;br /&gt;
&lt;br /&gt;
    sudo pacman -S base-devel git python2 python2-virtualenv mesa glfw ttf-font cmake&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Building Servo''' &lt;br /&gt;
&lt;br /&gt;
''Normal Build''&lt;br /&gt;
&lt;br /&gt;
    git clone https://github.com/servo/servo&lt;br /&gt;
    cd servo&lt;br /&gt;
    ./mach build&lt;br /&gt;
    ./mach run tests/html/about-mozilla.html &lt;br /&gt;
&lt;br /&gt;
''Building for Android target''&lt;br /&gt;
&lt;br /&gt;
    git clone https://github.com/servo/servo&lt;br /&gt;
    cd servo&lt;br /&gt;
    ANDROID_TOOLCHAIN=/path/to/toolchain ANDROID_NDK=/path/to/ndk PATH=$PATH:/path/to/toolchain/bin ./mach build --android&lt;br /&gt;
    cd ports/android&lt;br /&gt;
    ANDROID_SDK=/path/to/sdk make install&lt;br /&gt;
&lt;br /&gt;
= Steps of Implementation =&lt;br /&gt;
&lt;br /&gt;
→ Created a new file mod.rs in the following directory:   &amp;lt;code&amp;gt; servo/components/script/parse/mod.rs&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
→ Created a Parser Trait with the parse_chunk method in this mod.rs&lt;br /&gt;
&lt;br /&gt;
    pub mod html;&lt;br /&gt;
    pub trait Parser {&lt;br /&gt;
        fn parse_chunk(&amp;amp;self,input: String);&lt;br /&gt;
        fn finish(&amp;amp;self);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
→ Implementation of this Parser trait for the ServoHTML Parser struct is in the servo &amp;lt;code&amp;gt;/components/script/dom/servohtmlparser.rs&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    impl Parser for ServoHTMLParser{&lt;br /&gt;
        fn parse_chunk(&amp;amp;self, input: String) {&lt;br /&gt;
  	    self.tokenizer().borrow_mut().feed(input);&lt;br /&gt;
        }&lt;br /&gt;
        fn finish(&amp;amp;self){&lt;br /&gt;
  	    self.tokenizer().borrow_mut().end();&lt;br /&gt;
        }  &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
→ Modified &amp;lt;code&amp;gt;servo/components/script/parse/html.rs&amp;lt;/code&amp;gt; to invoke the parse_chunk method appropriately.&lt;br /&gt;
&lt;br /&gt;
     InputString(s) =&amp;gt; {&lt;br /&gt;
            parser.parse_chunk(s);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    InputUrl(url) =&amp;gt; {&lt;br /&gt;
            let load_response = load_response.unwrap();&lt;br /&gt;
            match load_response.metadata.content_type {&lt;br /&gt;
                Some((ref t, _)) if t.as_slice().eq_ignore_ascii_case(&amp;quot;image&amp;quot;) =&amp;gt; {&lt;br /&gt;
                    let page = format!(&amp;quot;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;img src='{:s}' /&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&amp;quot;, base_url.as_ref().unwrap().serialize());&lt;br /&gt;
                    parser.parse_chunk(page);&lt;br /&gt;
                },&lt;br /&gt;
    &lt;br /&gt;
    Payload(data) =&amp;gt; {&lt;br /&gt;
                                // FIXME: use Vec&amp;lt;u8&amp;gt; (html5ever #34)&lt;br /&gt;
                                let data = UTF_8.decode(data.as_slice(), DecodeReplace).unwrap();&lt;br /&gt;
                                parser.parse_chunk(data);&lt;br /&gt;
                            }&lt;br /&gt;
&lt;br /&gt;
= Design Patterns =&lt;br /&gt;
We have followed “Programming to Interfaces, not an implementation” design principle while implementing initial step of our project. We have modified the code of html.rs to invoke Parser trait’s parse_chunk method instead of directly invoking instead of directly invoking the methods of ServoHtmlParser .Thereby in future , if in case we use any other parser instance instead of ServoHtmlParser , we need not modify the invocation logic in html.rs function.(Traits are similar  to interfaces in other languages).&lt;br /&gt;
&lt;br /&gt;
We are planning to use parameterized variation of factory method design pattern to create instances of either html parser or Xml parser based on the HTTP Content-Type header. In html.rs file, instead of directly creating instances of ServoHtmlParser(like ServoHtmlParser::new..) ,we would be calling a function like build_parser by passing in HTTP Content-Type header as parameter. This build_parser method will return either instance of ServoHtmlParser or XML Parser based on the content type parameter. Here, build_parser will be acting as factory method .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&amp;lt;references&amp;gt;&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_M1452_jns&amp;diff=89926</id>
		<title>CSC/ECE 517 Fall 2014/oss M1452 jns</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_M1452_jns&amp;diff=89926"/>
		<updated>2014-10-27T17:39:16Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Integrating an XML Parser =&lt;br /&gt;
This wiki is about the project M 1452: Integrate an XML Parser, which is a part of the ongoing development on the Servo browser. Below you can find a brief description about the servo project, rust programming language, requirements of this particular project, setting up of the development environment and other relevant details.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
= Background Information =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rust ==&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a systems language for writing high performance applications that are usually written in C or C++ but it was developed to prevent some of the problems related to invalid memory accesses that generate segmentation faults. It covers imperative, functional and object-oriented programming.&lt;br /&gt;
&lt;br /&gt;
== Servo ==&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_M1452_jns&amp;diff=89921</id>
		<title>CSC/ECE 517 Fall 2014/oss M1452 jns</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_M1452_jns&amp;diff=89921"/>
		<updated>2014-10-27T17:30:09Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Integrating an XML Parser =&lt;br /&gt;
This wiki is about the project M 1452: Integrate an XML Parser, which is a part of the ongoing development on the Servo browser. Below you can find a brief description about the servo project, rust programming language, requirements of this particular project, setting up of the development environment and other relevant details.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
= Background Information =&lt;br /&gt;
&lt;br /&gt;
== Rust ==&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a systems language for writing high performance applications that are usually written in C or C++ but it was developed to prevent some of the problems related to invalid memory accesses that generate segmentation faults. It covers imperative, functional and object-oriented programming.&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_M1452_jns&amp;diff=89920</id>
		<title>CSC/ECE 517 Fall 2014/oss M1452 jns</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_M1452_jns&amp;diff=89920"/>
		<updated>2014-10-27T17:27:28Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Integrating an XML Parser =&lt;br /&gt;
This wiki is about the project M 1452: Integrate an XML Parser, which is a part of the ongoing development on the Servo browser. Below you can find a brief description about the servo project, rust programming language, requirements of this particular project, setting up of the development environment and other relevant details.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Background Information =&lt;br /&gt;
&lt;br /&gt;
== Rust ==&lt;br /&gt;
[http://www.rust-lang.org/ Rust] is a systems language for writing high performance applications that are usually written in C or C++ but it was developed to prevent some of the problems related to invalid memory accesses that generate segmentation faults. It covers imperative, functional and object-oriented programming.&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_M1452_jns&amp;diff=89892</id>
		<title>CSC/ECE 517 Fall 2014/oss M1452 jns</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/oss_M1452_jns&amp;diff=89892"/>
		<updated>2014-10-27T15:32:36Z</updated>

		<summary type="html">&lt;p&gt;Sngala: Created page with &amp;quot;= Integrating an XML Parser = This wiki is about the project M 1452: Integrate an XML Parser, which is a part of the ongoing development on the Servo browser. Below you can find ...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Integrating an XML Parser =&lt;br /&gt;
This wiki is about the project M 1452: Integrate an XML Parser, which is a part of the ongoing development on the Servo browser. Below you can find a brief description about the servo project, rust programming language, requirements of this particular project, setting up of the development environment and other relevant details.&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89584</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89584"/>
		<updated>2014-10-14T03:00:38Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Drawbacks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Jasmine'''&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for [http://en.wikipedia.org/wiki/JavaScript JavaScript]. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the [http://en.wikipedia.org/wiki/MIT_License MIT license]. Jasmine allows tests to be written independent of the [http://en.wikipedia.org/wiki/Document_Object_Model DOM] or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
Jasmine is often used in the [http://en.wikipedia.org/wiki/Ruby_on_Rails Rails framework]. Jasmine is available as a [http://en.wikipedia.org/wiki/RubyGems Rubygem] and it automates common workflows by leveraging known rake tasks and generators. Jasmine is highly influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many frameworks don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some frameworks have syntax that is hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It shouldn't be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* It should have idiomatic and unsurprising syntax.&lt;br /&gt;
* It should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* It shouldn't intrude in an application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* It should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It should encourage good testing practices.&lt;br /&gt;
* It should integrate easily with continuous build systems.&lt;br /&gt;
* It should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Test_suite Test suites] are generally used to group similar test cases together. In Jasmine a test suite begins with a call to the global function &amp;lt;code&amp;gt;describe&amp;lt;/code&amp;gt; with two parameters: a string and a function. The string is a name or title for a spec suite – usually what is under test. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function &amp;lt;code&amp;gt;it&amp;lt;/code&amp;gt;, which, like &amp;lt;code&amp;gt;describe&amp;lt;/code&amp;gt; takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the &amp;lt;code&amp;gt;xdescribe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;xit&amp;lt;/code&amp;gt; functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function &amp;lt;code&amp;gt;expect&amp;lt;/code&amp;gt; which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec. Any matcher can evaluate to a negative assertion by chaining the call to &amp;lt;code&amp;gt;expect&amp;lt;/code&amp;gt; with a &amp;lt;code&amp;gt;not&amp;lt;/code&amp;gt; before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*&amp;lt;code&amp;gt;toBe&amp;lt;/code&amp;gt;: represents the exact equality (===) operator.&lt;br /&gt;
*&amp;lt;code&amp;gt;toEqual&amp;lt;/code&amp;gt;: represents the regular equality (==) operator.&lt;br /&gt;
*&amp;lt;code&amp;gt;toMatch&amp;lt;/code&amp;gt;: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*&amp;lt;code&amp;gt;toBeDefined&amp;lt;/code&amp;gt;: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*&amp;lt;code&amp;gt;toBeUndefined&amp;lt;/code&amp;gt;: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*&amp;lt;code&amp;gt;toBeNull&amp;lt;/code&amp;gt;: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*&amp;lt;code&amp;gt;toBeTruthy&amp;lt;/code&amp;gt;: simulates JavaScript boolean casting.&lt;br /&gt;
*&amp;lt;code&amp;gt;toBeFalsy&amp;lt;/code&amp;gt;: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*&amp;lt;code&amp;gt;toContain&amp;lt;/code&amp;gt;: performs a search on an array for the actual value.&lt;br /&gt;
*&amp;lt;code&amp;gt;toBeLessThan&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;toBeGreaterThan&amp;lt;/code&amp;gt;: for numerical comparisons.&lt;br /&gt;
*&amp;lt;code&amp;gt;toBeCloseTo&amp;lt;/code&amp;gt;: for floating point comparisons.&lt;br /&gt;
*&amp;lt;code&amp;gt;toThrow&amp;lt;/code&amp;gt;: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The &amp;lt;code&amp;gt;describe&amp;lt;/code&amp;gt; function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If they are named well, specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY] up any duplicated setup and teardown code, Jasmine provides the global &amp;lt;code&amp;gt;beforeEach&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;afterEach&amp;lt;/code&amp;gt; functions. As the name implies the &amp;lt;code&amp;gt;beforeEach&amp;lt;/code&amp;gt; function is called once before each spec in the describe is run and the &amp;lt;code&amp;gt;afterEach&amp;lt;/code&amp;gt; function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
In Jasmine, test doubles are called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the &amp;lt;code&amp;gt;describe&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;it&amp;lt;/code&amp;gt; block it is defined in, and is removed after each spec. &lt;br /&gt;
There are special matchers for interacting with spies.&lt;br /&gt;
The &amp;lt;code&amp;gt;toHaveBeenCalled&amp;lt;/code&amp;gt; matcher returns true if the spy is called. The &amp;lt;code&amp;gt;toHaveBeenCalledWith&amp;lt;/code&amp;gt; matcher returns true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions &amp;lt;code&amp;gt;runs&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;waitsFor&amp;lt;/code&amp;gt;:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;runs&amp;lt;/code&amp;gt; – takes the asynchronous function for execution;&lt;br /&gt;
*&amp;lt;code&amp;gt;waitsFor&amp;lt;/code&amp;gt; – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code. It is installed with a call to &amp;lt;code&amp;gt;jasmine.clock().install&amp;lt;/code&amp;gt; in a spec or suite that needs to manipulate time. The clock needs to be uninstalled after the original functions are restored.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
Functions like &amp;lt;code&amp;gt;setTimeout&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;setInterval&amp;lt;/code&amp;gt; can be made synchronous executing the registered functions only once the clock is ticked forward in time. To execute registered functions, move time forward via the &amp;lt;code&amp;gt;jasmine.clock().tick&amp;lt;/code&amp;gt; function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If not provided with a base time to &amp;lt;code&amp;gt;mockDate&amp;lt;/code&amp;gt; it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following example demonstrates usage of jasmine Clock.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
&amp;lt;code&amp;gt;jasmine.any&amp;lt;/code&amp;gt; takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
[http://behaviour-driven.org/ Behavior Driven Development] (abbreviated as BDD) is a software development process that was developed in response to issues encountered with [http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)].&lt;br /&gt;
BDD is based on the techniques and principles of TDD, while combining these with ideas from domain-driven design and object-oriented analysis and design. BDD focuses on the behavioral specification of software units.&lt;br /&gt;
&lt;br /&gt;
While TDD is quite non-specific about what should be tested and at what level of detail, BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.&lt;br /&gt;
BDD also specifies how the behavior should be specified. BDD uses a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design.&lt;br /&gt;
&lt;br /&gt;
Generally TDD suggests writing unit tests at the beginning of the application development process to help the developer design the code. This helps the developer design the object and method interfaces through test, and refactor the code and tests as the code matures. These tests are often written as a white box test-inside-out that test the specific implementation of a piece of code.&lt;br /&gt;
BDD also emphasizes writing unit tests, but instead of focusing on the inside-out test approach, it approaches the test from a business value perspective which tests outside-in. &lt;br /&gt;
BDD emphasizes that test authors focus on why a piece of code is necessary, and what its goal is. &amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This approach is adopted in the way all tests are written in Jasmine. In Jasmine each test describes the behavior of the unit under test, through an &amp;quot;it should do the following&amp;quot; kind of clause.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Comparison between Jasmine, Qunit and Mocha=&lt;br /&gt;
The following gives a difference between three popular JavaScript test frameworks - Jasmine, Qunit and Mocha.&amp;lt;ref name=&amp;quot;Comparison&amp;quot;&amp;gt;https://github.com/thegrtman/javascript-test-framework-comparison&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;table border=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Frameworks &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Pros &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Cons &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt; [http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup for node through jasmine-node.&lt;br /&gt;
*Fluent syntax for assertions built-in, and works well with other assertion libraries&lt;br /&gt;
*Supported by many [http://en.wikipedia.org/wiki/Continuous_integration CI servers]  ([https://www.jetbrains.com/teamcity/ TeamCity], [https://www.codeship.io/ Codeship], etc.) &lt;br /&gt;
*Descriptive syntax for BDD paradigm.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Expects a specific suffix to all test files.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/QUnit Qunit]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Lots of support across the board, from Q&amp;amp;A to [http://en.wikipedia.org/wiki/Continuous_integration CI server] support.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Configuration is really difficult, and must constantly be maintained.&lt;br /&gt;
*Including assertion libraries is difficult.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup&lt;br /&gt;
*Supported by some CI servers and plugins for others.&lt;br /&gt;
*Has aliases for functions to be more BDD-oriented or TDD-oriented.&lt;br /&gt;
*Highly extensible.&lt;br /&gt;
*Asynchronous testing is easy.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*It's relatively new so support might be lacking in certain areas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;/&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha] is preferred for asynchronous testing, better flexibility and better usability.&amp;lt;ref name=&amp;quot;difference&amp;quot;&amp;gt;http://www.techtalkdc.com/which-javascript-test-library-should-you-use-qunit-vs-jasmine-vs-mocha/&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
*[http://en.wikipedia.org/wiki/JavaScript Javascript]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)]&lt;br /&gt;
*[http://rspec.info/ RSpec]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/QUnit Qunit]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89583</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89583"/>
		<updated>2014-10-14T03:00:22Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Drawbacks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Jasmine'''&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for [http://en.wikipedia.org/wiki/JavaScript JavaScript]. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the [http://en.wikipedia.org/wiki/MIT_License MIT license]. Jasmine allows tests to be written independent of the [http://en.wikipedia.org/wiki/Document_Object_Model DOM] or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
Jasmine is often used in the [http://en.wikipedia.org/wiki/Ruby_on_Rails Rails framework]. Jasmine is available as a [http://en.wikipedia.org/wiki/RubyGems Rubygem] and it automates common workflows by leveraging known rake tasks and generators. Jasmine is highly influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many frameworks don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some frameworks have syntax that is hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It shouldn't be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* It should have idiomatic and unsurprising syntax.&lt;br /&gt;
* It should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* It shouldn't intrude in an application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* It should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It should encourage good testing practices.&lt;br /&gt;
* It should integrate easily with continuous build systems.&lt;br /&gt;
* It should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
[http://en.wikipedia.org/wiki/Test_suite Test suites] are generally used to group similar test cases together. In Jasmine a test suite begins with a call to the global function &amp;lt;code&amp;gt;describe&amp;lt;/code&amp;gt; with two parameters: a string and a function. The string is a name or title for a spec suite – usually what is under test. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function &amp;lt;code&amp;gt;it&amp;lt;/code&amp;gt;, which, like &amp;lt;code&amp;gt;describe&amp;lt;/code&amp;gt; takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the &amp;lt;code&amp;gt;xdescribe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;xit&amp;lt;/code&amp;gt; functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function &amp;lt;code&amp;gt;expect&amp;lt;/code&amp;gt; which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec. Any matcher can evaluate to a negative assertion by chaining the call to &amp;lt;code&amp;gt;expect&amp;lt;/code&amp;gt; with a &amp;lt;code&amp;gt;not&amp;lt;/code&amp;gt; before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*&amp;lt;code&amp;gt;toBe&amp;lt;/code&amp;gt;: represents the exact equality (===) operator.&lt;br /&gt;
*&amp;lt;code&amp;gt;toEqual&amp;lt;/code&amp;gt;: represents the regular equality (==) operator.&lt;br /&gt;
*&amp;lt;code&amp;gt;toMatch&amp;lt;/code&amp;gt;: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*&amp;lt;code&amp;gt;toBeDefined&amp;lt;/code&amp;gt;: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*&amp;lt;code&amp;gt;toBeUndefined&amp;lt;/code&amp;gt;: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*&amp;lt;code&amp;gt;toBeNull&amp;lt;/code&amp;gt;: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*&amp;lt;code&amp;gt;toBeTruthy&amp;lt;/code&amp;gt;: simulates JavaScript boolean casting.&lt;br /&gt;
*&amp;lt;code&amp;gt;toBeFalsy&amp;lt;/code&amp;gt;: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*&amp;lt;code&amp;gt;toContain&amp;lt;/code&amp;gt;: performs a search on an array for the actual value.&lt;br /&gt;
*&amp;lt;code&amp;gt;toBeLessThan&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;toBeGreaterThan&amp;lt;/code&amp;gt;: for numerical comparisons.&lt;br /&gt;
*&amp;lt;code&amp;gt;toBeCloseTo&amp;lt;/code&amp;gt;: for floating point comparisons.&lt;br /&gt;
*&amp;lt;code&amp;gt;toThrow&amp;lt;/code&amp;gt;: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The &amp;lt;code&amp;gt;describe&amp;lt;/code&amp;gt; function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If they are named well, specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite [http://en.wikipedia.org/wiki/Don't_repeat_yourself DRY] up any duplicated setup and teardown code, Jasmine provides the global &amp;lt;code&amp;gt;beforeEach&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;afterEach&amp;lt;/code&amp;gt; functions. As the name implies the &amp;lt;code&amp;gt;beforeEach&amp;lt;/code&amp;gt; function is called once before each spec in the describe is run and the &amp;lt;code&amp;gt;afterEach&amp;lt;/code&amp;gt; function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
In Jasmine, test doubles are called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the &amp;lt;code&amp;gt;describe&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;it&amp;lt;/code&amp;gt; block it is defined in, and is removed after each spec. &lt;br /&gt;
There are special matchers for interacting with spies.&lt;br /&gt;
The &amp;lt;code&amp;gt;toHaveBeenCalled&amp;lt;/code&amp;gt; matcher returns true if the spy is called. The &amp;lt;code&amp;gt;toHaveBeenCalledWith&amp;lt;/code&amp;gt; matcher returns true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions &amp;lt;code&amp;gt;runs&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;waitsFor&amp;lt;/code&amp;gt;:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;runs&amp;lt;/code&amp;gt; – takes the asynchronous function for execution;&lt;br /&gt;
*&amp;lt;code&amp;gt;waitsFor&amp;lt;/code&amp;gt; – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code. It is installed with a call to &amp;lt;code&amp;gt;jasmine.clock().install&amp;lt;/code&amp;gt; in a spec or suite that needs to manipulate time. The clock needs to be uninstalled after the original functions are restored.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
Functions like &amp;lt;code&amp;gt;setTimeout&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;setInterval&amp;lt;/code&amp;gt; can be made synchronous executing the registered functions only once the clock is ticked forward in time. To execute registered functions, move time forward via the &amp;lt;code&amp;gt;jasmine.clock().tick&amp;lt;/code&amp;gt; function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If not provided with a base time to &amp;lt;code&amp;gt;mockDate&amp;lt;/code&amp;gt; it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following example demonstrates usage of jasmine Clock.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
&amp;lt;code&amp;gt;jasmine.any&amp;lt;/code&amp;gt; takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
[http://behaviour-driven.org/ Behavior Driven Development] (abbreviated as BDD) is a software development process that was developed in response to issues encountered with [http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)].&lt;br /&gt;
BDD is based on the techniques and principles of TDD, while combining these with ideas from domain-driven design and object-oriented analysis and design. BDD focuses on the behavioral specification of software units.&lt;br /&gt;
&lt;br /&gt;
While TDD is quite non-specific about what should be tested and at what level of detail, BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.&lt;br /&gt;
BDD also specifies how the behavior should be specified. BDD uses a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design.&lt;br /&gt;
&lt;br /&gt;
Generally TDD suggests writing unit tests at the beginning of the application development process to help the developer design the code. This helps the developer design the object and method interfaces through test, and refactor the code and tests as the code matures. These tests are often written as a white box test-inside-out that test the specific implementation of a piece of code.&lt;br /&gt;
BDD also emphasizes writing unit tests, but instead of focusing on the inside-out test approach, it approaches the test from a business value perspective which tests outside-in. &lt;br /&gt;
BDD emphasizes that test authors focus on why a piece of code is necessary, and what its goal is. &amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This approach is adopted in the way all tests are written in Jasmine. In Jasmine each test describes the behavior of the unit under test, through an &amp;quot;it should do the following&amp;quot; kind of clause.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Comparison between Jasmine, Qunit and Mocha=&lt;br /&gt;
The following gives a difference between three popular JavaScript test frameworks - Jasmine, Qunit and Mocha.&amp;lt;ref name=&amp;quot;Comparison&amp;quot;&amp;gt;https://github.com/thegrtman/javascript-test-framework-comparison&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;table border=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Frameworks &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Pros &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Cons &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt; [http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup for node through jasmine-node.&lt;br /&gt;
*Fluent syntax for assertions built-in, and works well with other assertion libraries&lt;br /&gt;
*Supported by many [http://en.wikipedia.org/wiki/Continuous_integration CI servers]  ([https://www.jetbrains.com/teamcity/ TeamCity], [https://www.codeship.io/ Codeship], etc.) &lt;br /&gt;
*Descriptive syntax for BDD paradigm.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Expects a specific suffix to all test files.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/QUnit Qunit]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Lots of support across the board, from Q&amp;amp;A to [http://en.wikipedia.org/wiki/Continuous_integration CI server] support.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Configuration is really difficult, and must constantly be maintained.&lt;br /&gt;
*Including assertion libraries is difficult.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup&lt;br /&gt;
*Supported by some CI servers and plugins for others.&lt;br /&gt;
*Has aliases for functions to be more BDD-oriented or TDD-oriented.&lt;br /&gt;
*Highly extensible.&lt;br /&gt;
*Asynchronous testing is easy.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*It's relatively new so support might be lacking in certain areas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;/&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha] is preferred for asynchronous testing,better flexibility and better usability.&amp;lt;ref name=&amp;quot;difference&amp;quot;&amp;gt;http://www.techtalkdc.com/which-javascript-test-library-should-you-use-qunit-vs-jasmine-vs-mocha/&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
*[http://en.wikipedia.org/wiki/JavaScript Javascript]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)]&lt;br /&gt;
*[http://rspec.info/ RSpec]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/QUnit Qunit]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89538</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89538"/>
		<updated>2014-10-13T20:31:41Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Comparison between Jasmine, Qunit and Mocha */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Jasmine'''&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for [http://en.wikipedia.org/wiki/JavaScript JavaScript]. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the [http://en.wikipedia.org/wiki/MIT_License MIT license]. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
Jasmine is often used in the [http://en.wikipedia.org/wiki/Ruby_on_Rails Rails framework]. Jasmine is available as a [http://en.wikipedia.org/wiki/RubyGems Rubygem] and it automates common workflows by leveraging known rake tasks and generators. Jasmine is highly influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It shouldn't be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* It should have idiomatic and unsurprising syntax.&lt;br /&gt;
* It should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* It shouldn't intrude in an application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* It should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It should encourage good testing practices.&lt;br /&gt;
* It should integrate easily with continuous build systems.&lt;br /&gt;
* It should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If they are named well, specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.The clock needs to be uninstalled after the original functions are restored.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
Functions like setTimeout or setInterval can be made synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If not provided with a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
[http://behaviour-driven.org/ Behavior Driven Development] (abbreviated as BDD) is a software development process that was developed in response to issues encountered with [http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)].&lt;br /&gt;
BDD is based on the techniques and principles of TDD, while combining these with ideas from domain-driven design and object-oriented analysis and design. BDD focuses on the behavioral specification of software units.&lt;br /&gt;
&lt;br /&gt;
While TDD is quite non-specific about what should be tested and at what level of detail, BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.&lt;br /&gt;
BDD also specifies how the behavior should be specified. BDD uses a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design.&lt;br /&gt;
&lt;br /&gt;
Generally TDD suggests writing unit tests at the beginning of the application development process to help the developer design the code. This helps the developer design the object and method interfaces through test, and refactor the code and tests as the code matures. These tests are often written as a white box test-inside-out that test the specific implementation of a piece of code.&lt;br /&gt;
BDD also emphasizes writing unit tests, but instead of focusing on the inside-out test approach, it approaches the test from a business value perspective which tests outside-in. &lt;br /&gt;
BDD emphasizes that test authors focus on why a piece of code is necessary, and what its goal is. &amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This approach is adopted in the way all tests are written in Jasmine. In Jasmine each test describes the behavior of the unit under test, through an &amp;quot;it should do the following&amp;quot; kind of clause.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Comparison between Jasmine, Qunit and Mocha=&lt;br /&gt;
The following gives a difference between Jasmine, Qunit and Mocha.&amp;lt;ref name=&amp;quot;Comparison&amp;quot;&amp;gt;https://github.com/thegrtman/javascript-test-framework-comparison&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;table border=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Frameworks &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Pros &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Cons &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt; [http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup for node through jasmine-node.&lt;br /&gt;
*Fluent syntax for assertions built-in, and works well with other assertion libraries&lt;br /&gt;
*Supported by many [http://en.wikipedia.org/wiki/Continuous_integration CI servers]  ([https://www.jetbrains.com/teamcity/ TeamCity], [https://www.codeship.io/ Codeship], etc.) &lt;br /&gt;
*Descriptive syntax for BDD paradigm.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Expects a specific suffix to all test files.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/QUnit Qunit]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Lots of support across the board, from Q&amp;amp;A to [http://en.wikipedia.org/wiki/Continuous_integration CI server] support.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Configuration is really difficult, and must constantly be maintained.&lt;br /&gt;
*Including assertion libraries is difficult.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup&lt;br /&gt;
*Supported by some CI servers and plugins for others.&lt;br /&gt;
*Has aliases for functions to be more BDD-oriented or TDD-oriented.&lt;br /&gt;
*Highly extensible.&lt;br /&gt;
*Asynchronous testing is easy.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*It's relatively new so support might be lacking in certain areas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;/&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha] is preferred for asynchronous testing,better flexibility and better usability.&amp;lt;ref name=&amp;quot;difference&amp;quot;&amp;gt;http://www.techtalkdc.com/which-javascript-test-library-should-you-use-qunit-vs-jasmine-vs-mocha/&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
*[http://en.wikipedia.org/wiki/JavaScript Javascript]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)]&lt;br /&gt;
*[http://rspec.info/ RSpec]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/QUnit Qunit]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89533</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89533"/>
		<updated>2014-10-13T20:27:19Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Suites */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Jasmine'''&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for [http://en.wikipedia.org/wiki/JavaScript JavaScript]. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the [http://en.wikipedia.org/wiki/MIT_License MIT license]. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
Jasmine is often used in the [http://en.wikipedia.org/wiki/Ruby_on_Rails Rails framework]. Jasmine is available as a [http://en.wikipedia.org/wiki/RubyGems Rubygem] and it automates common workflows by leveraging known rake tasks and generators. Jasmine is highly influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It shouldn't be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* It should have idiomatic and unsurprising syntax.&lt;br /&gt;
* It should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* It shouldn't intrude in an application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* It should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It should encourage good testing practices.&lt;br /&gt;
* It should integrate easily with continuous build systems.&lt;br /&gt;
* It should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If they are named well, specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.The clock needs to be uninstalled after the original functions are restored.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
Functions like setTimeout or setInterval can be made synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If not provided with a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
[http://behaviour-driven.org/ Behavior Driven Development] (abbreviated as BDD) is a software development process that was developed in response to issues encountered with [http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)].&lt;br /&gt;
BDD is based on the techniques and principles of TDD, while combining these with ideas from domain-driven design and object-oriented analysis and design. BDD focuses on the behavioral specification of software units.&lt;br /&gt;
&lt;br /&gt;
While TDD is quite non-specific about what should be tested and at what level of detail, BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.&lt;br /&gt;
BDD also specifies how the behavior should be specified. BDD uses a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design.&lt;br /&gt;
&lt;br /&gt;
Generally TDD suggests writing unit tests at the beginning of the application development process to help the developer design the code. This helps the developer design the object and method interfaces through test, and refactor the code and tests as the code matures. These tests are often written as a white box test-inside-out that test the specific implementation of a piece of code.&lt;br /&gt;
BDD also emphasizes writing unit tests, but instead of focusing on the inside-out test approach, it approaches the test from a business value perspective which tests outside-in. &lt;br /&gt;
BDD emphasizes that test authors focus on why a piece of code is necessary, and what its goal is. &amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This approach is adopted in the way all tests are written in Jasmine. In Jasmine each test describes the behavior of the unit under test, through an &amp;quot;it should do the following&amp;quot; kind of clause.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Comparison between Jasmine, Qunit and Mocha=&lt;br /&gt;
The following gives a difference between Jasmine, Qunit and Mocha.&amp;lt;ref name=&amp;quot;Comparison&amp;quot;&amp;gt;https://github.com/thegrtman/javascript-test-framework-comparison&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;table border=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Frameworks &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Pros &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Cons &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt; [http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup for node through jasmine-node.&lt;br /&gt;
*Fluent syntax for assertions built-in, and works well with other assertion libraries&lt;br /&gt;
*Supported by many [http://en.wikipedia.org/wiki/Continuous_integration CI servers]  ([https://www.jetbrains.com/teamcity/ TeamCity], [https://www.codeship.io/ Codeship], etc.) &lt;br /&gt;
*Descriptive syntax for BDD paradigm.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Expects a specific suffix to all test files.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/QUnit Qunit]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Lots of support across the board, from Q&amp;amp;A to [http://en.wikipedia.org/wiki/Continuous_integration CI servers] server support.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Configuration is really difficult, and must constantly be maintained.&lt;br /&gt;
*Including assertion libraries is difficult.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup&lt;br /&gt;
*Supported by some CI servers and plugins for others.&lt;br /&gt;
*Has aliases for functions to be more BDD-oriented or TDD-oriented.&lt;br /&gt;
*Highly extensible.&lt;br /&gt;
*Asynchronous testing is easy.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*It's relatively new so support might be lacking in certain areas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;/&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha] is preferred for asynchronous testing,better flexibility and better usability.&amp;lt;ref name=&amp;quot;difference&amp;quot;&amp;gt;http://www.techtalkdc.com/which-javascript-test-library-should-you-use-qunit-vs-jasmine-vs-mocha/&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
*[http://en.wikipedia.org/wiki/JavaScript Javascript]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)]&lt;br /&gt;
*[http://rspec.info/ RSpec]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/QUnit Qunit]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89532</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89532"/>
		<updated>2014-10-13T20:23:38Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Drawbacks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Jasmine'''&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for [http://en.wikipedia.org/wiki/JavaScript JavaScript]. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the [http://en.wikipedia.org/wiki/MIT_License MIT license]. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
Jasmine is often used in the [http://en.wikipedia.org/wiki/Ruby_on_Rails Rails framework]. Jasmine is available as a [http://en.wikipedia.org/wiki/RubyGems Rubygem] and it automates common workflows by leveraging known rake tasks and generators. Jasmine is highly influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It shouldn't be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* It should have idiomatic and unsurprising syntax.&lt;br /&gt;
* It should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* It shouldn't intrude in an application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* It should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It should encourage good testing practices.&lt;br /&gt;
* It should integrate easily with continuous build systems.&lt;br /&gt;
* It should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If they are named well, specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.The clock needs to be uninstalled after the original functions are restored.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
Functions like setTimeout or setInterval can be made synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If not provided with a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
[http://behaviour-driven.org/ Behavior Driven Development] (abbreviated as BDD) is a software development process that was developed in response to issues encountered with [http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)].&lt;br /&gt;
BDD is based on the techniques and principles of TDD, while combining these with ideas from domain-driven design and object-oriented analysis and design. BDD focuses on the behavioral specification of software units.&lt;br /&gt;
&lt;br /&gt;
While TDD is quite non-specific about what should be tested and at what level of detail, BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.&lt;br /&gt;
BDD also specifies how the behavior should be specified. BDD uses a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design.&lt;br /&gt;
&lt;br /&gt;
Generally TDD suggests writing unit tests at the beginning of the application development process to help the developer design the code. This helps the developer design the object and method interfaces through test, and refactor the code and tests as the code matures. These tests are often written as a white box test-inside-out that test the specific implementation of a piece of code.&lt;br /&gt;
BDD also emphasizes writing unit tests, but instead of focusing on the inside-out test approach, it approaches the test from a business value perspective which tests outside-in. &lt;br /&gt;
BDD emphasizes that test authors focus on why a piece of code is necessary, and what its goal is. &amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This approach is adopted in the way all tests are written in Jasmine. In Jasmine each test describes the behavior of the unit under test, through an &amp;quot;it should do the following&amp;quot; kind of clause.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Comparison between Jasmine, Qunit and Mocha=&lt;br /&gt;
The following gives a difference between Jasmine, Qunit and Mocha.&amp;lt;ref name=&amp;quot;Comparison&amp;quot;&amp;gt;https://github.com/thegrtman/javascript-test-framework-comparison&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;table border=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Frameworks &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Pros &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Cons &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt; [http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup for node through jasmine-node.&lt;br /&gt;
*Fluent syntax for assertions built-in, and works well with other assertion libraries&lt;br /&gt;
*Supported by many [http://en.wikipedia.org/wiki/Continuous_integration CI servers]  ([https://www.jetbrains.com/teamcity/ TeamCity], [https://www.codeship.io/ Codeship], etc.) &lt;br /&gt;
*Descriptive syntax for BDD paradigm.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Expects a specific suffix to all test files.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/QUnit Qunit]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Lots of support across the board, from Q&amp;amp;A to [http://en.wikipedia.org/wiki/Continuous_integration CI servers] server support.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Configuration is really difficult, and must constantly be maintained.&lt;br /&gt;
*Including assertion libraries is difficult.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup&lt;br /&gt;
*Supported by some CI servers and plugins for others.&lt;br /&gt;
*Has aliases for functions to be more BDD-oriented or TDD-oriented.&lt;br /&gt;
*Highly extensible.&lt;br /&gt;
*Asynchronous testing is easy.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*It's relatively new so support might be lacking in certain areas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;/&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha] is preferred for asynchronous testing,better flexibility and better usability.&amp;lt;ref name=&amp;quot;difference&amp;quot;&amp;gt;http://www.techtalkdc.com/which-javascript-test-library-should-you-use-qunit-vs-jasmine-vs-mocha/&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
*[http://en.wikipedia.org/wiki/JavaScript Javascript]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)]&lt;br /&gt;
*[http://rspec.info/ RSpec]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/QUnit Qunit]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89531</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89531"/>
		<updated>2014-10-13T20:21:21Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Comparison between Jasmine, Qunit and Mocha */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Jasmine'''&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for [http://en.wikipedia.org/wiki/JavaScript JavaScript]. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the [http://en.wikipedia.org/wiki/MIT_License MIT license]. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
Jasmine is often used in the [http://en.wikipedia.org/wiki/Ruby_on_Rails Rails framework]. Jasmine is available as a [http://en.wikipedia.org/wiki/RubyGems Rubygem] and it automates common workflows by leveraging known rake tasks and generators. Jasmine is highly influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It shouldn't be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* It should have idiomatic and unsurprising syntax.&lt;br /&gt;
* It should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* It shouldn't intrude in an application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* It should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It should encourage good testing practices.&lt;br /&gt;
* It should integrate easily with continuous build systems.&lt;br /&gt;
* It should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If they are named well, specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.The clock needs to be uninstalled after the original functions are restored.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
Functions like setTimeout or setInterval can be made synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If not provided with a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
[http://behaviour-driven.org/ Behavior Driven Development] (abbreviated as BDD) is a software development process that was developed in response to issues encountered with [http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)].&lt;br /&gt;
BDD is based on the techniques and principles of TDD, while combining these with ideas from domain-driven design and object-oriented analysis and design. BDD focuses on the behavioral specification of software units.&lt;br /&gt;
&lt;br /&gt;
While TDD is quite non-specific about what should be tested and at what level of detail, BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.&lt;br /&gt;
BDD also specifies how the behavior should be specified. BDD uses a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design.&lt;br /&gt;
&lt;br /&gt;
Generally TDD suggests writing unit tests at the beginning of the application development process to help the developer design the code. This helps the developer design the object and method interfaces through test, and refactor the code and tests as the code matures. These tests are often written as a white box test-inside-out that test the specific implementation of a piece of code.&lt;br /&gt;
BDD also emphasizes writing unit tests, but instead of focusing on the inside-out test approach, it approaches the test from a business value perspective which tests outside-in. &lt;br /&gt;
BDD emphasizes that test authors focus on why a piece of code is necessary, and what its goal is. &amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This approach is adopted in the way all tests are written in Jasmine. In Jasmine each test describes the behavior of the unit under test, through an &amp;quot;it should do the following&amp;quot; kind of clause.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Comparison between Jasmine, Qunit and Mocha=&lt;br /&gt;
The following gives a difference between Jasmine, Qunit and Mocha.&amp;lt;ref name=&amp;quot;Comparison&amp;quot;&amp;gt;https://github.com/thegrtman/javascript-test-framework-comparison&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;table border=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Frameworks &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Pros &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Cons &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt; [http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup for node through jasmine-node.&lt;br /&gt;
*Fluent syntax for assertions built-in, and works well with other assertion libraries&lt;br /&gt;
*Supported by many [http://en.wikipedia.org/wiki/Continuous_integration CI servers]  ([https://www.jetbrains.com/teamcity/ TeamCity], [https://www.codeship.io/ Codeship], etc.) &lt;br /&gt;
*Descriptive syntax for BDD paradigm.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Expects a specific suffix to all test files.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/QUnit Qunit]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Lots of support across the board, from Q&amp;amp;A to [http://en.wikipedia.org/wiki/Continuous_integration CI servers] server support.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Configuration is really difficult, and must constantly be maintained.&lt;br /&gt;
*Including assertion libraries is difficult.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup&lt;br /&gt;
*Supported by some CI servers and plugins for others.&lt;br /&gt;
*Has aliases for functions to be more BDD-oriented or TDD-oriented.&lt;br /&gt;
*Highly extensible.&lt;br /&gt;
*Asynchronous testing is easy.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*It's relatively new so support might be lacking in certain areas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;/&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
* For asynchronous testing,more flexibility and usability [http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha] is preferred.&amp;lt;ref name=&amp;quot;difference&amp;quot;&amp;gt;http://www.techtalkdc.com/which-javascript-test-library-should-you-use-qunit-vs-jasmine-vs-mocha/&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
*[http://en.wikipedia.org/wiki/JavaScript Javascript]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)]&lt;br /&gt;
*[http://rspec.info/ RSpec]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/QUnit Qunit]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89530</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89530"/>
		<updated>2014-10-13T20:19:09Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Jasmine'''&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for [http://en.wikipedia.org/wiki/JavaScript JavaScript]. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the [http://en.wikipedia.org/wiki/MIT_License MIT license]. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
Jasmine is often used in the [http://en.wikipedia.org/wiki/Ruby_on_Rails Rails framework]. Jasmine is available as a [http://en.wikipedia.org/wiki/RubyGems Rubygem] and it automates common workflows by leveraging known rake tasks and generators. Jasmine is highly influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It shouldn't be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* It should have idiomatic and unsurprising syntax.&lt;br /&gt;
* It should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* It shouldn't intrude in an application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* It should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It should encourage good testing practices.&lt;br /&gt;
* It should integrate easily with continuous build systems.&lt;br /&gt;
* It should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If they are named well, specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.The clock needs to be uninstalled after the original functions are restored.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
Functions like setTimeout or setInterval can be made synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If not provided with a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
[http://behaviour-driven.org/ Behavior Driven Development] (abbreviated as BDD) is a software development process that was developed in response to issues encountered with [http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)].&lt;br /&gt;
BDD is based on the techniques and principles of TDD, while combining these with ideas from domain-driven design and object-oriented analysis and design. BDD focuses on the behavioral specification of software units.&lt;br /&gt;
&lt;br /&gt;
While TDD is quite non-specific about what should be tested and at what level of detail, BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.&lt;br /&gt;
BDD also specifies how the behavior should be specified. BDD uses a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design.&lt;br /&gt;
&lt;br /&gt;
Generally TDD suggests writing unit tests at the beginning of the application development process to help the developer design the code. This helps the developer design the object and method interfaces through test, and refactor the code and tests as the code matures. These tests are often written as a white box test-inside-out that test the specific implementation of a piece of code.&lt;br /&gt;
BDD also emphasizes writing unit tests, but instead of focusing on the inside-out test approach, it approaches the test from a business value perspective which tests outside-in. &lt;br /&gt;
BDD emphasizes that test authors focus on why a piece of code is necessary, and what its goal is. &amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This approach is adopted in the way all tests are written in Jasmine. In Jasmine each test describes the behavior of the unit under test, through an &amp;quot;it should do the following&amp;quot; kind of clause.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Comparison between Jasmine, Qunit and Mocha=&lt;br /&gt;
The following gives a difference between Jasmine, Qunit and Mocha.&amp;lt;ref name=&amp;quot;Comparison&amp;quot;&amp;gt;https://github.com/thegrtman/javascript-test-framework-comparison&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;table border=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Frameworks &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Pros &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Cons &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt; [http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup for node through jasmine-node&lt;br /&gt;
*Fluent syntax for assertions built-in, and works well with other assertion libraries&lt;br /&gt;
*Supported by many [http://en.wikipedia.org/wiki/Continuous_integration CI servers]  ([https://www.jetbrains.com/teamcity/ TeamCity], [https://www.codeship.io/ Codeship], etc.) &lt;br /&gt;
*Descriptive syntax for BDD paradigm.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Expects a specific suffix to all test files.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/QUnit Qunit]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Lots of support across the board, from Q&amp;amp;A to [http://en.wikipedia.org/wiki/Continuous_integration CI servers] server support.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Configuration is really difficult, and must constantly be maintained.&lt;br /&gt;
*Including assertion libraries is difficult.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup&lt;br /&gt;
*Supported by some CI servers and plugins for others.&lt;br /&gt;
*Has aliases for functions to be more BDD-oriented or TDD-oriented.&lt;br /&gt;
*Highly extensible.&lt;br /&gt;
*Asynchronous testing is easy.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*It's relatively new so support might be lacking in certain areas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;/&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
* For asynchronous testing,more flexibility and usability [http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha] is preferred.&amp;lt;ref name=&amp;quot;difference&amp;quot;&amp;gt;http://www.techtalkdc.com/which-javascript-test-library-should-you-use-qunit-vs-jasmine-vs-mocha/&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
*[http://en.wikipedia.org/wiki/JavaScript Javascript]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)]&lt;br /&gt;
*[http://rspec.info/ RSpec]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/QUnit Qunit]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89529</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89529"/>
		<updated>2014-10-13T20:18:35Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Comparison between Jasmine, Qunit and Mocha */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Jasmine'''&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for [http://en.wikipedia.org/wiki/JavaScript JavaScript]. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the [http://en.wikipedia.org/wiki/MIT_License MIT license]. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
Jasmine is often used in the [http://en.wikipedia.org/wiki/Ruby_on_Rails Rails framework]. Jasmine is available as a [http://en.wikipedia.org/wiki/RubyGems Rubygem] and it automates common workflows by leveraging known rake tasks and generators. Jasmine is highly influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It shouldn't be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* It should have idiomatic and unsurprising syntax.&lt;br /&gt;
* It should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* It shouldn't intrude in an application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* It should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It should encourage good testing practices.&lt;br /&gt;
* It should integrate easily with continuous build systems.&lt;br /&gt;
* It should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If they are named well, specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.The clock needs to be uninstalled after the original functions are restored.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
Functions like setTimeout or setInterval can be made synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If not provided with a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
[http://behaviour-driven.org/ Behavior Driven Development] (abbreviated as BDD) is a software development process that was developed in response to issues encountered with [http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)].&lt;br /&gt;
BDD is based on the techniques and principles of TDD, while combining these with ideas from domain-driven design and object-oriented analysis and design. BDD focuses on the behavioral specification of software units.&lt;br /&gt;
&lt;br /&gt;
While TDD is quite non-specific about what should be tested and at what level of detail, BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.&lt;br /&gt;
BDD also specifies how the behavior should be specified. BDD uses a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design.&lt;br /&gt;
&lt;br /&gt;
Generally TDD suggests writing unit tests at the beginning of the application development process to help the developer design the code. This helps the developer design the object and method interfaces through test, and refactor the code and tests as the code matures. These tests are often written as a white box test-inside-out that test the specific implementation of a piece of code.&lt;br /&gt;
BDD also emphasizes writing unit tests, but instead of focusing on the inside-out test approach, it approaches the test from a business value perspective which tests outside-in. &lt;br /&gt;
BDD emphasizes that test authors focus on why a piece of code is necessary, and what its goal is. &amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This approach is adopted in the way all tests are written in Jasmine. In Jasmine each test describes the behavior of the unit under test, through an &amp;quot;it should do the following&amp;quot; kind of clause.&lt;br /&gt;
&lt;br /&gt;
=Comparison between Jasmine, Qunit and Mocha=&lt;br /&gt;
The following gives a difference between Jasmine, Qunit and Mocha.&amp;lt;ref name=&amp;quot;Comparison&amp;quot;&amp;gt;https://github.com/thegrtman/javascript-test-framework-comparison&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;table border=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Frameworks &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Pros &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Cons &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt; [http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup for node through jasmine-node&lt;br /&gt;
*Fluent syntax for assertions built-in, and works well with other assertion libraries&lt;br /&gt;
*Supported by many [http://en.wikipedia.org/wiki/Continuous_integration CI servers]  ([https://www.jetbrains.com/teamcity/ TeamCity], [https://www.codeship.io/ Codeship], etc.) &lt;br /&gt;
*Descriptive syntax for BDD paradigm.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Expects a specific suffix to all test files.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/QUnit Qunit]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Lots of support across the board, from Q&amp;amp;A to [http://en.wikipedia.org/wiki/Continuous_integration CI servers] server support.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Configuration is really difficult, and must constantly be maintained.&lt;br /&gt;
*Including assertion libraries is difficult.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup&lt;br /&gt;
*Supported by some CI servers and plugins for others.&lt;br /&gt;
*Has aliases for functions to be more BDD-oriented or TDD-oriented.&lt;br /&gt;
*Highly extensible.&lt;br /&gt;
*Asynchronous testing is easy.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*It's relatively new so support might be lacking in certain areas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;/&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
* For asynchronous testing,more flexibility and usability [http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha] is preferred.&amp;lt;ref name=&amp;quot;difference&amp;quot;&amp;gt;http://www.techtalkdc.com/which-javascript-test-library-should-you-use-qunit-vs-jasmine-vs-mocha/&amp;lt;/ref&amp;gt;&lt;br /&gt;
=See Also=&lt;br /&gt;
*[http://en.wikipedia.org/wiki/JavaScript Javascript]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)]&lt;br /&gt;
*[http://rspec.info/ RSpec]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/QUnit Qunit]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89526</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89526"/>
		<updated>2014-10-13T20:17:14Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Comparison between Jasmine, Qunit and Mocha */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Jasmine'''&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for [http://en.wikipedia.org/wiki/JavaScript JavaScript]. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the [http://en.wikipedia.org/wiki/MIT_License MIT license]. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
Jasmine is often used in the [http://en.wikipedia.org/wiki/Ruby_on_Rails Rails framework]. Jasmine is available as a [http://en.wikipedia.org/wiki/RubyGems Rubygem] and it automates common workflows by leveraging known rake tasks and generators. Jasmine is highly influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It shouldn't be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* It should have idiomatic and unsurprising syntax.&lt;br /&gt;
* It should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* It shouldn't intrude in an application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* It should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It should encourage good testing practices.&lt;br /&gt;
* It should integrate easily with continuous build systems.&lt;br /&gt;
* It should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If they are named well, specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.The clock needs to be uninstalled after the original functions are restored.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
Functions like setTimeout or setInterval can be made synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If not provided with a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
[http://behaviour-driven.org/ Behavior Driven Development] (abbreviated as BDD) is a software development process that was developed in response to issues encountered with [http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)].&lt;br /&gt;
BDD is based on the techniques and principles of TDD, while combining these with ideas from domain-driven design and object-oriented analysis and design. BDD focuses on the behavioral specification of software units.&lt;br /&gt;
&lt;br /&gt;
While TDD is quite non-specific about what should be tested and at what level of detail, BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.&lt;br /&gt;
BDD also specifies how the behavior should be specified. BDD uses a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design.&lt;br /&gt;
&lt;br /&gt;
Generally TDD suggests writing unit tests at the beginning of the application development process to help the developer design the code. This helps the developer design the object and method interfaces through test, and refactor the code and tests as the code matures. These tests are often written as a white box test-inside-out that test the specific implementation of a piece of code.&lt;br /&gt;
BDD also emphasizes writing unit tests, but instead of focusing on the inside-out test approach, it approaches the test from a business value perspective which tests outside-in. &lt;br /&gt;
BDD emphasizes that test authors focus on why a piece of code is necessary, and what its goal is. &amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This approach is adopted in the way all tests are written in Jasmine. In Jasmine each test describes the behavior of the unit under test, through an &amp;quot;it should do the following&amp;quot; kind of clause.&lt;br /&gt;
&lt;br /&gt;
=Comparison between Jasmine, Qunit and Mocha=&lt;br /&gt;
The following gives a difference between Jasmine, Qunit and Mocha.&amp;lt;ref name=&amp;quot;Comparison&amp;quot;&amp;gt;https://github.com/thegrtman/javascript-test-framework-comparison&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;table border=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Frameworks &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Pros &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Cons &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt; [http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup for node through jasmine-node&lt;br /&gt;
*Fluent syntax for assertions built-in, and works well with other assertion libraries&lt;br /&gt;
*Supported by many [http://en.wikipedia.org/wiki/Continuous_integration CI servers]  ([https://www.jetbrains.com/teamcity/ TeamCity], [https://www.codeship.io/ Codeship], etc.) &lt;br /&gt;
*Descriptive syntax for BDD paradigm&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Expects a specific suffix to all test files.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/QUnit Qunit]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Lots of support across the board, from Q&amp;amp;A to [http://en.wikipedia.org/wiki/Continuous_integration CI servers] server support&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Configuration is really difficult, and must constantly be maintained&lt;br /&gt;
*Including 3rd party libraries (like assertion libraries) is  difficult&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup&lt;br /&gt;
*Supported by some CI servers and plugins for others (jenkins has a maven plugin)&lt;br /&gt;
*Has aliases for functions to be more BDD-oriented or TDD-oriented&lt;br /&gt;
*Highly extensible&lt;br /&gt;
*Asynchronous testing is easy&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*It's relatively new so support might be lacking in certain areas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;/&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
* For asynchronous testing,more flexibility and usability [http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha] is preferred.&amp;lt;ref name=&amp;quot;difference&amp;quot;&amp;gt;http://www.techtalkdc.com/which-javascript-test-library-should-you-use-qunit-vs-jasmine-vs-mocha/&amp;lt;/ref&amp;gt;&lt;br /&gt;
=See Also=&lt;br /&gt;
*[http://en.wikipedia.org/wiki/JavaScript Javascript]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)]&lt;br /&gt;
*[http://rspec.info/ RSpec]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/QUnit Qunit]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89524</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89524"/>
		<updated>2014-10-13T20:16:45Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Comparison between Jasmine, Qunit and Mocha */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Jasmine'''&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for [http://en.wikipedia.org/wiki/JavaScript JavaScript]. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the [http://en.wikipedia.org/wiki/MIT_License MIT license]. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
Jasmine is often used in the [http://en.wikipedia.org/wiki/Ruby_on_Rails Rails framework]. Jasmine is available as a [http://en.wikipedia.org/wiki/RubyGems Rubygem] and it automates common workflows by leveraging known rake tasks and generators. Jasmine is highly influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It shouldn't be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* It should have idiomatic and unsurprising syntax.&lt;br /&gt;
* It should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* It shouldn't intrude in an application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* It should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It should encourage good testing practices.&lt;br /&gt;
* It should integrate easily with continuous build systems.&lt;br /&gt;
* It should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If they are named well, specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.The clock needs to be uninstalled after the original functions are restored.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
Functions like setTimeout or setInterval can be made synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If not provided with a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
[http://behaviour-driven.org/ Behavior Driven Development] (abbreviated as BDD) is a software development process that was developed in response to issues encountered with [http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)].&lt;br /&gt;
BDD is based on the techniques and principles of TDD, while combining these with ideas from domain-driven design and object-oriented analysis and design. BDD focuses on the behavioral specification of software units.&lt;br /&gt;
&lt;br /&gt;
While TDD is quite non-specific about what should be tested and at what level of detail, BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.&lt;br /&gt;
BDD also specifies how the behavior should be specified. BDD uses a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design.&lt;br /&gt;
&lt;br /&gt;
Generally TDD suggests writing unit tests at the beginning of the application development process to help the developer design the code. This helps the developer design the object and method interfaces through test, and refactor the code and tests as the code matures. These tests are often written as a white box test-inside-out that test the specific implementation of a piece of code.&lt;br /&gt;
BDD also emphasizes writing unit tests, but instead of focusing on the inside-out test approach, it approaches the test from a business value perspective which tests outside-in. &lt;br /&gt;
BDD emphasizes that test authors focus on why a piece of code is necessary, and what its goal is. &amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This approach is adopted in the way all tests are written in Jasmine. In Jasmine each test describes the behavior of the unit under test, through an &amp;quot;it should do the following&amp;quot; kind of clause.&lt;br /&gt;
&lt;br /&gt;
=Comparison between Jasmine, Qunit and Mocha=&lt;br /&gt;
The following gives a difference between Jasmine, Qunit and Mocha.&amp;lt;ref name=&amp;quot;Comparison&amp;quot;&amp;gt;https://github.com/thegrtman/javascript-test-framework-comparison&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;table border=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Frameworks &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Pros &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Cons &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt; [http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup for node through jasmine-node&lt;br /&gt;
*Fluent syntax for assertions built-in, and works well with other assertion libraries&lt;br /&gt;
*Supported by many [http://en.wikipedia.org/wiki/Continuous_integration CI] servers ([https://www.jetbrains.com/teamcity/ TeamCity], [https://www.codeship.io/ Codeship], etc.) &lt;br /&gt;
*Descriptive syntax for BDD paradigm&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Expects a specific suffix to all test files.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/QUnit Qunit]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Lots of support across the board, from Q&amp;amp;A to [http://en.wikipedia.org/wiki/Continuous_integration CI] server support&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Configuration is really difficult, and must constantly be maintained&lt;br /&gt;
*Including 3rd party libraries (like assertion libraries) is  difficult&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup&lt;br /&gt;
*Supported by some CI servers and plugins for others (jenkins has a maven plugin)&lt;br /&gt;
*Has aliases for functions to be more BDD-oriented or TDD-oriented&lt;br /&gt;
*Highly extensible&lt;br /&gt;
*Asynchronous testing is easy&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*It's relatively new so support might be lacking in certain areas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;/&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
* For asynchronous testing,more flexibility and usability [http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha] is preferred.&amp;lt;ref name=&amp;quot;difference&amp;quot;&amp;gt;http://www.techtalkdc.com/which-javascript-test-library-should-you-use-qunit-vs-jasmine-vs-mocha/&amp;lt;/ref&amp;gt;&lt;br /&gt;
=See Also=&lt;br /&gt;
*[http://en.wikipedia.org/wiki/JavaScript Javascript]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)]&lt;br /&gt;
*[http://rspec.info/ RSpec]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/QUnit Qunit]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89523</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89523"/>
		<updated>2014-10-13T20:06:27Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Jasmine'''&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for [http://en.wikipedia.org/wiki/JavaScript JavaScript]. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the [http://en.wikipedia.org/wiki/MIT_License MIT license]. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
Jasmine is often used in the [http://en.wikipedia.org/wiki/Ruby_on_Rails Rails framework]. Jasmine is available as a [http://en.wikipedia.org/wiki/RubyGems Rubygem] and it automates common workflows by leveraging known rake tasks and generators. Jasmine is highly influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It shouldn't be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* It should have idiomatic and unsurprising syntax.&lt;br /&gt;
* It should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* It shouldn't intrude in an application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* It should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It should encourage good testing practices.&lt;br /&gt;
* It should integrate easily with continuous build systems.&lt;br /&gt;
* It should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If they are named well, specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.The clock needs to be uninstalled after the original functions are restored.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
Functions like setTimeout or setInterval can be made synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If not provided with a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
[http://behaviour-driven.org/ Behavior Driven Development] (abbreviated as BDD) is a software development process that was developed in response to issues encountered with [http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)].&lt;br /&gt;
BDD is based on the techniques and principles of TDD, while combining these with ideas from domain-driven design and object-oriented analysis and design. BDD focuses on the behavioral specification of software units.&lt;br /&gt;
&lt;br /&gt;
While TDD is quite non-specific about what should be tested and at what level of detail, BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.&lt;br /&gt;
BDD also specifies how the behavior should be specified. BDD uses a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design.&lt;br /&gt;
&lt;br /&gt;
Generally TDD suggests writing unit tests at the beginning of the application development process to help the developer design the code. This helps the developer design the object and method interfaces through test, and refactor the code and tests as the code matures. These tests are often written as a white box test-inside-out that test the specific implementation of a piece of code.&lt;br /&gt;
BDD also emphasizes writing unit tests, but instead of focusing on the inside-out test approach, it approaches the test from a business value perspective which tests outside-in. &lt;br /&gt;
BDD emphasizes that test authors focus on why a piece of code is necessary, and what its goal is. &amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This approach is adopted in the way all tests are written in Jasmine. In Jasmine each test describes the behavior of the unit under test, through an &amp;quot;it should do the following&amp;quot; kind of clause.&lt;br /&gt;
&lt;br /&gt;
=Comparison between Jasmine, Qunit and Mocha=&lt;br /&gt;
The following gives a difference between Jasmine, Qunit and Mocha.&amp;lt;ref name=&amp;quot;Comparison&amp;quot;&amp;gt;https://github.com/thegrtman/javascript-test-framework-comparison&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;table border=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Frameworks &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Pros &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;th&amp;gt; Cons &amp;lt;/th&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt; [http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup for node through jasmine-node&lt;br /&gt;
*Fluent syntax for assertions built-in, and works well with other assertion libraries&lt;br /&gt;
*Supported by many CI servers (TeamCity, Codeship, etc.) and some that don't support natively have plugins (jenkins has a maven plugin)&lt;br /&gt;
*Descriptive syntax for BDD paradigm&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Expects a specific suffix to all test files (*spec.js by default)&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/QUnit Qunit]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Lots of support across the board, from Q&amp;amp;A to CI server support&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Asynchronous testing causes a lot of difficulties.&lt;br /&gt;
*Configuration is really difficult, and must constantly be maintained&lt;br /&gt;
*Including 3rd party libraries (like assertion libraries) is  difficult&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*Simple setup&lt;br /&gt;
*Supported by some CI servers and plugins for others (jenkins has a maven plugin)&lt;br /&gt;
*Has aliases for functions to be more BDD-oriented or TDD-oriented&lt;br /&gt;
*Highly extensible&lt;br /&gt;
*Asynchronous testing is easy&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
*It's relatively new so support might be lacking in certain areas.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;/&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
* For asynchronous testing,more flexibility and usability [http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha] is preferred.&amp;lt;ref name=&amp;quot;difference&amp;quot;&amp;gt;http://www.techtalkdc.com/which-javascript-test-library-should-you-use-qunit-vs-jasmine-vs-mocha/&amp;lt;/ref&amp;gt;&lt;br /&gt;
=See Also=&lt;br /&gt;
*[http://en.wikipedia.org/wiki/JavaScript Javascript]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)]&lt;br /&gt;
*[http://rspec.info/ RSpec]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/QUnit Qunit]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Mocha_(JavaScript_framework) Mocha]&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89522</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89522"/>
		<updated>2014-10-13T19:28:23Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Jasmine'''&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for [http://en.wikipedia.org/wiki/JavaScript JavaScript]. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the [http://en.wikipedia.org/wiki/MIT_License MIT license]. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
Jasmine is often used in the [http://en.wikipedia.org/wiki/Ruby_on_Rails Rails framework]. Jasmine is available as a [http://en.wikipedia.org/wiki/RubyGems Rubygem] and it automates common workflows by leveraging known rake tasks and generators. Jasmine is highly influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It shouldn't be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* It should have idiomatic and unsurprising syntax.&lt;br /&gt;
* It should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* It shouldn't intrude in an application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* It should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It should encourage good testing practices.&lt;br /&gt;
* It should integrate easily with continuous build systems.&lt;br /&gt;
* It should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If they are named well, specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.The clock needs to be uninstalled after the original functions are restored.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
Functions like setTimeout or setInterval can be made synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If not provided with a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
[http://behaviour-driven.org/ Behavior Driven Development] (abbreviated as BDD) is a software development process that was developed in response to issues encountered with [http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)].&lt;br /&gt;
BDD is based on the techniques and principles of TDD, while combining these with ideas from domain-driven design and object-oriented analysis and design. BDD focuses on the behavioral specification of software units.&lt;br /&gt;
&lt;br /&gt;
While TDD is quite non-specific about what should be tested and at what level of detail, BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.&lt;br /&gt;
BDD also specifies how the behavior should be specified. BDD uses a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design.&lt;br /&gt;
&lt;br /&gt;
Generally TDD suggests writing unit tests at the beginning of the application development process to help the developer design the code. This helps the developer design the object and method interfaces through test, and refactor the code and tests as the code matures. These tests are often written as a white box test-inside-out that test the specific implementation of a piece of code.&lt;br /&gt;
BDD also emphasizes writing unit tests, but instead of focusing on the inside-out test approach, it approaches the test from a business value perspective which tests outside-in. &lt;br /&gt;
BDD emphasizes that test authors focus on why a piece of code is necessary, and what its goal is. &amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This approach is adopted in the way all tests are written in Jasmine. In Jasmine each test describes the behavior of the unit under test, through an &amp;quot;it should do the following&amp;quot; kind of clause.&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;/&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
*[http://en.wikipedia.org/wiki/JavaScript Javascript]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)]&lt;br /&gt;
*[http://rspec.info/ RSpec]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/QUnit Qunit]&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89521</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89521"/>
		<updated>2014-10-13T19:22:09Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Goals */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Jasmine'''&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for [http://en.wikipedia.org/wiki/JavaScript JavaScript]. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the [http://en.wikipedia.org/wiki/MIT_License MIT license]. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
Jasmine is often used in the [http://en.wikipedia.org/wiki/Ruby_on_Rails Rails framework]. Jasmine is available as a [http://en.wikipedia.org/wiki/RubyGems Rubygem] and it automates common workflows by leveraging known rake tasks and generators. Jasmine is highly influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* Shouldn't be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* Should have idiomatic and unsurprising syntax.&lt;br /&gt;
* Should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* Shouldn't intrude in an application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* Should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* It should encourage good testing practices.&lt;br /&gt;
* It should integrate easily with continuous build systems.&lt;br /&gt;
* It should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If they are named well, specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.The clock needs to be uninstalled after the original functions are restored.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
Functions like setTimeout or setInterval can be made synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If not provided with a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
[http://behaviour-driven.org/ Behavior Driven Development] (abbreviated as BDD) is a software development process that was developed in response to issues encountered with [http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)].&lt;br /&gt;
BDD is based on the techniques and principles of TDD, while combining these with ideas from domain-driven design and object-oriented analysis and design. BDD focuses on the behavioral specification of software units.&lt;br /&gt;
&lt;br /&gt;
While TDD is quite non-specific about what should be tested and at what level of detail, BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.&lt;br /&gt;
BDD also specifies how the behavior should be specified. BDD uses a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design.&lt;br /&gt;
&lt;br /&gt;
Generally TDD suggests writing unit tests at the beginning of the application development process to help the developer design the code. This helps the developer design the object and method interfaces through test, and refactor the code and tests as the code matures. These tests are often written as a white box test-inside-out that test the specific implementation of a piece of code.&lt;br /&gt;
BDD also emphasizes writing unit tests, but instead of focusing on the inside-out test approach, it approaches the test from a business value perspective which tests outside-in. &lt;br /&gt;
BDD emphasizes that test authors focus on why a piece of code is necessary, and what its goal is. &amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This approach is adopted in the way all tests are written in Jasmine. In Jasmine each test describes the behavior of the unit under test, through an &amp;quot;it should do the following&amp;quot; kind of clause.&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;/&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
*[http://en.wikipedia.org/wiki/JavaScript Javascript]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)]&lt;br /&gt;
*[http://rspec.info/ RSpec]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/QUnit Qunit]&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89520</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89520"/>
		<updated>2014-10-13T19:21:52Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Design Principles */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Jasmine'''&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for [http://en.wikipedia.org/wiki/JavaScript JavaScript]. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the [http://en.wikipedia.org/wiki/MIT_License MIT license]. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
Jasmine is often used in the [http://en.wikipedia.org/wiki/Ruby_on_Rails Rails framework]. Jasmine is available as a [http://en.wikipedia.org/wiki/RubyGems Rubygem] and it automates common workflows by leveraging known rake tasks and generators. Jasmine is highly influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* Shouldn't be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* Should have idiomatic and unsurprising syntax.&lt;br /&gt;
* Should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* Shouldn't intrude in an application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* Should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If they are named well, specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.The clock needs to be uninstalled after the original functions are restored.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
Functions like setTimeout or setInterval can be made synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If not provided with a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
[http://behaviour-driven.org/ Behavior Driven Development] (abbreviated as BDD) is a software development process that was developed in response to issues encountered with [http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)].&lt;br /&gt;
BDD is based on the techniques and principles of TDD, while combining these with ideas from domain-driven design and object-oriented analysis and design. BDD focuses on the behavioral specification of software units.&lt;br /&gt;
&lt;br /&gt;
While TDD is quite non-specific about what should be tested and at what level of detail, BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.&lt;br /&gt;
BDD also specifies how the behavior should be specified. BDD uses a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design.&lt;br /&gt;
&lt;br /&gt;
Generally TDD suggests writing unit tests at the beginning of the application development process to help the developer design the code. This helps the developer design the object and method interfaces through test, and refactor the code and tests as the code matures. These tests are often written as a white box test-inside-out that test the specific implementation of a piece of code.&lt;br /&gt;
BDD also emphasizes writing unit tests, but instead of focusing on the inside-out test approach, it approaches the test from a business value perspective which tests outside-in. &lt;br /&gt;
BDD emphasizes that test authors focus on why a piece of code is necessary, and what its goal is. &amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This approach is adopted in the way all tests are written in Jasmine. In Jasmine each test describes the behavior of the unit under test, through an &amp;quot;it should do the following&amp;quot; kind of clause.&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;/&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
*[http://en.wikipedia.org/wiki/JavaScript Javascript]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)]&lt;br /&gt;
*[http://rspec.info/ RSpec]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/QUnit Qunit]&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89519</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89519"/>
		<updated>2014-10-13T19:20:01Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Jasmine'''&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for [http://en.wikipedia.org/wiki/JavaScript JavaScript]. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the [http://en.wikipedia.org/wiki/MIT_License MIT license]. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
Jasmine is often used in the [http://en.wikipedia.org/wiki/Ruby_on_Rails Rails framework]. Jasmine is available as a [http://en.wikipedia.org/wiki/RubyGems Rubygem] and it automates common workflows by leveraging known rake tasks and generators. Jasmine is highly influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* should not be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* should have idiomatic and unsurprising syntax.&lt;br /&gt;
* should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* shouldn't intrude in an application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If they are named well, specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.The clock needs to be uninstalled after the original functions are restored.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
Functions like setTimeout or setInterval can be made synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If not provided with a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
[http://behaviour-driven.org/ Behavior Driven Development] (abbreviated as BDD) is a software development process that was developed in response to issues encountered with [http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)].&lt;br /&gt;
BDD is based on the techniques and principles of TDD, while combining these with ideas from domain-driven design and object-oriented analysis and design. BDD focuses on the behavioral specification of software units.&lt;br /&gt;
&lt;br /&gt;
While TDD is quite non-specific about what should be tested and at what level of detail, BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.&lt;br /&gt;
BDD also specifies how the behavior should be specified. BDD uses a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design.&lt;br /&gt;
&lt;br /&gt;
Generally TDD suggests writing unit tests at the beginning of the application development process to help the developer design the code. This helps the developer design the object and method interfaces through test, and refactor the code and tests as the code matures. These tests are often written as a white box test-inside-out that test the specific implementation of a piece of code.&lt;br /&gt;
BDD also emphasizes writing unit tests, but instead of focusing on the inside-out test approach, it approaches the test from a business value perspective which tests outside-in. &lt;br /&gt;
BDD emphasizes that test authors focus on why a piece of code is necessary, and what its goal is. &amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This approach is adopted in the way all tests are written in Jasmine. In Jasmine each test describes the behavior of the unit under test, through an &amp;quot;it should do the following&amp;quot; kind of clause.&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;/&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
*[http://en.wikipedia.org/wiki/JavaScript Javascript]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)]&lt;br /&gt;
*[http://rspec.info/ RSpec]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/QUnit Qunit]&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89518</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89518"/>
		<updated>2014-10-13T18:59:49Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Jasmine'''&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for [http://en.wikipedia.org/wiki/JavaScript JavaScript]. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the [http://en.wikipedia.org/wiki/MIT_License MIT license]. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
It can be used in the Rails framework. Jasmine ships as a Rubygem and leverages familiar rake tasks and generators to automate common workflows. Jasmine is heavily influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* should not be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* should have idiomatic and unsurprising syntax.&lt;br /&gt;
* should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* shouldn't intrude in an application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If they are named well, specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.The clock needs to be uninstalled after the original functions are restored.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
Functions like setTimeout or setInterval can be made synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If not provided with a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
[http://behaviour-driven.org/ Behavior Driven Development] (abbreviated as BDD) is a software development process that was developed in response to issues encountered with [http://en.wikipedia.org/wiki/Test-driven_development Test Driven Development (TDD)].&lt;br /&gt;
BDD is based on the techniques and principles of TDD, while combining these with ideas from domain-driven design and object-oriented analysis and design. BDD focuses on the behavioral specification of software units.&lt;br /&gt;
&lt;br /&gt;
While TDD is quite non-specific about what should be tested and at what level of detail, BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.&lt;br /&gt;
BDD also specifies how the behavior should be specified. BDD uses a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design.&lt;br /&gt;
&lt;br /&gt;
Generally TDD suggests writing unit tests at the beginning of the application development process to help the developer design the code. This helps the developer design the object and method interfaces through test, and refactor the code and tests as the code matures. These tests are often written as a white box test-inside-out that test the specific implementation of a piece of code.&lt;br /&gt;
BDD also emphasizes writing unit tests, but instead of focusing on the inside-out test approach, it approaches the test from a business value perspective which tests outside-in. &lt;br /&gt;
BDD emphasizes that test authors focus on why a piece of code is necessary, and what its goal is. &amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This approach is adopted in the way all tests are written in Jasmine. In Jasmine each test describes the behavior of the unit under test, through an &amp;quot;it should do the following&amp;quot; kind of clause.&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;/&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89481</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89481"/>
		<updated>2014-10-07T20:30:16Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Jasmine'''&lt;br /&gt;
&lt;br /&gt;
[http://jasmine.github.io/ Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for [http://en.wikipedia.org/wiki/JavaScript JavaScript]. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the MIT license. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
It can be used in the Rails framework. Jasmine ships as a Rubygem and leverages familiar rake tasks and generators to automate common workflows. Jasmine is heavily influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* should not be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* should have idiomatic and unsurprising syntax.&lt;br /&gt;
* should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* shouldn't intrude in your application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89480</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89480"/>
		<updated>2014-10-07T20:29:01Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Jasmine'''&lt;br /&gt;
&lt;br /&gt;
[http://jasmine.github.io/ Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for [http://en.wikipedia.org/wiki/JavaScript JavaScript]. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the MIT license. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
It can be used in the Rails framework. Jasmine ships as a Rubygem and leverages familiar rake tasks and generators to automate common workflows. Jasmine is heavily influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* should not be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* should have idiomatic and unsurprising syntax.&lt;br /&gt;
* should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* shouldn't intrude in your application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89195</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89195"/>
		<updated>2014-10-06T18:36:40Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for [http://en.wikipedia.org/wiki/JavaScript JavaScript]. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the MIT license. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
It can be used in the Rails framework. Jasmine ships as a Rubygem and leverages familiar rake tasks and generators to automate common workflows. Jasmine is heavily influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* should not be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* should have idiomatic and unsurprising syntax.&lt;br /&gt;
* should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* shouldn't intrude in your application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If you name them well, your specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.Remember to uninstall the clock after you are done to restore the original functions.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
You can make setTimeout or setInterval synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If you do not provide a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
[http://behaviour-driven.org/ Behavior Driven Development] (abbreviated as BDD) is a software development process that was developed in response to issues encountered with Test Driven Development (TDD).&lt;br /&gt;
BDD is based on the techniques and principles of TDD, while combining these with ideas from domain-driven design and object-oriented analysis and design. BDD focuses on the behavioral specification of software units.&lt;br /&gt;
&lt;br /&gt;
While TDD is quite non-specific about what should be tested and at what level of detail, BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.&lt;br /&gt;
BDD also specifies how the behavior should be specified. BDD uses a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design.&lt;br /&gt;
&lt;br /&gt;
In Jasmine each test describes he behavior of the unit under test.&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89194</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89194"/>
		<updated>2014-10-06T18:35:53Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] is an open source [http://en.wikipedia.org/wiki/Behavior-driven_development Behavior Driven Development (BDD)] based  testing framework for JavaScript. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the MIT license. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
It can be used in the Rails framework. Jasmine ships as a Rubygem and leverages familiar rake tasks and generators to automate common workflows. Jasmine is heavily influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* should not be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* should have idiomatic and unsurprising syntax.&lt;br /&gt;
* should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* shouldn't intrude in your application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If you name them well, your specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.Remember to uninstall the clock after you are done to restore the original functions.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
You can make setTimeout or setInterval synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If you do not provide a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
[http://behaviour-driven.org/ Behavior Driven Development] (abbreviated as BDD) is a software development process that was developed in response to issues encountered with Test Driven Development (TDD).&lt;br /&gt;
BDD is based on the techniques and principles of TDD, while combining these with ideas from domain-driven design and object-oriented analysis and design. BDD focuses on the behavioral specification of software units.&lt;br /&gt;
&lt;br /&gt;
While TDD is quite non-specific about what should be tested and at what level of detail, BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.&lt;br /&gt;
BDD also specifies how the behavior should be specified. BDD uses a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design.&lt;br /&gt;
&lt;br /&gt;
In Jasmine each test describes he behavior of the unit under test.&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89193</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=89193"/>
		<updated>2014-10-06T18:34:37Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework) Jasmine] is an open source Behavior Driven Development (BDD) based  testing framework for JavaScript. It is maintained by [http://pivotallabs.com/ Pivotal Labs] and is available on [http://en.wikipedia.org/wiki/GitHub GitHub] under the MIT license. Jasmine allows tests to be written independent of the DOM or other JavaScript frameworks. Jasmine can be run in a browser, or headless without a browser by integrating with other frameworks such as [http://en.wikipedia.org/wiki/Rhino_(JavaScript_engine) Rhino], Envy, or the Jasmine-headless-webkit library. &lt;br /&gt;
&lt;br /&gt;
It can be used in the Rails framework. Jasmine ships as a Rubygem and leverages familiar rake tasks and generators to automate common workflows. Jasmine is heavily influenced by other unit testing frameworks, such as [https://github.com/nkallen/screw-unit ScrewUnit], [https://code.google.com/p/jsspec/ JSSpec], [https://github.com/liblime/jspec JSpec], and [http://rspec.info/ RSpec]; and has syntax very similar to [http://rspec.info/ RSpec].&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* should not be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* should have idiomatic and unsurprising syntax.&lt;br /&gt;
* should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* shouldn't intrude in your application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If you name them well, your specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.Remember to uninstall the clock after you are done to restore the original functions.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
You can make setTimeout or setInterval synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If you do not provide a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
[http://behaviour-driven.org/ Behavior Driven Development] (abbreviated as BDD) is a software development process that was developed in response to issues encountered with Test Driven Development (TDD).&lt;br /&gt;
BDD is based on the techniques and principles of TDD, while combining these with ideas from domain-driven design and object-oriented analysis and design. BDD focuses on the behavioral specification of software units.&lt;br /&gt;
&lt;br /&gt;
While TDD is quite non-specific about what should be tested and at what level of detail, BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.&lt;br /&gt;
BDD also specifies how the behavior should be specified. BDD uses a semi-formal format for behavioral specification which is borrowed from user story specifications from the field of object-oriented analysis and design.&lt;br /&gt;
&lt;br /&gt;
In Jasmine each test describes he behavior of the unit under test.&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88924</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88924"/>
		<updated>2014-10-04T23:30:17Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Drawbacks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Jasmine is an open source Behavior Driven Development (BDD) based  testing framework for JavaScript. Jasmine aims to run on any Javascript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. &lt;br /&gt;
&lt;br /&gt;
It can be used in the Rails framework. Jasmine ships as a Rubygem and leverages familiar rake tasks and generators to automate common workflows. Jasmine is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec; and has syntax very similar to RSpec.&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* should not be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* should have idiomatic and unsurprising syntax.&lt;br /&gt;
* should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* shouldn't intrude in your application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If you name them well, your specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.Remember to uninstall the clock after you are done to restore the original functions.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
You can make setTimeout or setInterval synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If you do not provide a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the [http://en.wikipedia.org/wiki/JavaScript Javascript] code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like [http://en.wikipedia.org/wiki/Java_(programming_language) Java] and [http://en.wikipedia.org/wiki/PHP PHP].&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* [http://en.wikipedia.org/wiki/QUnit Qunit] is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88923</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88923"/>
		<updated>2014-10-04T23:25:55Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Grouping Related Specs with describe */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Jasmine is an open source Behavior Driven Development (BDD) based  testing framework for JavaScript. Jasmine aims to run on any Javascript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. &lt;br /&gt;
&lt;br /&gt;
It can be used in the Rails framework. Jasmine ships as a Rubygem and leverages familiar rake tasks and generators to automate common workflows. Jasmine is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec; and has syntax very similar to RSpec.&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* should not be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* should have idiomatic and unsurprising syntax.&lt;br /&gt;
* should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* shouldn't intrude in your application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If you name them well, your specs read as full sentences in traditional [http://en.wikipedia.org/wiki/Behavior-driven_development BDD] style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.Remember to uninstall the clock after you are done to restore the original functions.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
You can make setTimeout or setInterval synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If you do not provide a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the Javascript code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Qunit is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like Java and PHP.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* Qunit is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88922</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88922"/>
		<updated>2014-10-04T23:24:38Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Usage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Jasmine is an open source Behavior Driven Development (BDD) based  testing framework for JavaScript. Jasmine aims to run on any Javascript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. &lt;br /&gt;
&lt;br /&gt;
It can be used in the Rails framework. Jasmine ships as a Rubygem and leverages familiar rake tasks and generators to automate common workflows. Jasmine is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec; and has syntax very similar to RSpec.&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* should not be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* should have idiomatic and unsurprising syntax.&lt;br /&gt;
* should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* shouldn't intrude in your application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of [http://en.wikipedia.org/wiki/Behavior-driven_development behavior-driven development] and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If you name them well, your specs read as full sentences in traditional BDD style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.Remember to uninstall the clock after you are done to restore the original functions.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
You can make setTimeout or setInterval synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If you do not provide a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the Javascript code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Qunit is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like Java and PHP.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* Qunit is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88921</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88921"/>
		<updated>2014-10-04T23:23:01Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Usage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Jasmine is an open source Behavior Driven Development (BDD) based  testing framework for JavaScript. Jasmine aims to run on any Javascript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. &lt;br /&gt;
&lt;br /&gt;
It can be used in the Rails framework. Jasmine ships as a Rubygem and leverages familiar rake tasks and generators to automate common workflows. Jasmine is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec; and has syntax very similar to RSpec.&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* should not be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* should have idiomatic and unsurprising syntax.&lt;br /&gt;
* should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* shouldn't intrude in your application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of behavior-driven development and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of [http://en.wikipedia.org/wiki/RSpec RSpec].&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If you name them well, your specs read as full sentences in traditional BDD style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.Remember to uninstall the clock after you are done to restore the original functions.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
You can make setTimeout or setInterval synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If you do not provide a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the Javascript code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Qunit is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like Java and PHP.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* Qunit is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88920</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88920"/>
		<updated>2014-10-04T23:21:15Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Background */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Jasmine is an open source Behavior Driven Development (BDD) based  testing framework for JavaScript. Jasmine aims to run on any Javascript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. &lt;br /&gt;
&lt;br /&gt;
It can be used in the Rails framework. Jasmine ships as a Rubygem and leverages familiar rake tasks and generators to automate common workflows. Jasmine is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec; and has syntax very similar to RSpec.&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for [http://en.wikipedia.org/wiki/JavaScript JS] developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good [http://en.wikipedia.org/wiki/JavaScript JavaScript]testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* should not be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* should have idiomatic and unsurprising syntax.&lt;br /&gt;
* should work anywhere [http://en.wikipedia.org/wiki/JavaScript JavaScript]can run, including browsers, servers, phones, etc.&lt;br /&gt;
* shouldn't intrude in your application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of behavior-driven development and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of RSpec.&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If you name them well, your specs read as full sentences in traditional BDD style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.Remember to uninstall the clock after you are done to restore the original functions.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
You can make setTimeout or setInterval synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If you do not provide a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the Javascript code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Qunit is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like Java and PHP.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* Qunit is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88919</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88919"/>
		<updated>2014-10-04T23:10:21Z</updated>

		<summary type="html">&lt;p&gt;Sngala: /* Drawbacks */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Jasmine is an open source Behavior Driven Development (BDD) based  testing framework for JavaScript. Jasmine aims to run on any Javascript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. &lt;br /&gt;
&lt;br /&gt;
It can be used in the Rails framework. Jasmine ships as a Rubygem and leverages familiar rake tasks and generators to automate common workflows. Jasmine is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec; and has syntax very similar to RSpec.&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for JS developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good JavaScript testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* should not be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* should have idiomatic and unsurprising syntax.&lt;br /&gt;
* should work anywhere JavaScript can run, including browsers, servers, phones, etc.&lt;br /&gt;
* shouldn't intrude in your application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of behavior-driven development and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of RSpec.&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If you name them well, your specs read as full sentences in traditional BDD style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.Remember to uninstall the clock after you are done to restore the original functions.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
You can make setTimeout or setInterval synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If you do not provide a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for integration testing, because Jasmine only tests the Javascript code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Qunit is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like Java and PHP.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* Qunit is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88918</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88918"/>
		<updated>2014-10-04T23:09:32Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Jasmine is an open source Behavior Driven Development (BDD) based  testing framework for JavaScript. Jasmine aims to run on any Javascript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. &lt;br /&gt;
&lt;br /&gt;
It can be used in the Rails framework. Jasmine ships as a Rubygem and leverages familiar rake tasks and generators to automate common workflows. Jasmine is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec; and has syntax very similar to RSpec.&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for JS developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good JavaScript testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* should not be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* should have idiomatic and unsurprising syntax.&lt;br /&gt;
* should work anywhere JavaScript can run, including browsers, servers, phones, etc.&lt;br /&gt;
* shouldn't intrude in your application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of behavior-driven development and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of RSpec.&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If you name them well, your specs read as full sentences in traditional BDD style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.Remember to uninstall the clock after you are done to restore the original functions.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
You can make setTimeout or setInterval synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If you do not provide a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
* Jasmine is not recommended for your integration tests, because Jasmine only tests the Javascript code on one system at a time.&amp;lt;ref name=&amp;quot;Adobe&amp;quot;&amp;gt;http://www.adobe.com/devnet/html5/articles/unit-test-javascript-applications-with-jasmine.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Qunit is preferred more over Jasmine since it follow more similar conventions to other unit testing frameworks like Java and PHP.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;&amp;gt;http://tech.pro/q/39/what-javascript-testing-framework-do-you-prefer-and-why&amp;lt;/ref&amp;gt; &lt;br /&gt;
* Qunit is simpler, easy for beginners and has a straight forward syntax hence its preferred over Jasmine.&amp;lt;ref name=&amp;quot;Alternatives&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88917</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88917"/>
		<updated>2014-10-04T22:55:18Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Jasmine is an open source Behavior Driven Development (BDD) based  testing framework for JavaScript. Jasmine aims to run on any Javascript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. &lt;br /&gt;
&lt;br /&gt;
It can be used in the Rails framework. Jasmine ships as a Rubygem and leverages familiar rake tasks and generators to automate common workflows. Jasmine is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec; and has syntax very similar to RSpec.&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for JS developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good JavaScript testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* should not be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* should have idiomatic and unsurprising syntax.&lt;br /&gt;
* should work anywhere JavaScript can run, including browsers, servers, phones, etc.&lt;br /&gt;
* shouldn't intrude in your application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of behavior-driven development and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of RSpec.&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If you name them well, your specs read as full sentences in traditional BDD style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.Remember to uninstall the clock after you are done to restore the original functions.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
You can make setTimeout or setInterval synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If you do not provide a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
     expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88916</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88916"/>
		<updated>2014-10-04T22:53:59Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Jasmine is an open source Behavior Driven Development (BDD) based  testing framework for JavaScript. Jasmine aims to run on any Javascript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. &lt;br /&gt;
&lt;br /&gt;
It can be used in the Rails framework. Jasmine ships as a Rubygem and leverages familiar rake tasks and generators to automate common workflows. Jasmine is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec; and has syntax very similar to RSpec.&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for JS developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good JavaScript testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* should not be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* should have idiomatic and unsurprising syntax.&lt;br /&gt;
* should work anywhere JavaScript can run, including browsers, servers, phones, etc.&lt;br /&gt;
* shouldn't intrude in your application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of behavior-driven development and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of RSpec.&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If you name them well, your specs read as full sentences in traditional BDD style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.Remember to uninstall the clock after you are done to restore the original functions.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
You can make setTimeout or setInterval synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If you do not provide a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Matching Anything with jasmine.any ===&lt;br /&gt;
jasmine.any takes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;jasmine.any&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;matches any value&amp;quot;, function() {&lt;br /&gt;
    expect({}).toEqual(jasmine.any(Object));&lt;br /&gt;
    expect(12).toEqual(jasmine.any(Number));&lt;br /&gt;
  });&lt;br /&gt;
  describe(&amp;quot;when used with a spy&amp;quot;, function() {&lt;br /&gt;
    it(&amp;quot;is useful for comparing arguments&amp;quot;, function() {&lt;br /&gt;
      var foo = jasmine.createSpy('foo');&lt;br /&gt;
      foo(12, function() {&lt;br /&gt;
        return true;&lt;br /&gt;
      });&lt;br /&gt;
&lt;br /&gt;
      expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function));&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88915</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88915"/>
		<updated>2014-10-04T22:50:31Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Jasmine is an open source Behavior Driven Development (BDD) based  testing framework for JavaScript. Jasmine aims to run on any Javascript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. &lt;br /&gt;
&lt;br /&gt;
It can be used in the Rails framework. Jasmine ships as a Rubygem and leverages familiar rake tasks and generators to automate common workflows. Jasmine is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec; and has syntax very similar to RSpec.&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for JS developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good JavaScript testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* should not be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* should have idiomatic and unsurprising syntax.&lt;br /&gt;
* should work anywhere JavaScript can run, including browsers, servers, phones, etc.&lt;br /&gt;
* shouldn't intrude in your application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of behavior-driven development and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of RSpec.&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If you name them well, your specs read as full sentences in traditional BDD style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Spies ===&lt;br /&gt;
Jasmine’s has test double functions called spies. A spy can stub any function and tracks calls to it and all arguments. A spy only exists in the describe or it block it is defined, and will be removed after each spec. There are special matchers for interacting with spies. The toHaveBeenCalled matcher will return true if the spy was called. The toHaveBeenCalledWith matcher will return true if the argument list matches any of the recorded calls to the spy.&amp;lt;ref name=&amp;quot;New Features&amp;quot;&amp;gt;http://jasmine.github.io/edge/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spy&amp;quot;, function() {&lt;br /&gt;
  var foo, bar = null;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
     foo = {&lt;br /&gt;
      setBar: function(value) {&lt;br /&gt;
        bar = value;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    spyOn(foo, 'setBar');&lt;br /&gt;
    foo.setBar(123);&lt;br /&gt;
    foo.setBar(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks that the spy was called&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;tracks all the arguments of its calls&amp;quot;, function() {&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(123);&lt;br /&gt;
    expect(foo.setBar).toHaveBeenCalledWith(456, 'another param');&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;stops all execution on a function&amp;quot;, function() {&lt;br /&gt;
    expect(bar).toBeNull();&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
=== Jasmine Clock ===&lt;br /&gt;
The Jasmine Clock is available for testing time dependent code.It is installed with a call to jasmine.clock().install in a spec or suite that needs to manipulate time.Remember to uninstall the clock after you are done to restore the original functions.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the JavaScript Timeout Functions ====&lt;br /&gt;
You can make setTimeout or setInterval synchronous executing the registered functions only once the clock is ticked forward in time.To execute registered functions, move time forward via the jasmine.clock().tick function, which takes a number of milliseconds.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Mocking the Date ====&lt;br /&gt;
The Jasmine Clock can also be used to mock the current date.If you do not provide a base time to mockDate it will use the current date.&amp;lt;ref name=&amp;quot;New Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example showing the uses of jasmine Clock &lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;Manually ticking the Jasmine Clock&amp;quot;, function() {&lt;br /&gt;
  var timerCallback;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    timerCallback = jasmine.createSpy(&amp;quot;timerCallback&amp;quot;);&lt;br /&gt;
    jasmine.clock().install();&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    jasmine.clock().uninstall();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes a timeout to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setTimeout(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback).toHaveBeenCalled();&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;causes an interval to be called synchronously&amp;quot;, function() {&lt;br /&gt;
    setInterval(function() {&lt;br /&gt;
      timerCallback();&lt;br /&gt;
    }, 100);&lt;br /&gt;
    expect(timerCallback).not.toHaveBeenCalled();&lt;br /&gt;
    jasmine.clock().tick(101);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(1);&lt;br /&gt;
    jasmine.clock().tick(50);&lt;br /&gt;
    expect(timerCallback.calls.count()).toEqual(2);&lt;br /&gt;
  });&lt;br /&gt;
 describe(&amp;quot;Mocking the Date object&amp;quot;, function(){&lt;br /&gt;
    it(&amp;quot;mocks the Date object and sets it to a given time&amp;quot;, function() {&lt;br /&gt;
      var baseTime = new Date(2013, 9, 23);&lt;br /&gt;
 jasmine.clock().mockDate(baseTime);&lt;br /&gt;
 jasmine.clock().tick(50);&lt;br /&gt;
      expect(new Date().getTime()).toEqual(baseTime.getTime() + 50);&lt;br /&gt;
    });&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88914</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88914"/>
		<updated>2014-10-04T22:16:26Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Jasmine is an open source Behavior Driven Development (BDD) based  testing framework for JavaScript. Jasmine aims to run on any Javascript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. &lt;br /&gt;
&lt;br /&gt;
It can be used in the Rails framework. Jasmine ships as a Rubygem and leverages familiar rake tasks and generators to automate common workflows. Jasmine is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec; and has syntax very similar to RSpec.&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for JS developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good JavaScript testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* should not be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* should have idiomatic and unsurprising syntax.&lt;br /&gt;
* should work anywhere JavaScript can run, including browsers, servers, phones, etc.&lt;br /&gt;
* shouldn't intrude in your application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of behavior-driven development and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of RSpec.&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
=== Suites ===&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Specs ===&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Disabling Specs and Suits ===&lt;br /&gt;
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and specs are skipped when run and thus their results will not appear in the results.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 xdescribe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  xit(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Expectations ===&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Matchers ====&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Included Matchers ====&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&amp;lt;ref name=&amp;quot;Included Matchers&amp;quot;&amp;gt;http://www.htmlgoodies.com/beyond/javascript/testing-javascript-using-the-jasmine-framework.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
There is also the ability to write [https://github.com/pivotal/jasmine/wiki/Matchers custom matchers]when a project’s domain calls for specific assertions that are not included.&lt;br /&gt;
&lt;br /&gt;
=== Grouping Related Specs with describe ===&lt;br /&gt;
The describe function is for grouping related specs. The string parameter is for naming the collection of specs, and will be concatenated with specs to make a spec’s full name. This aids in finding specs in a large suite. If you name them well, your specs read as full sentences in traditional BDD style.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    var foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
==== Setup and Teardown ====&lt;br /&gt;
To help a test suite DRY up any duplicated setup and teardown code, Jasmine provides the global beforeEach and afterEach functions. As the name implies the beforeEach function is called once before each spec in the describe is run and the afterEach function is called once after each spec.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A spec (with setup and tear-down)&amp;quot;, function() {&lt;br /&gt;
  var foo;&lt;br /&gt;
  beforeEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
    foo += 1;&lt;br /&gt;
  });&lt;br /&gt;
  afterEach(function() {&lt;br /&gt;
    foo = 0;&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;is just a function, so it can contain any code&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
  });&lt;br /&gt;
  it(&amp;quot;can have more than one expectation&amp;quot;, function() {&lt;br /&gt;
    expect(foo).toEqual(1);&lt;br /&gt;
    expect(true).toEqual(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Asynchronous Calls ===&lt;br /&gt;
Jasmine also supports testing of asynchronous calls using the functions runs and waitsFor:&amp;lt;ref name=&amp;quot;Asynchronous Calls&amp;quot;&amp;gt;https://www.inexfinance.com/en/blog/2013/1/25/jasmine_for_clientside_testing&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*runs – takes the asynchronous function for execution;&lt;br /&gt;
*waitsFor – takes three parameters: the first one – is a latch function that should return true if the asynch call made in runs was executed, the second one – is a failure message, and the last one - is the waiting time in milliseconds.&lt;br /&gt;
&lt;br /&gt;
 describe &amp;quot;Asynchronous&amp;quot;, -&amp;gt;&lt;br /&gt;
  a = 0&lt;br /&gt;
  async = -&amp;gt;&lt;br /&gt;
    setTimeout((-&amp;gt; a = 5), 1000)&lt;br /&gt;
  it &amp;quot;asynch executes code&amp;quot;, -&amp;gt;&lt;br /&gt;
    runs(-&amp;gt; async())&lt;br /&gt;
    waitsFor((-&amp;gt; a == 5), &amp;quot;the value should be changed&amp;quot;, 3000)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88911</id>
		<title>CSC/ECE 517 Fall 2014/ch1b 26 sa</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2014/ch1b_26_sa&amp;diff=88911"/>
		<updated>2014-10-04T21:49:21Z</updated>

		<summary type="html">&lt;p&gt;Sngala: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Jasmine is an open source Behavior Driven Development (BDD) based  testing framework for JavaScript. Jasmine aims to run on any Javascript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. &lt;br /&gt;
&lt;br /&gt;
It can be used in the Rails framework. Jasmine ships as a Rubygem and leverages familiar rake tasks and generators to automate common workflows. Jasmine is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec; and has syntax very similar to RSpec.&lt;br /&gt;
&lt;br /&gt;
= Background =&lt;br /&gt;
&lt;br /&gt;
The Jasmine framework was developed since developers to address certain specific concerns in existing testing frameworks &amp;lt;ref name=&amp;quot;Background&amp;quot;&amp;gt;https://github.com/pivotal/jasmine/wiki/Background&amp;lt;/ref&amp;gt;&lt;br /&gt;
* Many frameworks only work from within a browser. &lt;br /&gt;
* Many don't support testing asynchronous code like event callbacks. &lt;br /&gt;
* Some have syntax that's hard for JS developers or IDEs to understand.&lt;br /&gt;
&lt;br /&gt;
== Design Principles ==&lt;br /&gt;
The Jasmine developer community believes that a good JavaScript testing framework must follow these principles. &amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* should not be tied to any browser, framework, platform, or host language.&lt;br /&gt;
* should have idiomatic and unsurprising syntax.&lt;br /&gt;
* should work anywhere JavaScript can run, including browsers, servers, phones, etc.&lt;br /&gt;
* shouldn't intrude in your application's territory (e.g. by cluttering the global namespace).&lt;br /&gt;
* should play well with IDEs (e.g. test code should pass static analysis).&lt;br /&gt;
&lt;br /&gt;
== Goals ==&lt;br /&gt;
The Jasmine framework is written with the objective of meeting these goals.&amp;lt;ref name=&amp;quot;Background&amp;quot;/&amp;gt;&lt;br /&gt;
* it should encourage good testing practices.&lt;br /&gt;
* it should integrate easily with continuous build systems.&lt;br /&gt;
* it should be simple to get started with.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Jasmine aims to be easy to read. A simple hello world test looks like the code below, where describe() describes a suite of tests and it() is an individual test specification. The name &amp;quot;it()&amp;quot; follows the idea of behavior-driven development and serves as the first word in the test name, which should be a complete sentence. Usage follows syntax similar to that of RSpec.&amp;lt;ref name=&amp;quot;Usage&amp;quot;&amp;gt;http://en.wikipedia.org/wiki/Jasmine_(JavaScript_framework)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe('Hello world', function() { &lt;br /&gt;
    it('says hello', function() {&lt;br /&gt;
    expect(helloWorld()).toEqual(&amp;quot;Hello world!&amp;quot;);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Suites ==&lt;br /&gt;
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. The function is a block of code that implements the suite.&amp;lt;ref name=&amp;quot;Features&amp;quot;&amp;gt;http://jasmine.github.io/1.3/introduction.html&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;contains spec with an expectation&amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Specs ==&lt;br /&gt;
Specs are defined by calling the global Jasmine function it, which, like describe takes a string and a function. The string is a title for this spec and the function is the spec, or test. A spec contains one or more expectations that test the state of the code under test.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An expectation in Jasmine is an assertion that can be either true or false. A spec with all true expectations is a passing spec. A spec with one or more expectations that evaluate to false is a failing spec.&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;A suite is just a function&amp;quot;, function() {&lt;br /&gt;
  var a;&lt;br /&gt;
  it(&amp;quot;and so is a spec&amp;quot;, function() {&lt;br /&gt;
    a = true;&lt;br /&gt;
   expect(a).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Expectations ==&lt;br /&gt;
Expectations are built with the function expect which takes a value, called the actual. It is chained with a Matcher function, which takes the expected value.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Matchers ===&lt;br /&gt;
Each matcher implements a boolean comparison between the actual value and the expected value. It is responsible for reporting to Jasmine if the expectation is true or false. Jasmine will then pass or fail the spec.Any matcher can evaluate to a negative assertion by chaining the call to expect with a not before calling the matcher.&amp;lt;ref name=&amp;quot;Features&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 describe(&amp;quot;The 'toBe' matcher compares with ===&amp;quot;, function() {&lt;br /&gt;
  it(&amp;quot;and has a positive case &amp;quot;, function() {&lt;br /&gt;
    expect(true).toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 it(&amp;quot;and can have a negative case&amp;quot;, function() {&lt;br /&gt;
    expect(false).not.toBe(true);&lt;br /&gt;
  });&lt;br /&gt;
 });&lt;br /&gt;
&lt;br /&gt;
=== Included Matchers ===&lt;br /&gt;
Jasmine has a rich set of matchers included. Some of them are listed below.&lt;br /&gt;
*toBe: represents the exact equality (===) operator.&lt;br /&gt;
*toEqual: represents the regular equality (==) operator.&lt;br /&gt;
*toMatch: calls the RegExp match() method behind the scenes to compare string data.&lt;br /&gt;
*toBeDefined: opposite of the JS &amp;quot;undefined&amp;quot; constant.&lt;br /&gt;
*toBeUndefined: tests the actual against &amp;quot;undefined&amp;quot;.&lt;br /&gt;
*toBeNull: tests the actual against a null value - useful for certain functions that may return null, like those of regular expressions (same as toBe(null))&lt;br /&gt;
*toBeTruthy: simulates JavaScript boolean casting.&lt;br /&gt;
*toBeFalsy: like toBeTruthy, but tests against anything that evaluates to false, such as empty strings, zero, undefined, etc…&lt;br /&gt;
*toContain: performs a search on an array for the actual value.&lt;br /&gt;
*toBeLessThan/toBeGreaterThan: for numerical comparisons.&lt;br /&gt;
*toBeCloseTo: for floating point comparisons.&lt;br /&gt;
*toThrow: for catching expected exceptions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Behavior Driven Design =&lt;br /&gt;
&lt;br /&gt;
= Drawbacks =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= References = &lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sngala</name></author>
	</entry>
</feed>