\documentclass[11pt,twoside]{article}\makeatletter

\IfFileExists{xcolor.sty}%
  {\RequirePackage{xcolor}}%
  {\RequirePackage{color}}
\usepackage{colortbl}
\usepackage{wrapfig}
\usepackage{ifxetex}
\ifxetex
  \usepackage{fontspec}
  \usepackage{xunicode}
  \catcode`⃥=\active \def⃥{\textbackslash}
  \catcode`❴=\active \def❴{\{}
  \catcode`❵=\active \def❵{\}}
  \def\textJapanese{\fontspec{Noto Sans CJK JP}}
  \def\textChinese{\fontspec{Noto Sans CJK SC}}
  \def\textKorean{\fontspec{Noto Sans CJK KR}}
  \setmonofont{DejaVu Sans Mono}
  
\else
  \IfFileExists{utf8x.def}%
   {\usepackage[utf8x]{inputenc}
      \PrerenderUnicode{–}
    }%
   {\usepackage[utf8]{inputenc}}
  \usepackage[english]{babel}
  \usepackage[T1]{fontenc}
  \usepackage{float}
  \usepackage[]{ucs}
  \uc@dclc{8421}{default}{\textbackslash }
  \uc@dclc{10100}{default}{\{}
  \uc@dclc{10101}{default}{\}}
  \uc@dclc{8491}{default}{\AA{}}
  \uc@dclc{8239}{default}{\,}
  \uc@dclc{20154}{default}{ }
  \uc@dclc{10148}{default}{>}
  \def\textschwa{\rotatebox{-90}{e}}
  \def\textJapanese{}
  \def\textChinese{}
  \IfFileExists{tipa.sty}{\usepackage{tipa}}{}
\fi
\def\exampleFont{\ttfamily\small}
\DeclareTextSymbol{\textpi}{OML}{25}
\usepackage{relsize}
\RequirePackage{array}
\def\@testpach{\@chclass
 \ifnum \@lastchclass=6 \@ne \@chnum \@ne \else
  \ifnum \@lastchclass=7 5 \else
   \ifnum \@lastchclass=8 \tw@ \else
    \ifnum \@lastchclass=9 \thr@@
   \else \z@
   \ifnum \@lastchclass = 10 \else
   \edef\@nextchar{\expandafter\string\@nextchar}%
   \@chnum
   \if \@nextchar c\z@ \else
    \if \@nextchar l\@ne \else
     \if \@nextchar r\tw@ \else
   \z@ \@chclass
   \if\@nextchar |\@ne \else
    \if \@nextchar !6 \else
     \if \@nextchar @7 \else
      \if \@nextchar (8 \else
       \if \@nextchar )9 \else
  10
  \@chnum
  \if \@nextchar m\thr@@\else
   \if \@nextchar p4 \else
    \if \@nextchar b5 \else
   \z@ \@chclass \z@ \@preamerr \z@ \fi \fi \fi \fi
   \fi \fi  \fi  \fi  \fi  \fi  \fi \fi \fi \fi \fi \fi}
\gdef\arraybackslash{\let\\=\@arraycr}
\def\@textsubscript#1{{\m@th\ensuremath{_{\mbox{\fontsize\sf@size\z@#1}}}}}
\def\Panel#1#2#3#4{\multicolumn{#3}{){\columncolor{#2}}#4}{#1}}
\def\abbr{}
\def\corr{}
\def\expan{}
\def\gap{}
\def\orig{}
\def\reg{}
\def\ref{}
\def\sic{}
\def\persName{}\def\name{}
\def\placeName{}
\def\orgName{}
\def\textcal#1{{\fontspec{Lucida Calligraphy}#1}}
\def\textgothic#1{{\fontspec{Lucida Blackletter}#1}}
\def\textlarge#1{{\large #1}}
\def\textoverbar#1{\ensuremath{\overline{#1}}}
\def\textquoted#1{‘#1’}
\def\textsmall#1{{\small #1}}
\def\textsubscript#1{\@textsubscript{\selectfont#1}}
\def\textxi{\ensuremath{\xi}}
\def\titlem{\itshape}
\newenvironment{biblfree}{}{\ifvmode\par\fi }
\newenvironment{bibl}{}{}
\newenvironment{byline}{\vskip6pt\itshape\fontsize{16pt}{18pt}\selectfont}{\par }
\newenvironment{citbibl}{}{\ifvmode\par\fi }
\newenvironment{docAuthor}{\ifvmode\vskip4pt\fontsize{16pt}{18pt}\selectfont\fi\itshape}{\ifvmode\par\fi }
\newenvironment{docDate}{}{\ifvmode\par\fi }
\newenvironment{docImprint}{\vskip 6pt}{\ifvmode\par\fi }
\newenvironment{docTitle}{\vskip6pt\bfseries\fontsize{22pt}{25pt}\selectfont}{\par }
\newenvironment{msHead}{\vskip 6pt}{\par}
\newenvironment{msItem}{\vskip 6pt}{\par}
\newenvironment{rubric}{}{}
\newenvironment{titlePart}{}{\par }

\newcolumntype{L}[1]{){\raggedright\arraybackslash}p{#1}}
\newcolumntype{C}[1]{){\centering\arraybackslash}p{#1}}
\newcolumntype{R}[1]{){\raggedleft\arraybackslash}p{#1}}
\newcolumntype{P}[1]{){\arraybackslash}p{#1}}
\newcolumntype{B}[1]{){\arraybackslash}b{#1}}
\newcolumntype{M}[1]{){\arraybackslash}m{#1}}
\definecolor{label}{gray}{0.75}
\def\unusedattribute#1{\sout{\textcolor{label}{#1}}}
\DeclareRobustCommand*{\xref}{\hyper@normalise\xref@}
\def\xref@#1#2{\hyper@linkurl{#2}{#1}}
\begingroup
\catcode`\_=\active
\gdef_#1{\ensuremath{\sb{\mathrm{#1}}}}
\endgroup
\mathcode`\_=\string"8000
\catcode`\_=12\relax

\usepackage[a4paper,twoside,lmargin=1in,rmargin=1in,tmargin=1in,bmargin=1in,marginparwidth=0.75in]{geometry}
\usepackage{framed}

\definecolor{shadecolor}{gray}{0.95}
\usepackage{longtable}
\usepackage[normalem]{ulem}
\usepackage{fancyvrb}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{marginnote}

\renewcommand{\@cite}[1]{#1}


\renewcommand*{\marginfont}{\itshape\footnotesize}

\def\Gin@extensions{.pdf,.png,.jpg,.mps,.tif}

  \pagestyle{fancy}

\usepackage[pdftitle={Automock: Automated Mock Backend Generation for Javascript based Applications},
 pdfauthor={}]{hyperref}
\hyperbaseurl{}

	 \paperwidth210mm
	 \paperheight297mm
              
\def\@pnumwidth{1.55em}
\def\@tocrmarg {2.55em}
\def\@dotsep{4.5}
\setcounter{tocdepth}{3}
\clubpenalty=8000
\emergencystretch 3em
\hbadness=4000
\hyphenpenalty=400
\pretolerance=750
\tolerance=2000
\vbadness=4000
\widowpenalty=10000

\renewcommand\section{\@startsection {section}{1}{\z@}%
     {-1.75ex \@plus -0.5ex \@minus -.2ex}%
     {0.5ex \@plus .2ex}%
     {\reset@font\Large\bfseries}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
     {-1.75ex\@plus -0.5ex \@minus- .2ex}%
     {0.5ex \@plus .2ex}%
     {\reset@font\Large}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
     {-1.5ex\@plus -0.35ex \@minus -.2ex}%
     {0.5ex \@plus .2ex}%
     {\reset@font\large}}
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
     {-1ex \@plus-0.35ex \@minus -0.2ex}%
     {0.5ex \@plus .2ex}%
     {\reset@font\normalsize}}
\renewcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
     {1.5ex \@plus1ex \@minus .2ex}%
     {-1em}%
     {\reset@font\normalsize\bfseries}}


\def\l@section#1#2{\addpenalty{\@secpenalty} \addvspace{1.0em plus 1pt}
 \@tempdima 1.5em \begingroup
 \parindent \z@ \rightskip \@pnumwidth 
 \parfillskip -\@pnumwidth 
 \bfseries \leavevmode #1\hfil \hbox to\@pnumwidth{\hss #2}\par
 \endgroup}
\def\l@subsection{\@dottedtocline{2}{1.5em}{2.3em}}
\def\l@subsubsection{\@dottedtocline{3}{3.8em}{3.2em}}
\def\l@paragraph{\@dottedtocline{4}{7.0em}{4.1em}}
\def\l@subparagraph{\@dottedtocline{5}{10em}{5em}}
\@ifundefined{c@section}{\newcounter{section}}{}
\@ifundefined{c@chapter}{\newcounter{chapter}}{}
\newif\if@mainmatter 
\@mainmattertrue
\def\chaptername{Chapter}
\def\frontmatter{%
  \pagenumbering{roman}
  \def\thechapter{\@roman\c@chapter}
  \def\theHchapter{\roman{chapter}}
  \def\thesection{\@roman\c@section}
  \def\theHsection{\roman{section}}
  \def\@chapapp{}%
}
\def\mainmatter{%
  \cleardoublepage
  \def\thechapter{\@arabic\c@chapter}
  \setcounter{chapter}{0}
  \setcounter{section}{0}
  \pagenumbering{arabic}
  \setcounter{secnumdepth}{6}
  \def\@chapapp{\chaptername}%
  \def\theHchapter{\arabic{chapter}}
  \def\thesection{\@arabic\c@section}
  \def\theHsection{\arabic{section}}
}
\def\backmatter{%
  \cleardoublepage
  \setcounter{chapter}{0}
  \setcounter{section}{0}
  \setcounter{secnumdepth}{2}
  \def\@chapapp{\appendixname}%
  \def\thechapter{\@Alph\c@chapter}
  \def\theHchapter{\Alph{chapter}}
  \appendix
}
\newenvironment{bibitemlist}[1]{%
   \list{\@biblabel{\@arabic\c@enumiv}}%
       {\settowidth\labelwidth{\@biblabel{#1}}%
        \leftmargin\labelwidth
        \advance\leftmargin\labelsep
        \@openbib@code
        \usecounter{enumiv}%
        \let\p@enumiv\@empty
        \renewcommand\theenumiv{\@arabic\c@enumiv}%
	}%
  \sloppy
  \clubpenalty4000
  \@clubpenalty \clubpenalty
  \widowpenalty4000%
  \sfcode`\.\@m}%
  {\def\@noitemerr
    {\@latex@warning{Empty `bibitemlist' environment}}%
    \endlist}

\def\tableofcontents{\section*{\contentsname}\@starttoc{toc}}
\parskip0pt
\parindent1em
\def\Panel#1#2#3#4{\multicolumn{#3}{){\columncolor{#2}}#4}{#1}}
\newenvironment{reflist}{%
  \begin{raggedright}\begin{list}{}
  {%
   \setlength{\topsep}{0pt}%
   \setlength{\rightmargin}{0.25in}%
   \setlength{\itemsep}{0pt}%
   \setlength{\itemindent}{0pt}%
   \setlength{\parskip}{0pt}%
   \setlength{\parsep}{2pt}%
   \def\makelabel##1{\itshape ##1}}%
  }
  {\end{list}\end{raggedright}}
\newenvironment{sansreflist}{%
  \begin{raggedright}\begin{list}{}
  {%
   \setlength{\topsep}{0pt}%
   \setlength{\rightmargin}{0.25in}%
   \setlength{\itemindent}{0pt}%
   \setlength{\parskip}{0pt}%
   \setlength{\itemsep}{0pt}%
   \setlength{\parsep}{2pt}%
   \def\makelabel##1{\upshape ##1}}%
  }
  {\end{list}\end{raggedright}}
\newenvironment{specHead}[2]%
 {\vspace{20pt}\hrule\vspace{10pt}%
  \phantomsection\label{#1}\markright{#2}%

  \pdfbookmark[2]{#2}{#1}%
  \hspace{-0.75in}{\bfseries\fontsize{16pt}{18pt}\selectfont#2}%
  }{}
      \def\TheFullDate{2016-01-15 (revised: 15 January 2016)}
\def\TheID{\makeatother }
\def\TheDate{2016-01-15}
\title{Automock: Automated Mock Backend Generation for Javascript based Applications}
\author{}\makeatletter 
\makeatletter
\newcommand*{\cleartoleftpage}{%
  \clearpage
    \if@twoside
    \ifodd\c@page
      \hbox{}\newpage
      \if@twocolumn
        \hbox{}\newpage
      \fi
    \fi
  \fi
}
\makeatother
\makeatletter
\thispagestyle{empty}
\markright{\@title}\markboth{\@title}{\@author}
\renewcommand\small{\@setfontsize\small{9pt}{11pt}\abovedisplayskip 8.5\p@ plus3\p@ minus4\p@
\belowdisplayskip \abovedisplayskip
\abovedisplayshortskip \z@ plus2\p@
\belowdisplayshortskip 4\p@ plus2\p@ minus2\p@
\def\@listi{\leftmargin\leftmargini
               \topsep 2\p@ plus1\p@ minus1\p@
               \parsep 2\p@ plus\p@ minus\p@
               \itemsep 1pt}
}
\makeatother
\fvset{frame=single,numberblanklines=false,xleftmargin=5mm,xrightmargin=5mm}
\fancyhf{} 
\setlength{\headheight}{14pt}
\fancyhead[LE]{\bfseries\leftmark} 
\fancyhead[RO]{\bfseries\rightmark} 
\fancyfoot[RO]{}
\fancyfoot[CO]{\thepage}
\fancyfoot[LO]{\TheID}
\fancyfoot[LE]{}
\fancyfoot[CE]{\thepage}
\fancyfoot[RE]{\TheID}
\hypersetup{citebordercolor=0.75 0.75 0.75,linkbordercolor=0.75 0.75 0.75,urlbordercolor=0.75 0.75 0.75,bookmarksnumbered=true}
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrulewidth}{0pt}}

\date{}
\usepackage{authblk}

\providecommand{\keywords}[1]
{
\footnotesize
  \textbf{\textit{Index terms---}} #1
}

\usepackage{graphicx,xcolor}
\definecolor{GJBlue}{HTML}{273B81}
\definecolor{GJLightBlue}{HTML}{0A9DD9}
\definecolor{GJMediumGrey}{HTML}{6D6E70}
\definecolor{GJLightGrey}{HTML}{929497} 

\renewenvironment{abstract}{%
   \setlength{\parindent}{0pt}\raggedright
   \textcolor{GJMediumGrey}{\rule{\textwidth}{2pt}}
   \vskip16pt
   \textcolor{GJBlue}{\large\bfseries\abstractname\space}
}{%   
   \vskip8pt
   \textcolor{GJMediumGrey}{\rule{\textwidth}{2pt}}
   \vskip16pt
}

\usepackage[absolute,overlay]{textpos}

\makeatother 
      \usepackage{lineno}
      \linenumbers
      
\begin{document}

             \author[1]{Neha  Singhal}

             \author[2]{Harshit  Jain}

             \affil[1]{  Adobe Systems Incorporated}

\renewcommand\Authands{ and }

\date{\small \em Received: 12 December 2015 Accepted: 31 December 2015 Published: 15 January 2016}

\maketitle


\begin{abstract}
        


Modern web development is an intensely collaborative process. Frontend Developers, Backend Developers and Quality Assurance Engineers are integral cogs of a development machine. Frontend developers constantly juggle developing new features, fixing bugs and writing good unit test cases. Achieving this is sometimes difficult as frontend developers are not able to utilize their time completely. They have to wait for the backend to be ready and wait for pages to load during iterations. This paper proposes an approach that enables frontend developers to quickly generate a mock backend that behaves exactly like their actual backend. This generated mock backend minimizes the dependency between frontend developers and backend developers, since both the teams can now utilize the entire sprint duration efficiently. The approach also aids the frontend developer to perform quicker iterations and modifications to his or her code.

\end{abstract}


\keywords{javascript development; xml http request; javascript testing; web development; automated mock server.}

\begin{textblock*}{18cm}(1cm,1cm) % {block width} (coords) 
\textcolor{GJBlue}{\LARGE Global Journals \LaTeX\ JournalKaleidoscope\texttrademark}
\end{textblock*}

\begin{textblock*}{18cm}(1.4cm,1.5cm) % {block width} (coords) 
\textcolor{GJBlue}{\footnotesize \\ Artificial Intelligence formulated this projection for compatibility purposes from the original article published at Global Journals. However, this technology is currently in beta. \emph{Therefore, kindly ignore odd layouts, missed formulae, text, tables, or figures.}}
\end{textblock*}


\let\tabcellsep& 	 	 		 
\section[{I. Introduction}]{I. Introduction}\par
he modern development process is increasingly moving towards an Agile Workflow. It is a process followed by teams both large and small. There has been a paradigm shift from long, slow development cycles to quick iterations. Agile processes have also been documented in multiple research papers  {\ref [4; 5; 9]}.\par
A typical development sprint is comprised of three major phases. First is the assignment of features to the frontend team and the corresponding backend team. Post the assignment phase, the sprint moves to the feature implementation stage. At this stage, Backend developers work on implementing the server features. The frontend developers have to generally wait for the backend to be ready. Once the backend is ready, the frontend developers implement the user interface.\par
The backend developers are mostly idle during this time. One of the major challenges faced during development is that the non-production environments of integrated third-party services are unstable and not accessible at times, blocking developers from interacting with these services.\par
The final stage is the User interface (UI) unit testing stage. Post feature implementation, the developer has to write test cases for his or her module. There are some frequent issues usually faced at this point. Firstly, UI test cases for asynchronous network calls are messy and time consuming to write. Secondly, UI test cases that make network calls consume a lot of time in execution. Thirdly, UI test cases generally require consistent data based on real-world data. Finally, UI test cases must not add any test data to the database. 
\section[{II. Proposed Model}]{II. Proposed Model}\par
Our approach resolves some of these issues faced by frontend developers. It has an intuitive interface and can easily be integrated into most JavaScript based applications with a single line of code.\par
The key features of our approach are:\par
? A fully-functional mock server ? Very lightweight; comprises just a single JavaScript file ? Flexibility to support as many API calls as required The Agile approach is also followed for web application development (including development of Single Page Applications). A modern web application generally comprises two integral components-the frontend (or the UI) and the backend server. Both run in tandem and are heavily dependent on each other. The frontend depends on the backend for data and the backend relies on the frontend to display the content to the end user. Our approach is best suited for any medium to large-sized JavaScript web application including applications working with third-party components. It also designed for JavaScript unit testing. It is especially suited for interdependent teams working on the same web application in parallel.\par
As of now, the only limitation with our approach is that it only supports web development projects which use JavaScript. Detailed description of our approach: 
\section[{a) Fully functional mock server}]{a) Fully functional mock server}\par
A backend server comprises of a mapping between API calls and the corresponding responses for those calls. The frontend of a web application usually uses the AJAX (Asynchronous JavaScript and XML) protocol \hyperref[b5]{[6]} to query the backend server. Though this allows the application to provide a user with a rich and interactive user experience, it also imposes certain challenges. The XML Http Request Spec \hyperref[b14]{[15]} on which AJAX is based is browser implemented and hard for an application to control directly. To make a network call, the JavaScript code in the application calls the XML Http Request Object of the browser the application is running in directly. The interaction between the application and the XML Http Request Object is done through a series of callbacks. Once the network call is made, the server returns the appropriate response to the caller (based on the API request made). The browser then passes this information along to the application (through the aforementioned callback).\par
The XML Http Request Object according to the specification is meant to be immutable. Applications are not allowed to edit it directly without also manually implementing the overridden functionality. Our approach achieves the same functionality as a normal XML Http Request Object without the application realizing that the XML Http Request Object is being intercepted. Our approach achieves this in the following way. First, our approach intercepts some properties of the global XML Http Request object. This ensures that all AJAX network calls pass through Automock. On intercepting an AJAX network call, Automock checks if the response for the particular call is stored in its data file. Automock then checks if there are possible alternate responses. Based on configuration settings, Automock decides which response to return. If no specific configuration is set, Automock returns the default response. If a stored response is found, Automock returns the updated response. To achieve this, it replaces some properties of the original XML Http Request Object. The following properties of the XML Http Request Object are immutable: response Text, ready State, response, status and status Text. Because these properties cannot be modified, Automock has to delete and replace them with the desired values in the XML Http Request Object. This XML Http Request object is then returned to the calling function. Since, the object is identical to the original XML Http Request Object, it works as expected and the application thinks that it made an actual asynchronous network call. In case there is no response present in the data file, Automock passes the call to the original XML Http Request object and makes the actual network call.\par
These steps ensure that the developer does not need to modify their code at all, while still achieving the functionality required. The mocked response is exactly identical to an actual response, enabling us to make AJAX calls in any preferred way; for example, through the j Query library, directly through an XML Http Request object, or even through any framework dependent-call, such as "fetch" in Backbone.js. 
\section[{b) Very lightweight}]{b) Very lightweight}\par
Our approach comprises of just a single JavaScript file which basically comprises of the process outlined above and a socket communication library to interact with the User Interface and the data in real time. It requires no installation and has a very small memory footprint. All the saved AJAX responses are stored in a single flat file which is also minified and serialized. Since an actual server does not need to be run, it also does not consume much CPU memory. c) Ease of integration Unlike a traditional server which generally requires an application to be installed and run on one of the ports of the computer, Automock can be included in any web application that uses JavaScript with just a single line of code. As we intercept the native XML Http Request Object, we do not have to deal with issues such as port conflicts. It also does not require any build processes or any other external library to load itself into the system. 
\section[{d) Flexibility to support as many API calls as required}]{d) Flexibility to support as many API calls as required}\par
A developer can mock as many API calls as required. If a mocked API call is not present, Automock forwards the request to the actual backend for resolution. This approach covers a vast variety of use cases wherein the developer can use Automock for only a small module or scale it up and use it for the entire application. This approach also allows the library to be integrated into the project at any stage of the development process. In addition to the above, since we modify the native XML Http Request Object, a user can use any popular library to make network requests such as j Query, Backbone.js, Angular's \$http etc. 
\section[{e) Automatic capture and mocking of existing API calls}]{e) Automatic capture and mocking of existing API calls}\par
Our approach provides the functionality to capture and mock any existing API calls within the application. It captures all outgoing AJAX requests and maps them to their corresponding incoming AJAX replies. First, it sets up a watch on all AJAX network calls. If any request is noticed by the watcher, it intercepts each returning AJAX network call and stores the response. This stored value is then mapped as the response to the URL for which the AJAX network call was made. Once it has the responses, it extracts each response and transforms the data into a format that the mock server can read. All such transformed responses are combined with our implementation of the mock server and stored in the JSON format. It records the URL, the response, the request type (Such as GET, PUT etc.) and some configuration options. This is serialized and converted into a file that is saved on the developer's system.\par
The developer can then simply mock all future calls to the same APIs. Thus, the developer can work without having to constantly query the server, speeding up development since no expensive network calls are necessary. f) Significant performance boost to unit test case execution Frontend (and JavaScript) testing is a complex subject with lots of research taking place. Regardless of the desired approach which may be either tool based (Such as Webmate \hyperref[b2]{[3]} or ATUSA \hyperref[b9]{[10]}) or automated \hyperref[b1]{[2]}, testing of asynchronous code and especially network requests is challenging.\par
Developers usually write multiple JavaScript unit test cases to test their modules. Running an entire suite of tests is usually very slow, because a large number of AJAX calls are made repeatedly. In our experience, the bottleneck while running a large number of test cases is the time taken by the network requests. By using our approach, the responses are instantaneous. During our testing, we have experienced a significant performance boost in our unit test cases. 
\section[{g) No interaction with the database}]{g) No interaction with the database}\par
An important requirement during the developpment phase is to avoid adding unnecessary data into the database. To combat this issue, developer teams either use local databases or setup a stage database. Both of these options are time consuming and possibly expensive as well. Since our approach does not make real API calls to the server, it solves this problem without the hassles of setting up a separate database 
\section[{h) Supports alternate error responses for any API call}]{h) Supports alternate error responses for any API call}\par
A developer must handle error responses during development. It is generally tricky to get error responses out of any good backend in a simple way. Our approach supports returning an error response for an API with some simple configuration settings. A developer can quickly and easily change API responses by either directly modifying the flat file or through the accompanying UI. This approach also helps ensure that a developer has handled all possible cases on the client facing UI. 
\section[{i) Supports multiple responses for the same API call}]{i) Supports multiple responses for the same API call}\par
Modern web applications now increasingly show different users different data based on the context. For example, when fetching the news feed for a user or fetching list of items for a particular category on an ecommerce site. Automock can be configured to return different responses for the same API call to simulate various situations. 
\section[{III. Case Study}]{III. Case Study}\par
A version 2.0 prerelease web application was taken up for this case study. The project used an agile methodology and a timeline of about 6-8 weeks. The developers comprised two teams that worked in parallel. One team handled the backend and the other team handled the frontend of the web application. Each sprint was broken down into multiple stories/features being implemented. Here are the various phases we went through during our sprint where we made use of Automock: a) Step 1: New feature implementation At this point, both the frontend and the backend developers started development on the new feature. We used Automock quite effectively to make this process much more efficient. The backend developer would create the API stub (The name of the API and what parameters it takes) and use the Automock UI to set the typical response for the API. The frontend developer would then just run the fake server and implement their feature. When the actual API was ready, no more code changes were required for the frontend developer and they could just switch out the mock server for the real server. Since no developer was blocked, both the teams could pick up more features and utilize the entire sprint duration, thus requiring fewer sprints for the same set of features. 
\section[{b) Step 2: Handling edge cases}]{b) Step 2: Handling edge cases}\par
Once the frontend developer had finished implementing a feature, they could work on handling edge cases and on handling error cases appropriately. To achieve this, they no longer needed hacks or workarounds. They could just modify the existing mock server response for that API with an error response and continue their development. Since this approach accurately simulates an API call, there is a much better end user experience when things go wrong at runtime. 
\section[{Table 1: Comparison of time taken while developing for edge cases}]{Table 1: Comparison of time taken while developing for edge cases}\par
Notes:\par
? Time taken without Automock is calculated as: Time taken to modify backend code (\textasciitilde 60 sec) + Time taken to build the .war file (76 sec) + Time taken to deploy the .war file (57 sec) = Total Time (193 sec) ? Time taken with Automock is calculated as: Time taken to modify frontend code; that is, changing the configuration variable (\textasciitilde 8 sec) = Total Time (8 sec). The time taken to build and deploy the .war file is not required here as no backend changes are needed.\par
? All times are measured on a typical developer system. 
\section[{c)}]{c)}\par
Step 3: Adding functionality to pre-existing features Some pre-existing areas of our code had to be modified to add new functionality. This is where we used one of Automock's best features -Automock can automatically capture and generate mock responses for all existing API calls. We captured all outgoing requests and stored the incoming responses. Since the application now no longer made time-consuming API calls, code edits and unit testing in these areas took much less time. Results:  
\section[{d) Step 4: Third-party services}]{d) Step 4: Third-party services}\par
Our application has dependencies on various third party services. We use these services for authentication, community forums, bug tracking etc. We encountered frequent outages from these third party services, especially on the stage environments. Using Automock, we were able to mock all the related network calls and responses. Once this was done, we were no longer dependent on the availability of the third party service. This helped us mitigate any delays in development caused by the outages.  
\section[{e) Step 5: Unit Testing}]{e) Step 5: Unit Testing}\par
Once the frontend developer has finished implementing a feature, they can then write the unit test cases for it. Generally, test cases that make network requests take a long time to complete. Such test cases are also time-consuming to write, since asynchronous logic is hard to implement in most testing frameworks. We have observed that most of the execution time of test cases is taken up by network requests.\par
Automock helped us solve this problem in a very elegant manner. Since mocked API calls return instantaneously, there was no need to handle asynchronous logic in the test cases. Also, since no expensive network calls were made, the test suite ran significantly faster. This gave us the double benefit of faster test case execution (with no messy workarounds for handling asynchronous calls) and faster test case creation. It also helped us write test cases with realworld data that was static and repeatable. Using Automock, we also avoided polluting the database with junk test data. 
\section[{f ) Step 6: Context based responses}]{f ) Step 6: Context based responses}\par
Modern web applications are moving towards context sensitive responses. The same API call can return different responses based on multiple parameters. For example, our website returns different responses based on the credentials of a user. Using Automock, we were easily able to run the application as a different user. We set configuration parameters/flags and ran the application with different contexts. This allowed us to thoroughly handle all the cases that an end user might face, making our application much more robust and user friendly. Year 2016 ( ) For example, we see that on setting config. user as User1, we get "Response Type 1" as the mocked response. However, on setting config. user as User2, we get "Response Type 2" as the mocked response. We could, similarly, set as many alternate responses as we required using configuration options. JavaScript application testing is a comparatively recent field due to the increasing size and complexity of modern web applications. More recently, there has been extensive research in the areas of automated testing  {\ref [12; 13]}.However, this will still require having to either make the actual network call or write stubbing or mocking logic for the network call. Our approach helps us handle this problem easily and efficiently by mocking the API automatically. Since, the API calls are mocked using our approach, the actual network calls do not have to be made and no extra stubbing logic is required.\par
Along with research, there are existing libraries and tools to aid web development. Since it is an area of intense activity, there are some libraries already present in this space. In order to adequately put into context the related work in the field, it will be helpful to list down the minimum set of features that we required.\par
Any framework or library that we use should have a certain baseline of requirements. It should be independent of the development phase (Support use during both testing and development). It should mock network calls without requiring a change in code. It should automatically capture existing network calls as well as allow for the creation of mocks for new network calls. It should support polymorphic responses to network calls. Lastly, it should be lightweight to include and should have zero interaction with the database. Some of the libraries under consideration by us were: a) SinonJS [14] b) Jasmine-AJAX [7] c) Api-mock [1] d) Mockjax [8] a) SinonJS\par
SinonJS is one of the most popular mocking/stubbing frameworks around. It is great at stubbing and mocking API calls. However, it is limited in its scope as it is a purely testing focused library. Though powerful as a test tool, it requires a great deal of setup and teardown to use in tests. However, SinonJS does not work at all during the development phase. 
\section[{b) Jasmine-AJAX}]{b) Jasmine-AJAX}\par
Jasmine-AJAX solved one of the most pressing problems with SinonJS -easily mocking API calls. Jasmine-AJAX provides an easily customizable framework to modify the response to a network call. However, it also has a major limitation of only working with the Jasmine testing framework. Similar to SinonJS, this is also a testing focused library and does not work during the development phase. 
\section[{c) API-Mock}]{c) API-Mock}\par
API-Mock is an excellent tool to generate a mock server (running on Express) based on API blueprints. API-mock lets you document your API in the API blueprint format, generates mocks for your routes and sends the responses defined in the API spec. Since API-Mock generates a mock server, it can be used during both development and testing phases. However, it has the caveat of not working well with the existing server. Code changes are required to accommodate the generated API-mock server configuration. Due to this, it was not a good fit for our requirements. 
\section[{d) Mockjax}]{d) Mockjax}\par
Mockjax provides the easiest way of mocking API calls as compared to the other libraries listed above. One drawback of this library is that it is a manual process. The typical workflow for using Mockjax is to integrate the backend code and make the AJAX network call. Then a developer needs to copy the response for each call manually. Then they must transform the response into a Mockjax supported format. Finally, the developer must paste this formatted response into a file and integrate the library.\par
Though the process seems simple, the time taken to manually add calls using this workflow takes a large amount of time and effort. For a medium to large scaled project, this problem is compounded since a very large number of AJAX calls must be integrated into the application.\par
A combination of the factors above led to the development of Automock. As we have demonstrated through this paper and through the data provided in the tables, our approach realizes tangible and measurable benefits during development of a web application. It is most effective when interdependent teams are working together. Here are the key benefits: There has been some research where the XML Http Request Object is either monitored \hyperref[b15]{[16]} or encapsulated \hyperref[b10]{[11]}. To the best of our knowledge, Automock is the only original research paper that overrides a part of the native XML Http Request Object for automating the mocking of network calls. This not only aids in testing but also in development and achieves the goal of removing the dependency between frontend and backend team during agile sprints. 
\section[{V. Conclusion and Advantages}]{V. Conclusion and Advantages}\par
? Helps manage third-party service outages \begin{figure}[htbp]
\noindent\textbf{1}\includegraphics[]{image-2.png}
\caption{\label{fig_0}Figure 1 :}\end{figure}
 \begin{figure}[htbp]
\noindent\textbf{2}\includegraphics[]{image-3.png}
\caption{\label{fig_1}Figure 2 :}\end{figure}
 \begin{figure}[htbp]
\noindent\textbf{3}\includegraphics[]{image-4.png}
\caption{\label{fig_2}Figure 3 :}\end{figure}
  \begin{figure}[htbp]
\noindent\textbf{2} \par 
\begin{longtable}{P{0.36106194690265486\textwidth}P{0.27079646017699116\textwidth}P{0.21814159292035398\textwidth}}
Time Taken (sec)\tabcellsep Without AUTOMOCK\tabcellsep With AUTOMOCK\\
Module 1\tabcellsep 14.11\tabcellsep 0.31\\
Module 2\tabcellsep 18.13\tabcellsep 2.90\\
Module 3\tabcellsep 31.63\tabcellsep 0.21\\
Module 4\tabcellsep 49.07\tabcellsep 0.20\end{longtable} \par
  {\small\itshape [Note: Notes:? Modules in this table refer to a section/page of our application, each of which loads a different number of asynchronous AJAX calls. ? All times are measured on a typical developer system.]} 
\caption{\label{tab_1}Table 2 :}\end{figure}
 \begin{figure}[htbp]
\noindent\textbf{3} \par 
\begin{longtable}{P{0.7626306620209059\textwidth}P{0.050348432055749126\textwidth}P{0.03702090592334495\textwidth}}
Time Taken (sec)\tabcellsep Without AUTOMOCK\tabcellsep With AUTOMOCK\\
User: User1\tabcellsep 108.56\tabcellsep 3.51\\
User: User2\tabcellsep 112.94\tabcellsep 3.51\\
User: User3\tabcellsep 121.27\tabcellsep 3.51\\
Notes:\tabcellsep \tabcellsep \\
\multicolumn{2}{l}{? Our application has user-specific data. Hence, the}\tabcellsep \\
\multicolumn{2}{l}{time taken without Automock varies for different}\tabcellsep \\
users.\tabcellsep \tabcellsep \\
\multicolumn{2}{l}{? The time taken mentioned in this table was the}\tabcellsep \\
\multicolumn{2}{l}{aggregate time taken to load all the four modules}\tabcellsep \\
mentioned in table 2.\tabcellsep \tabcellsep \\
\multicolumn{2}{l}{? All times were measured on a typical developer}\tabcellsep \\
system.\tabcellsep \tabcellsep \\
IV. Related Work\tabcellsep \tabcellsep \\
\multicolumn{2}{l}{JavaScript and Web Development in general}\tabcellsep \\
\multicolumn{2}{l}{are exciting fields for research and development. Our}\tabcellsep \\
\multicolumn{2}{l}{work is focused on easing the experience of web}\tabcellsep \\
development and testing.\tabcellsep \tabcellsep \end{longtable} \par
 
\caption{\label{tab_2}Table 3 :}\end{figure}
 \begin{figure}[htbp]
\noindent\textbf{4} \par 
\begin{longtable}{P{0.6214622641509434\textwidth}P{0.03608490566037736\textwidth}P{0.05613207547169811\textwidth}P{0.044103773584905664\textwidth}P{0.040094339622641514\textwidth}P{0.052122641509433965\textwidth}}
\tabcellsep SinonJS\tabcellsep Jasmine-AJAX\tabcellsep Api-Mock\tabcellsep Mockjax\tabcellsep Automock\\
Support testing and development\tabcellsep \tabcellsep \tabcellsep ?\tabcellsep ?\tabcellsep ?\\
Mock without code changes\tabcellsep ?\tabcellsep ?\tabcellsep \tabcellsep ?\tabcellsep ?\\
Support polymorphic responses\tabcellsep ?\tabcellsep ?\tabcellsep ?\tabcellsep ?\tabcellsep ?\\
Automatic network call capture\tabcellsep \tabcellsep \tabcellsep \tabcellsep \tabcellsep ?\\
Support creation of new network requests\tabcellsep \tabcellsep \tabcellsep ?\tabcellsep \tabcellsep ?\end{longtable} \par
 
\caption{\label{tab_3}Table 4 :}\end{figure}
 \begin{figure}[htbp]
\noindent\textbf{} \par 
\begin{longtable}{}
\end{longtable} \par
 
\caption{\label{tab_4}}\end{figure}
 			\footnote{© 2016 Global Journals Inc. (US)} 		 		\backmatter  			  				\begin{bibitemlist}{1}
\bibitem[Api-Mock and Api-Mock ()]{b0}\label{b0} 	 		\textit{},  		 			Api-Mock 		,  		 			Api-Mock 		.  		 \url{https://github.com/localmed/api-mock}  		2016.  	 
\bibitem[
			Jasmine-Ajax
		 ()]{b6}\label{b6} 	 		\textit{},  		 			Jasmine-Ajax 		.  		 \url{https://github.com/jasmine/jasmine-ajax}  		2016.  	 
\bibitem[Mockjax and Jquery-Mockjax ()]{b7}\label{b7} 	 		\textit{},  		 			Mockjax 		,  		 			Jquery-Mockjax 		.  		 \url{https://github.com/jakerella/jquery-mockjax}  		2016.  	 
\bibitem[Sinon and Sinonjs ()]{b13}\label{b13} 	 		\textit{},  		 			Sinon 		,  		 			Sinonjs 		.  		 \url{http://sinonjs.org/}  		2016.  	 
\bibitem[Xhr and Xml Http Request ()]{b14}\label{b14} 	 		\textit{},  		 			Xhr 		,  		 			Xml Http Request 		.  		 \url{https://xhr.spec.whatwg.Org/}  		2016.  	 
\bibitem[Ganis et al.]{b4}\label{b4} 	 		‘A brief report on working smarter with Agile software develop ment’.  		 			M Ganis 		,  		 			E M Maximilien 		,  		 			T Rivera 		.  	 	 		\textit{IBM Journal of Research and Development}  		54  (4)  p. .  	 
\bibitem[Artzi et al.]{b1}\label{b1} 	 		‘A framework for automated testing of javascript web applications’.  		 			S Artzi 		,  		 			J Dolby 		,  		 			S H Jensen 		,  		 			A Moller 		,  		 			F Tip 		.  	 	 		\textit{Proceedings of the 33rd International Conference on Software Engineering},  				 (the 33rd International Conference on Software EngineeringNew York)  		ACM. p. .  	 
\bibitem[Dinakar]{b3}\label{b3} 	 		‘Agile development: overcoming a shortterm focus in implementing best practices’.  		 			K Dinakar 		.  	 	 		\textit{Proceedings of the 24th ACM SIGPLAN conference companion on Object oriented programming systems languages and applications},  				 (the 24th ACM SIGPLAN conference companion on Object oriented programming systems languages and applicationsNew York)  		ACM. p. .  	 
\bibitem[Garrett ()]{b5}\label{b5} 	 		\textit{Ajax: A new approach to Web applications},  		 			J Garrett 		.  		 \url{http://adaptivepath.org/ideas/ajax-new-approach-web-applications/}  		2005. 2016.  	 
\bibitem[Negara and Stroulia]{b12}\label{b12} 	 		‘Automated Acceptance Testing of JavaScript Web Applications’.  		 			N Negara 		,  		 			E Stroulia 		.  	 	 		\textit{19th Working Conference on Reverse Engineering},  				p. .  	 
\bibitem[Mirshokraie et al.]{b11}\label{b11} 	 		‘Automated Javascript Unit Test Generation’.  		 			S Mirshokraie 		,  		 			A Mesbah 		,  		 			K Pattabiraman 		,  		 			Jseft 		.  	 	 		\textit{IEEE 8th International Conference on Software Testing, Verification and Validation, (ICST '15)},  				p. .  	 
\bibitem[Meyerovich et al.]{b10}\label{b10} 	 		‘Flapjax: a programming language for Ajax applications’.  		 			L A Meyerovich 		,  		 			A Guha 		,  		 			J Baskin 		,  		 			G H Cooper 		,  		 			M Greenberg 		,  		 			A Bromfield 		,  		 			S Krishnamurthi 		.  	 	 		\textit{Proceedings of the 24th ACM SIGPLAN conference on Object oriented programming systems languages and applications},  				 (the 24th ACM SIGPLAN conference on Object oriented programming systems languages and applicationsNew York)  		ACM. p. .  	 
\bibitem[Mesbah and Deursen]{b9}\label{b9} 	 		‘Invariant-based automatic testing of AJAX user interfaces’.  		 			A Mesbah 		,  		 			A V Deursen 		.  	 	 		\textit{Proceedings of the 31st International Conference on Software Engineering, (ICSE '09)},  				 (the 31st International Conference on Software Engineering, (ICSE '09))  		IEEE Computer Society Washington. p. .  	 
\bibitem[Kosk and Mikkonen]{b8}\label{b8} 	 		‘Rolling out a mission critical system in an agilish way: reflections on building a large-scale dependable information system for public sector’.  		 			A Kosk 		,  		 			T Mikkonen 		.  	 	 		\textit{Proceedings of the Second International Workshop on Rapid Continuous Software Engineering},  				 (the Second International Workshop on Rapid Continuous Software Engineering)  		IEEE Press Piscataway. p. .  	 	 (RCoSE '15) 
\bibitem[Zheng et al.]{b15}\label{b15} 	 		‘Statically locating web application bugs caused by asynchronous calls’.  		 			Y Zheng 		,  		 			T Bao 		,  		 			X Zhang 		.  	 	 		\textit{Proceedings of the 20th international conference on World Wide Web},  				 (the 20th international conference on World Wide WebNew York)  		ACM. p. .  	 
\bibitem[Dallmeier et al.]{b2}\label{b2} 	 		‘WebMate: a tool for testing web 2.0 applications’.  		 			V Dallmeier 		,  		 			M Burger 		,  		 			T Orth 		,  		 			A Zeller 		.  	 	 		\textit{Proceedings of the Workshop on JavaScript Tools},  				 (the Workshop on JavaScript ToolsNew York)  		ACM. p. .  	 
\end{bibitemlist}
 			 		 	 
\end{document}
