This file explains how to set-up environment to start work with this project template. This project uses (Gulp, Bower, Jasmine, Karma).
In this sample project you can find
- set of useful gulp tasks,
- sample unit tests
- fully configured karma file which generates tests & coverage report
- jenkins integration (not implemented yet)
Following software needs to be installed for UI development with this project template
- Node.js & npm (Node package manager)
- Git
Once Node & npm is installed in your machine, you can install all node packages with node console.
-
start > search and open "Node.js command prompt"
-
Change the current directory in your console to by using "cd" command where you can find "package.json" file Eg: > cd "C:\Users\UserName\Documents\Workspaces\project_name"
-
Execute following commands in "Node.js command prompt" to install few node packages globally
npm install -g bower gulp phantomjs jasmine-core npm install -g karma karma-chrome-launcher karma-cli karma-coverage karma-html-reporter karma-jasmine karma-phantomjs-launcher -
Execute following commands in "Node.js command prompt" to install few node packages locally. This command not only install project dependencies but also runs karma runner on PhantomJS for you.
npm install
First you need to install the Chrome browser. Now karma runner requires an environment variable called "CHROME_BIN" (for Chrome browser). This can be set in the user account environment variables by searching with word "env" in start
- Start > search "env" > open "Edit environment variable for your account".
- Click on "New" button under "User Variables for ..."
- In Variable name enter : CHROME_BIN
- In Variable value enter : "path to exe file of chrome browser" Eg: C:\Users\PalaSK\AppData\Local\Google\Chrome\Application\chrome.exe (if it exists here)
- Restart your command prompt and enter "%CHROME_BIN%" which should open a chrome browser
- If the above step doesn’t open a chrome browser, please check the path you have provided in environment variables
- In karma.config.js at line no 66, add "Chrome" to the browsers array
- start karma runner to run on both PhantomJS & Chrome browser
You can execute following commands to perform development tasks
-
To compile your sass to css
gulp sass -
To watch and compile sass to css automatically
gulp sass-watcher -
To convert all your html templates & push those into angularTemplateCache
gulp html2js -
To watch, convert & push all your html templates & push those into angularTemplateCache
gulp html2js-watcher -
To compress all css, js files for build & dist
not implemented yet ;)
-
Open "Node.js command prompt"
-
Run gulp task
gulp html2jsThis gulp task converts all your html templates to javascript templates and updates into angular template cache. Whenever you change any html file, you should execute this command or you can execute a watcher command in a separate window specified in gulp tasks section
-
Start karma runner - following command starts karma runner, executes all the unit test cases, generates all reports and also watches for any change in our js files & executes all unit tests again
karma start karma.config.js -
Run karma with few options
karma start karma.config.js --reporters html,coverage,dots // To generate perticular reports karma start karma.config.js --browsers Chrome // To run only in chrome karma start karma.config.js --single-run // To run only once -
You need to open html report files from "tests/reports" in browser to check the generated reports
npm installs more than 30,000 files in "node_modules" directory. When we do maven clean & build, maven tries to put all these node modules inside *.war file, which takes more than 1 hour. So In order to exclude "node_modules" folder insert following plugin in \web\pom.xml (inside plugins tag)
<plugins>
<!-- other plugins -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
<warSourceExcludes>node_modules/**,data/**,build/**,tests/**</warSourceExcludes>
</configuration>
</plugin>
<!-- other plugins -->
</plugins>