switch over to using Testacular for running unit tests
[angular-drzb] / README.md
1 # angular-seed — the seed for AngularJS apps
2
3 This project is an application skeleton for a typical [AngularJS](http://angularjs.org/) web app.
4 You can use it to quickly bootstrap your angular webapp projects and dev environment for these
5 projects.
6
7 The seed contains AngularJS libraries, test libraries and a bunch of scripts all preconfigured for
8 instant web development gratification. Just clone the repo (or download the zip/tarball), start up
9 our (or yours) webserver and you are ready to develop and test your application.
10
11 The seed app doesn't do much, just shows how to wire two controllers and views together. You can
12 check it out by opening app/index.html in your browser (might not work file `file://` scheme in
13 certain browsers, see note below).
14
15 _Note: While angular is client-side-only technology and it's possible to create angular webapps that
16 don't require a backend server at all, we recommend hosting the project files using a local
17 webserver during development to avoid issues with security restrictions (sandbox) in browsers. The
18 sandbox implementation varies between browsers, but quite often prevents things like cookies, xhr,
19 etc to function properly when an html page is opened via `file://` scheme instead of `http://`._
20
21
22 ## How to use angular-seed
23
24 Clone the angular-seed repository and start hacking...
25
26
27 ### Running the app during development
28
29 You can pick one of these options:
30
31 * serve this repository with your webserver
32 * install node.js and run `scripts/web-server.js`
33
34 Then navigate your browser to `http://localhost:<port>/app/index.html` to see the app running in
35 your browser.
36
37
38 ### Running the app in production
39
40 This really depends on how complex is your app and the overall infrastructure of your system, but
41 the general rule is that all you need in production are all the files under the `app/` directory.
42 Everything else should be omitted.
43
44 Angular apps are really just a bunch of static html, css and js files that just need to be hosted
45 somewhere, where they can be accessed by browsers.
46
47 If your Angular app is talking to the backend server via xhr or other means, you need to figure
48 out what is the best way to host the static files to comply with the same origin policy if
49 applicable. Usually this is done by hosting the files by the backend server or through
50 reverse-proxying the backend server(s) and a webserver(s).
51
52
53 ### Running unit tests
54
55 We recommend using [jasmine](http://pivotal.github.com/jasmine/) and
56 [Testacular](http://vojtajina.github.com/testacular/) for your unit tests/specs, but you are free
57 to use whatever works for you.
58
59 Requires [node.js](http://nodejs.org/), Testacular (`sudo npm install -g testacular`) and a local
60 or remote browser.
61
62 * start `scripts/test.sh` (on windows: `scripts\test.bat`)
63   * a browser will start and connect to the Testacular server (Chrome is default browser, others can be captured by loading the same url as the one in Chrome or by changing the `config/testacular.conf.js` file)
64 * to run or re-run tests just change any of your source or test javascript files
65
66
67 ### End to end testing
68
69 Angular ships with a baked-in end-to-end test runner that understands angular, your app and allows
70 you to write your tests with jasmine-like BDD syntax.
71
72 Requires a webserver, node.js + `./scripts/web-server.js` or your backend server that hosts the angular static files.
73
74 Check out the
75 [end-to-end runner's documentation](http://docs.angularjs.org/guide/dev_guide.e2e-testing) for more
76 info.
77
78 * create your end-to-end tests in `test/e2e/scenarios.js`
79 * serve your project directory with your http/backend server or node.js + `scripts/web-server.js`
80 * to run do one of:
81   * open `http://localhost:port/test/e2e/runner.html` in your browser
82   * run the tests from console with [Testacular](vojtajina.github.com/testacular) via
83     `scripts/e2e-test.sh` or `script/e2e-test.bat`
84
85
86 ### Receiving updates from upstream
87
88 When we upgrade angular-seed's repo with newer angular or testing library code, you can just
89 fetch the changes and merge them into your project with git.
90
91
92 ## Directory Layout
93
94     app/                --> all of the files to be used in production
95       css/              --> css files
96         app.css         --> default stylesheet
97       img/              --> image files
98       index.html        --> app layout file (the main html template file of the app)
99       js/               --> javascript files
100         controllers.js  --> application controllers
101         filters.js      --> custom angular filters
102         services.js     --> custom angular services
103         widgets.js      --> custom angular widgets
104       lib/              --> angular and 3rd party javascript libraries
105         angular/
106           angular.js            --> the latest angular js
107           angular.min.js        --> the latest minified angular js
108           angular-*.js  --> angular add-on modules
109           version.txt           --> version number
110       partials/         --> angular view partials (partial html templates)
111         partial1.html
112         partial2.html
113
114     config/testacular.conf.js        --> config file for running unit tests with Testacular
115     config/testacular-e2e.conf.js    --> config file for running e2e tests with Testacular
116
117     scripts/            --> handy shell/js/ruby scripts
118       e2e-test.sh       --> runs end-to-end tests with Testacular (*nix)
119       e2e-test.bat      --> runs end-to-end tests with Testacular (windows)
120       test.bat          --> autotests unit tests with Testacular (windows)
121       test.sh           --> autotests unit tests with Testacular (*nix)
122       web-server.js     --> simple development webserver based on node.js
123
124     test/               --> test source files and libraries
125       e2e/              -->
126         runner.html     --> end-to-end test runner (open in your browser to run)
127         scenarios.js    --> end-to-end specs
128       lib/
129         angular/                --> angular testing libraries
130           angular-mocks.js      --> mocks that replace certain angular services in tests
131           angular-scenario.js   --> angular's scenario (end-to-end) test runner library
132           version.txt           --> version file
133       unit/                     --> unit level specs/tests
134         controllersSpec.js      --> specs for controllers
135
136 ## Contact
137
138 For more information on AngularJS please check out http://angularjs.org/