From skipping over the source it seems that this project doesn't use the best practice guide introduced by Angular earlier this year (https://docs.google.com/document/d/1XXMvReO8-Awi1EZXAXS4PzDzdNvV6pGcuaF4Q9821Es/pub). It's quite sad that from my experience really few people follow this guide and that none (?) of Angulars own projects encourages the guide - so it became quite pointless. I understand that https://github.com/angular/angular-phonecat and https://github.com/angular/angular-seed are maybe to small for the recommended practices in the guide and that they were created earlier. However this is a new project and it seems to have a larger scale which is really good. If there was ever a public big project from the Angular team itself it seems that it is this one. So please use or change the best practice guide.
FYI:
I tried to follow this guide in enterprise projects and hit some walls. I currently use it with some modifications. Example app structure:
karma.conf.js
protractor.conf.js
dgeni.conf.js
dist/
src/
index.html
style.css
app.js
app_e2e.js
user/
user.html
user.css
user.js
user_e2e.js
user-controller.js
user-controller_test.js
user-filter.js
user-filter_test.js
Every JS file without a controller/filter/service/directive/etc.-suffix is just a module containing value
, constant
, config
and/or run
functions (e.g. app.js
, user.js
).
Every JS file with a controller/filter/service/directive/etc.-Suffix contains the type of functionality described in the suffix, but is a module, too. E.g. user-controller.js
has a module name like app.user.controller
. user.js
has a module name like app.user
and declares app.user.controller
as a dependency. As every file is a module itself and Angular handles the dependency tree the build configuration becomes really simple: it's just a concat
with two globs [ 'src/**/*.js', '!src/**/*_{test,e2e}.js' ]
.
Every JS file without a controller/filter/service/directive/etc.-suffix can have a _e2e
-suffix which refers to a proctector file for end-2-end tests.
Every JS file with a controller/filter/service/directive/etc.-suffix can have a _test
-suffix which refers to a karma file for unit tests.
With my experience these separation for tests scales very well and feels very natural. Most of the stuff happening in modules is only suited for e2e-tests while controllers, services, etc. can be test quite well with unit-tests. If a module contains very custom logic in a run
and config
function which can't be extracted into a service I sometimes also add unit tests for these case (e.g. a user_test.js
).
Like the example with concat
this structure helps a lot in the build configuration. I test our coding style with jscs
for all js files with a simple 'src/**/*.js'
as it doesn't matter if I write a test or a source file. jshint
however is targeted for [ 'src/**/*.js', '!src/**/*_{test,e2e}.js' ]
and 'src/**/*_{test,e2e}.js'
separately to target different rules, globals, etc. for Node and browser environment.
Configuration files for Karma, Protractor and Dgeni are all named in a similar fashion: (type).conf.js
. (I generally try to name JS files as configurations consistently as (type).conf.js
and JSON files as configurations as .(type)rc
like .jscsrc
or .jshintrc
. Some frameworks force this, some not...) If I need to be more specific I again use suffixes like protractor-travis.conf.js
and protractor-jenkins.conf.js
.
(Note: The _test
suffix could also be named _unit
which would be more consistent to _e2e
, but if someone already used the best practice guide before this person would be more familiar with _test
so I didn't rename it.)
Anyway... I don't want to spam you and don't want to say that my way would be the right way. I just want to provide some feedback which could be beneficial for others.