├── .coveralls.yml ├── .gitignore ├── .jshintrc ├── .travis.yml ├── Gruntfile.js ├── LICENSE ├── README.md ├── cucumber └── index.js ├── package.json ├── resources ├── app │ ├── .DS_Store │ └── angularjs │ │ ├── bower.json │ │ ├── bower_components │ │ ├── angular-route │ │ │ └── angular-route.js │ │ ├── angular │ │ │ └── angular.js │ │ └── todomvc-common │ │ │ ├── base.css │ │ │ ├── base.js │ │ │ └── bg.png │ │ ├── index.html │ │ ├── js │ │ ├── app.js │ │ ├── controllers │ │ │ └── todoCtrl.js │ │ ├── directives │ │ │ ├── todoEscape.js │ │ │ └── todoFocus.js │ │ └── services │ │ │ └── todoStorage.js │ │ ├── readme.md │ │ └── test │ │ ├── config │ │ └── karma.conf.js │ │ ├── package.json │ │ ├── readme.md │ │ └── unit │ │ ├── directivesSpec.js │ │ └── todoCtrlSpec.js ├── saveCoverage.tmpl └── specFile.tmpl ├── tasks └── protractor_coverage.js └── test ├── cucumber.conf.js ├── features ├── step_definitions │ └── stepDefinitions.js └── test.feature ├── myTemplate.tmpl ├── protractor ├── exclude.spec.js ├── exclude2.spec.js └── test.spec.js ├── protractorConf.js ├── protractorConf.remote.js └── protractor_coverage_test.js /.coveralls.yml: -------------------------------------------------------------------------------- 1 | service_name: travis-ci 2 | repo_token: wPBYvucjdBuTmPj0lET91mXfvsGxuVlH7 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | lib-cov 2 | *.seed 3 | *.log 4 | *.csv 5 | *.dat 6 | *.out 7 | *.pid 8 | *.gz 9 | 10 | pids 11 | logs 12 | results 13 | 14 | npm-debug.log 15 | node_modules 16 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "curly": true, 3 | "eqeqeq": true, 4 | "immed": true, 5 | "latedef": true, 6 | "newcap": true, 7 | "noarg": true, 8 | "sub": true, 9 | "undef": true, 10 | "boss": true, 11 | "eqnull": true, 12 | "node": true 13 | } 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | env: 2 | global: 3 | - secure: Al5FuEPE1pcadZNiWNcPyz3DZw7aFnBu/4qi8l7/K6IpmpvuOcDRDbhNqZaosfWSzE6AiVYlKXOSi9wafIjxUQ77W2o8iTi0TL/vEl3uoYB8Ne/4F4HL7CIZHFWv2QzlBHpiUJMo8mctUIHYns9/cM7Le4WGlpInNMMcjTzrhIQ= 4 | - secure: JrjTYKr32SadmQQGLl4aj6CnrUJuMGLOjEl6VjQWZEkgWU2+L7gdF09z1LbdsPh7Gz5/FnkRiYZTl5Ssl0gbY/F9veTGP4K+5MLYaOeFdZ6QJ6MAnFRKzwxSOqjgT9IrIknzojCi06I0VGyDFrrt9JhK+Sbx5Iv7koK76e2CpWE= 5 | language: node_js 6 | node_js: 7 | - "4.2" 8 | - "5" 9 | addons: 10 | sauce_connect: 11 | username: 12 | secure: vzmgWK87Z4F8e6D8G5f6uogQeKeVFW8mortiDY0LctDHn5xWQSFdo0xWnjAs5MDBc1fgHwplqV93n5fMwu3BCuDZTPPJ8v2T3jTk2Fe8YlMVu8Hh3G6e2qRySimN8gILkpl/FC5BffbMsjNp8zultfv8M3gTX90WSK6ny4TQKwI= 13 | access_key: 14 | secure: Jw9dhWLg60cEpFwmdBwg5lBe0BnGEM0c801zlaT30Ma6k0I2nNOH93ZVPH3ejxlbaYcjKrV2/A5ajUYO0OrlRPrblKO2JS5V355yPauXAC+fMbkbGiKHTQbgmzdk782u1ETy+bfGiZrH+BEkVlaVfpyguzEBieriybRr4+H6FFg= 15 | before_script: 16 | - "npm i" 17 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | /* 2 | * grunt-protractor-coverage 3 | * https://github.com/r3b/grunt-protractor-coverage 4 | * 5 | * Copyright (c) 2014 ryan bridges 6 | * Licensed under the APLv2 license. 7 | */ 8 | 9 | 'use strict'; 10 | var tmp = require('tmp'); 11 | module.exports = function(grunt) { 12 | 13 | // Project configuration. 14 | grunt.initConfig({ 15 | jshint: { 16 | all: [ 17 | 'Gruntfile.js', 18 | 'tasks/*.js', 19 | '<%= nodeunit.tests %>', 20 | ], 21 | options: { 22 | jshintrc: '.jshintrc', 23 | }, 24 | }, 25 | 26 | // Before generating any new files, remove any previously-created files. 27 | clean: { 28 | options: { 29 | force:true 30 | }, 31 | tests: ['tmp', 'build', 'instrumented', 'coverage', 'reports'], 32 | }, 33 | connect: { 34 | server: { 35 | options: { 36 | port: 3000, 37 | base: 'instrumented/resources/app/angularjs' 38 | } 39 | }, 40 | }, 41 | // Configuration to be run (and then tested). 42 | protractor_coverage: { 43 | options: { 44 | configFile: "test/protractorConf.js", // Default config file 45 | keepAlive: true, // If false, the grunt process stops when the test fails. 46 | noColor: false, // If true, protractor will not use colors in its output. 47 | coverageDir: 'coverage', 48 | args: {}, 49 | saveCoverageTemplate: "resources/saveCoverage.tmpl" 50 | }, 51 | local: { 52 | options: { 53 | args: { 54 | baseUrl: 'http://localhost:3000/', 55 | // Arguments passed to the command 56 | 'browser': 'chrome' 57 | } 58 | } 59 | }, 60 | remote: { 61 | options: { 62 | configFile: "test/protractorConf.remote.js", // Default config file 63 | args: { 64 | baseUrl: 'http://localhost:3000/', 65 | // Arguments passed to the command 66 | 'browser': 'chrome' 67 | } 68 | } 69 | }, 70 | cucumber: { 71 | options: { 72 | configFile: "test/cucumber.conf.js", 73 | noInject: true 74 | } 75 | } 76 | }, 77 | copy: { 78 | 'instrument': { 79 | files: [{ 80 | src: ['resources/app/**/*', '!resources/app/**/*.js'], 81 | dest: 'instrumented/' 82 | }] 83 | }, 84 | }, 85 | instrument: { 86 | files: 'resources/app/**/*.js', 87 | options: { 88 | lazy: true, 89 | basePath: "instrumented" 90 | } 91 | }, 92 | makeReport: { 93 | src: 'coverage/**/*.json', 94 | options: { 95 | type: 'lcov', 96 | dir: 'reports', 97 | print: 'detail' 98 | } 99 | }, 100 | 101 | // Unit tests. 102 | nodeunit: { 103 | tests: ['test/*_test.js'], 104 | }, 105 | coveralls: { 106 | main:{ 107 | src: 'reports/**/*.info', 108 | options: { 109 | force: true 110 | }, 111 | }, 112 | }, 113 | 114 | }); 115 | 116 | // Actually load this plugin's task(s). 117 | grunt.loadTasks('tasks'); 118 | 119 | // These plugins provide necessary tasks. 120 | grunt.loadNpmTasks('grunt-contrib-jshint'); 121 | grunt.loadNpmTasks('grunt-contrib-clean'); 122 | grunt.loadNpmTasks('grunt-contrib-nodeunit'); 123 | grunt.loadNpmTasks('grunt-contrib-copy'); 124 | grunt.loadNpmTasks('grunt-contrib-connect'); 125 | grunt.loadNpmTasks('grunt-istanbul'); 126 | grunt.loadNpmTasks('grunt-coveralls'); 127 | grunt.loadNpmTasks('grunt-selenium-webdriver'); 128 | 129 | // Whenever the "test" task is run, first clean the "tmp" dir, then run this 130 | // plugin's task(s), then test the result. 131 | grunt.registerTask('test', ['clean', 'copy', 'instrument', 'connect:server', 'selenium_start', 'protractor_coverage:local', 'selenium_stop', 'makeReport', 'coveralls']); 132 | grunt.registerTask('test-remote', ['clean', 'copy', 'instrument', 'connect:server', 'protractor_coverage:remote', 'makeReport', 'coveralls']); 133 | grunt.registerTask('test-cucumber', ['clean', 'copy', 'instrument', 'connect:server', 'selenium_start', 'protractor_coverage:cucumber', 'selenium_stop', 'makeReport', 'coveralls']); 134 | 135 | // By default, lint and run all tests. 136 | grunt.registerTask('default', ['jshint', 'test']); 137 | 138 | }; 139 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # grunt-protractor-coverage 2 | [![Build Status](https://travis-ci.org/r3b/grunt-protractor-coverage.svg?branch=master)](https://travis-ci.org/r3b/grunt-protractor-coverage) 3 | [![Coverage Status](https://coveralls.io/repos/r3b/grunt-protractor-coverage/badge.png)](https://coveralls.io/r/r3b/grunt-protractor-coverage) 4 | 5 | > Instrument your code and gather coverage data from Protractor E2E tests 6 | 7 | ## Getting Started 8 | This plugin requires Grunt `~0.4.4` 9 | 10 | If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command: 11 | 12 | The underlying code is borrowed heavily from [grunt-protractor-runner](https://github.com/teerapap/grunt-protractor-runner) and most options are still intact. 13 | 14 | ```shell 15 | npm install grunt-protractor-coverage --save-dev 16 | ``` 17 | 18 | Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: 19 | 20 | ```js 21 | grunt.loadNpmTasks('grunt-protractor-coverage'); 22 | ``` 23 | 24 | ## The "protractor_coverage" task 25 | 26 | ### Overview 27 | In your project's Gruntfile, add a section named `protractor_coverage` to the data object passed into `grunt.initConfig()`. 28 | 29 | ```js 30 | grunt.initConfig({ 31 | protractor_coverage: { 32 | options: { 33 | // Task-specific options go here. 34 | }, 35 | your_target: { 36 | // Target-specific file lists and/or options go here. 37 | }, 38 | }, 39 | }) 40 | ``` 41 | 42 | #### Default Options 43 | In this example, the default options are used to do capture coverage of your protractor tests. 44 | 45 | Measuring coverage from protractor tests does not work out of the box. To measure coverage Protractor coverage, all 46 | sources need to be instrumented using istanbul. 47 | 48 | ```js 49 | instrument: { 50 | files: 'src/**/*.js', 51 | options: { 52 | lazy: true, 53 | basePath: "instrumented" 54 | } 55 | } 56 | ``` 57 | 58 | And the server running the code / app should use that instrumented code. 59 | 60 | ```js 61 | connect: { 62 | options: { 63 | port: 9000, 64 | hostname: 'localhost' 65 | }, 66 | runtime: { 67 | options: { 68 | middleware: function (connect) { 69 | return [ 70 | lrSnippet, 71 | mountFolder(connect, 'instrumented'), 72 | mountFolder(connect, '.......') 73 | ]; 74 | } 75 | } 76 | } 77 | } 78 | ``` 79 | 80 | Next to that your test should be run. 81 | 82 | ```js 83 | protractor_coverage: { 84 | options: { 85 | keepAlive: true, 86 | noColor: false, 87 | collectorPort: 3001, 88 | coverageDir: 'path/to/coverage/dir', 89 | args: { 90 | baseUrl: 'http://localhost:9000' 91 | } 92 | }, 93 | local: { 94 | options: { 95 | configFile: 'path/to/protractor-local.conf.js' 96 | } 97 | }, 98 | travis: { 99 | options: { 100 | configFile: 'path/to/protractor-travis.conf.js' 101 | } 102 | } 103 | } 104 | ``` 105 | 106 | After the tests have been run and the coverage has been measured and captured you want to create a report. 107 | 108 | ```js 109 | makeReport: { 110 | src: 'path/to/coverage/dir/*.json', 111 | options: { 112 | type: 'lcov', 113 | dir: 'path/to/coverage/dir', 114 | print: 'detail' 115 | } 116 | } 117 | ``` 118 | 119 | ### Cucumber tests 120 | grunt-protractor-coverage normally injects code used for obtaining coverage information by generating altered versions of spec files, but Cucumber features are written in Gherkin rather than JavaScript so this will fail. You can prevent this from happening using the noInject option: 121 | 122 | ```js 123 | protractor_coverage: { 124 | options: { 125 | keepAlive: true, 126 | noInject: true, 127 | coverageDir: 'path/to/coverage/dir', 128 | args: { 129 | baseUrl: 'http://localhost:9000' 130 | } 131 | }, 132 | local: { 133 | options: { 134 | configFile: 'path/to/protractor-local.conf.js' 135 | } 136 | } 137 | } 138 | ``` 139 | 140 | Once enabled you'll also need to update your step definitions to store coverage data after each scenario runs: 141 | 142 | ```js 143 | var coverage = require('grunt-protractor-coverage/cucumber'); 144 | 145 | module.exports = function () { 146 | // Step definitions go here 147 | 148 | this.After(coverage.getCoverage); 149 | }; 150 | ``` 151 | 152 | ### Glue it all together!! 153 | 154 | ```js 155 | grunt.initConfig({ 156 | connect: { 157 | options: { 158 | port: 9000, 159 | hostname: 'localhost' 160 | }, 161 | runtime: { 162 | options: { 163 | middleware: function (connect) { 164 | return [ 165 | lrSnippet, 166 | mountFolder(connect, 'instrumented'), 167 | mountFolder(connect, '.......') 168 | ]; 169 | } 170 | } 171 | } 172 | }, 173 | instrument: { 174 | files: 'src/**/*.js', 175 | options: { 176 | lazy: true, 177 | basePath: "instrumented" 178 | } 179 | }, 180 | protractor_coverage: { 181 | options: { 182 | keepAlive: true, 183 | noColor: false, 184 | coverageDir: 'path/to/coverage/dir', 185 | args: { 186 | baseUrl: 'http://localhost:9000' 187 | } 188 | }, 189 | local: { 190 | options: { 191 | configFile: 'path/to/protractor-local.conf.js' 192 | } 193 | }, 194 | travis: { 195 | options: { 196 | configFile: 'path/to/protractor-travis.conf.js' 197 | } 198 | } 199 | }, 200 | makeReport: { 201 | src: 'path/to/coverage/dir/*.json', 202 | options: { 203 | type: 'lcov', 204 | dir: 'path/to/coverage/dir', 205 | print: 'detail' 206 | } 207 | } 208 | }); 209 | ``` 210 | 211 | ## Contributing 212 | In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/). 213 | 214 | ## Release History 215 | _(Nothing yet)_ 216 | -------------------------------------------------------------------------------- /cucumber/index.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | var options = { 3 | hostname: 'localhost', 4 | port: 3001, 5 | path: '/data', 6 | method: 'POST', 7 | headers:{ 8 | 'Content-Type':'application/json' 9 | } 10 | }; 11 | 12 | function saveCoverage(data){ 13 | var req = http.request(options, function(res) { 14 | res.on('data', function (chunk) { 15 | }); 16 | }); 17 | req.on('error', function(e) { 18 | console.warn('Could not save coverage: ' + e.message); 19 | }); 20 | req.write(JSON.stringify(data)); 21 | req.write('\n'); 22 | req.end(); 23 | } 24 | 25 | function getCoverage(callback) { 26 | browser.executeScript("return ('__coverage__' in window) ? window.__coverage__ : null;").then(function (coverage) { 27 | if (coverage) { 28 | saveCoverage(coverage); 29 | } 30 | typeof callback === 'function' && callback(); 31 | }); 32 | } 33 | 34 | module.exports = { 35 | options: options, 36 | getCoverage: getCoverage 37 | }; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grunt-protractor-coverage", 3 | "version": "0.2.18", 4 | "description": "Instrument your code and gather coverage data from Protractor E2E tests", 5 | "main": "Gruntfile.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "dependencies": { 10 | "coverage-collector": "0.0.5", 11 | "dargs-object": "~0.2.0", 12 | "escodegen": "~1.8.0", 13 | "esprima": "~2.7.1", 14 | "estraverse": "~4.1.1", 15 | "grunt": "^0.4.5", 16 | "grunt-contrib-connect": "~0.11.2", 17 | "grunt-istanbul": "~0.6.1", 18 | "mkdirp": "~0.5.1", 19 | "temporary": "0.0.8", 20 | "tmp": "0.0.28" 21 | }, 22 | "devDependencies": { 23 | "cucumber": "^0.9.2", 24 | "grunt": "~0.4.5", 25 | "grunt-cli": "~0.1.13", 26 | "grunt-contrib-clean": "~0.4.0a", 27 | "grunt-contrib-copy": "~0.8.2", 28 | "grunt-contrib-jshint": "~0.11.3", 29 | "grunt-contrib-nodeunit": "~0.4.1", 30 | "grunt-coveralls": "~1.0.0", 31 | "grunt-selenium-webdriver": "^0.2.482", 32 | "protractor": "^3.0.0" 33 | }, 34 | "scripts": { 35 | "test": "grunt clean jshint test-remote -v" 36 | }, 37 | "repository": { 38 | "type": "git", 39 | "url": "git://github.com/r3b/grunt-protractor-coverage.git" 40 | }, 41 | "keywords": [ 42 | "gruntplugin", 43 | "protractor", 44 | "coverage", 45 | "testing", 46 | "istanbul" 47 | ], 48 | "author": "ryan bridges", 49 | "license": "Apache-2.0", 50 | "bugs": { 51 | "url": "https://github.com/r3b/grunt-protractor-coverage/issues" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /resources/app/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/r3b/grunt-protractor-coverage/de6857e792cedebb38524e4281ea98fc4b4fe192/resources/app/.DS_Store -------------------------------------------------------------------------------- /resources/app/angularjs/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "todomvc-angular", 3 | "version": "0.0.0", 4 | "dependencies": { 5 | "angular": "1.2.14", 6 | "todomvc-common": "~0.1.4" 7 | }, 8 | "devDependencies": { 9 | "angular-mocks": "1.2.14", 10 | "angular-route": "1.2.14" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /resources/app/angularjs/bower_components/angular-route/angular-route.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license AngularJS v1.2.14 3 | * (c) 2010-2014 Google, Inc. http://angularjs.org 4 | * License: MIT 5 | */ 6 | (function(window, angular, undefined) {'use strict'; 7 | 8 | /** 9 | * @ngdoc module 10 | * @name ngRoute 11 | * @description 12 | * 13 | * # ngRoute 14 | * 15 | * The `ngRoute` module provides routing and deeplinking services and directives for angular apps. 16 | * 17 | * ## Example 18 | * See {@link ngRoute.$route#example $route} for an example of configuring and using `ngRoute`. 19 | * 20 | * 21 | *
22 | */ 23 | /* global -ngRouteModule */ 24 | var ngRouteModule = angular.module('ngRoute', ['ng']). 25 | provider('$route', $RouteProvider); 26 | 27 | /** 28 | * @ngdoc provider 29 | * @name $routeProvider 30 | * @function 31 | * 32 | * @description 33 | * 34 | * Used for configuring routes. 35 | * 36 | * ## Example 37 | * See {@link ngRoute.$route#example $route} for an example of configuring and using `ngRoute`. 38 | * 39 | * ## Dependencies 40 | * Requires the {@link ngRoute `ngRoute`} module to be installed. 41 | */ 42 | function $RouteProvider(){ 43 | function inherit(parent, extra) { 44 | return angular.extend(new (angular.extend(function() {}, {prototype:parent}))(), extra); 45 | } 46 | 47 | var routes = {}; 48 | 49 | /** 50 | * @ngdoc method 51 | * @name $routeProvider#when 52 | * 53 | * @param {string} path Route path (matched against `$location.path`). If `$location.path` 54 | * contains redundant trailing slash or is missing one, the route will still match and the 55 | * `$location.path` will be updated to add or drop the trailing slash to exactly match the 56 | * route definition. 57 | * 58 | * * `path` can contain named groups starting with a colon: e.g. `:name`. All characters up 59 | * to the next slash are matched and stored in `$routeParams` under the given `name` 60 | * when the route matches. 61 | * * `path` can contain named groups starting with a colon and ending with a star: 62 | * e.g.`:name*`. All characters are eagerly stored in `$routeParams` under the given `name` 63 | * when the route matches. 64 | * * `path` can contain optional named groups with a question mark: e.g.`:name?`. 65 | * 66 | * For example, routes like `/color/:color/largecode/:largecode*\/edit` will match 67 | * `/color/brown/largecode/code/with/slashes/edit` and extract: 68 | * 69 | * * `color: brown` 70 | * * `largecode: code/with/slashes`. 71 | * 72 | * 73 | * @param {Object} route Mapping information to be assigned to `$route.current` on route 74 | * match. 75 | * 76 | * Object properties: 77 | * 78 | * - `controller` – `{(string|function()=}` – Controller fn that should be associated with 79 | * newly created scope or the name of a {@link angular.Module#controller registered 80 | * controller} if passed as a string. 81 | * - `controllerAs` – `{string=}` – A controller alias name. If present the controller will be 82 | * published to scope under the `controllerAs` name. 83 | * - `template` – `{string=|function()=}` – html template as a string or a function that 84 | * returns an html template as a string which should be used by {@link 85 | * ngRoute.directive:ngView ngView} or {@link ng.directive:ngInclude ngInclude} directives. 86 | * This property takes precedence over `templateUrl`. 87 | * 88 | * If `template` is a function, it will be called with the following parameters: 89 | * 90 | * - `{Array.<Object>}` - route parameters extracted from the current 91 | * `$location.path()` by applying the current route 92 | * 93 | * - `templateUrl` – `{string=|function()=}` – path or function that returns a path to an html 94 | * template that should be used by {@link ngRoute.directive:ngView ngView}. 95 | * 96 | * If `templateUrl` is a function, it will be called with the following parameters: 97 | * 98 | * - `{Array.<Object>}` - route parameters extracted from the current 99 | * `$location.path()` by applying the current route 100 | * 101 | * - `resolve` - `{Object.=}` - An optional map of dependencies which should 102 | * be injected into the controller. If any of these dependencies are promises, the router 103 | * will wait for them all to be resolved or one to be rejected before the controller is 104 | * instantiated. 105 | * If all the promises are resolved successfully, the values of the resolved promises are 106 | * injected and {@link ngRoute.$route#$routeChangeSuccess $routeChangeSuccess} event is 107 | * fired. If any of the promises are rejected the 108 | * {@link ngRoute.$route#$routeChangeError $routeChangeError} event is fired. The map object 109 | * is: 110 | * 111 | * - `key` – `{string}`: a name of a dependency to be injected into the controller. 112 | * - `factory` - `{string|function}`: If `string` then it is an alias for a service. 113 | * Otherwise if function, then it is {@link auto.$injector#invoke injected} 114 | * and the return value is treated as the dependency. If the result is a promise, it is 115 | * resolved before its value is injected into the controller. Be aware that 116 | * `ngRoute.$routeParams` will still refer to the previous route within these resolve 117 | * functions. Use `$route.current.params` to access the new route parameters, instead. 118 | * 119 | * - `redirectTo` – {(string|function())=} – value to update 120 | * {@link ng.$location $location} path with and trigger route redirection. 121 | * 122 | * If `redirectTo` is a function, it will be called with the following parameters: 123 | * 124 | * - `{Object.}` - route parameters extracted from the current 125 | * `$location.path()` by applying the current route templateUrl. 126 | * - `{string}` - current `$location.path()` 127 | * - `{Object}` - current `$location.search()` 128 | * 129 | * The custom `redirectTo` function is expected to return a string which will be used 130 | * to update `$location.path()` and `$location.search()`. 131 | * 132 | * - `[reloadOnSearch=true]` - {boolean=} - reload route when only `$location.search()` 133 | * or `$location.hash()` changes. 134 | * 135 | * If the option is set to `false` and url in the browser changes, then 136 | * `$routeUpdate` event is broadcasted on the root scope. 137 | * 138 | * - `[caseInsensitiveMatch=false]` - {boolean=} - match routes without being case sensitive 139 | * 140 | * If the option is set to `true`, then the particular route can be matched without being 141 | * case sensitive 142 | * 143 | * @returns {Object} self 144 | * 145 | * @description 146 | * Adds a new route definition to the `$route` service. 147 | */ 148 | this.when = function(path, route) { 149 | routes[path] = angular.extend( 150 | {reloadOnSearch: true}, 151 | route, 152 | path && pathRegExp(path, route) 153 | ); 154 | 155 | // create redirection for trailing slashes 156 | if (path) { 157 | var redirectPath = (path[path.length-1] == '/') 158 | ? path.substr(0, path.length-1) 159 | : path +'/'; 160 | 161 | routes[redirectPath] = angular.extend( 162 | {redirectTo: path}, 163 | pathRegExp(redirectPath, route) 164 | ); 165 | } 166 | 167 | return this; 168 | }; 169 | 170 | /** 171 | * @param path {string} path 172 | * @param opts {Object} options 173 | * @return {?Object} 174 | * 175 | * @description 176 | * Normalizes the given path, returning a regular expression 177 | * and the original path. 178 | * 179 | * Inspired by pathRexp in visionmedia/express/lib/utils.js. 180 | */ 181 | function pathRegExp(path, opts) { 182 | var insensitive = opts.caseInsensitiveMatch, 183 | ret = { 184 | originalPath: path, 185 | regexp: path 186 | }, 187 | keys = ret.keys = []; 188 | 189 | path = path 190 | .replace(/([().])/g, '\\$1') 191 | .replace(/(\/)?:(\w+)([\?\*])?/g, function(_, slash, key, option){ 192 | var optional = option === '?' ? option : null; 193 | var star = option === '*' ? option : null; 194 | keys.push({ name: key, optional: !!optional }); 195 | slash = slash || ''; 196 | return '' 197 | + (optional ? '' : slash) 198 | + '(?:' 199 | + (optional ? slash : '') 200 | + (star && '(.+?)' || '([^/]+)') 201 | + (optional || '') 202 | + ')' 203 | + (optional || ''); 204 | }) 205 | .replace(/([\/$\*])/g, '\\$1'); 206 | 207 | ret.regexp = new RegExp('^' + path + '$', insensitive ? 'i' : ''); 208 | return ret; 209 | } 210 | 211 | /** 212 | * @ngdoc method 213 | * @name $routeProvider#otherwise 214 | * 215 | * @description 216 | * Sets route definition that will be used on route change when no other route definition 217 | * is matched. 218 | * 219 | * @param {Object} params Mapping information to be assigned to `$route.current`. 220 | * @returns {Object} self 221 | */ 222 | this.otherwise = function(params) { 223 | this.when(null, params); 224 | return this; 225 | }; 226 | 227 | 228 | this.$get = ['$rootScope', 229 | '$location', 230 | '$routeParams', 231 | '$q', 232 | '$injector', 233 | '$http', 234 | '$templateCache', 235 | '$sce', 236 | function($rootScope, $location, $routeParams, $q, $injector, $http, $templateCache, $sce) { 237 | 238 | /** 239 | * @ngdoc service 240 | * @name $route 241 | * @requires $location 242 | * @requires $routeParams 243 | * 244 | * @property {Object} current Reference to the current route definition. 245 | * The route definition contains: 246 | * 247 | * - `controller`: The controller constructor as define in route definition. 248 | * - `locals`: A map of locals which is used by {@link ng.$controller $controller} service for 249 | * controller instantiation. The `locals` contain 250 | * the resolved values of the `resolve` map. Additionally the `locals` also contain: 251 | * 252 | * - `$scope` - The current route scope. 253 | * - `$template` - The current route template HTML. 254 | * 255 | * @property {Array.<Object>} routes Array of all configured routes. 256 | * 257 | * @description 258 | * `$route` is used for deep-linking URLs to controllers and views (HTML partials). 259 | * It watches `$location.url()` and tries to map the path to an existing route definition. 260 | * 261 | * Requires the {@link ngRoute `ngRoute`} module to be installed. 262 | * 263 | * You can define routes through {@link ngRoute.$routeProvider $routeProvider}'s API. 264 | * 265 | * The `$route` service is typically used in conjunction with the 266 | * {@link ngRoute.directive:ngView `ngView`} directive and the 267 | * {@link ngRoute.$routeParams `$routeParams`} service. 268 | * 269 | * @example 270 | This example shows how changing the URL hash causes the `$route` to match a route against the 271 | URL, and the `ngView` pulls in the partial. 272 | 273 | Note that this example is using {@link ng.directive:script inlined templates} 274 | to get it working on jsfiddle as well. 275 | 276 | 277 | 278 |
279 | Choose: 280 | Moby | 281 | Moby: Ch1 | 282 | Gatsby | 283 | Gatsby: Ch4 | 284 | Scarlet Letter
285 | 286 |
287 |
288 | 289 |
$location.path() = {{$location.path()}}
290 |
$route.current.templateUrl = {{$route.current.templateUrl}}
291 |
$route.current.params = {{$route.current.params}}
292 |
$route.current.scope.name = {{$route.current.scope.name}}
293 |
$routeParams = {{$routeParams}}
294 |
295 |
296 | 297 | 298 | controller: {{name}}
299 | Book Id: {{params.bookId}}
300 |
301 | 302 | 303 | controller: {{name}}
304 | Book Id: {{params.bookId}}
305 | Chapter Id: {{params.chapterId}} 306 |
307 | 308 | 309 | angular.module('ngRouteExample', ['ngRoute']) 310 | 311 | .config(function($routeProvider, $locationProvider) { 312 | $routeProvider.when('/Book/:bookId', { 313 | templateUrl: 'book.html', 314 | controller: BookCntl, 315 | resolve: { 316 | // I will cause a 1 second delay 317 | delay: function($q, $timeout) { 318 | var delay = $q.defer(); 319 | $timeout(delay.resolve, 1000); 320 | return delay.promise; 321 | } 322 | } 323 | }); 324 | $routeProvider.when('/Book/:bookId/ch/:chapterId', { 325 | templateUrl: 'chapter.html', 326 | controller: ChapterCntl 327 | }); 328 | 329 | // configure html5 to get links working on jsfiddle 330 | $locationProvider.html5Mode(true); 331 | }); 332 | 333 | function MainCntl($scope, $route, $routeParams, $location) { 334 | $scope.$route = $route; 335 | $scope.$location = $location; 336 | $scope.$routeParams = $routeParams; 337 | } 338 | 339 | function BookCntl($scope, $routeParams) { 340 | $scope.name = "BookCntl"; 341 | $scope.params = $routeParams; 342 | } 343 | 344 | function ChapterCntl($scope, $routeParams) { 345 | $scope.name = "ChapterCntl"; 346 | $scope.params = $routeParams; 347 | } 348 | 349 | 350 | 351 | it('should load and compile correct template', function() { 352 | element(by.linkText('Moby: Ch1')).click(); 353 | var content = element(by.css('[ng-view]')).getText(); 354 | expect(content).toMatch(/controller\: ChapterCntl/); 355 | expect(content).toMatch(/Book Id\: Moby/); 356 | expect(content).toMatch(/Chapter Id\: 1/); 357 | 358 | element(by.partialLinkText('Scarlet')).click(); 359 | 360 | content = element(by.css('[ng-view]')).getText(); 361 | expect(content).toMatch(/controller\: BookCntl/); 362 | expect(content).toMatch(/Book Id\: Scarlet/); 363 | }); 364 | 365 |
366 | */ 367 | 368 | /** 369 | * @ngdoc event 370 | * @name $route#$routeChangeStart 371 | * @eventType broadcast on root scope 372 | * @description 373 | * Broadcasted before a route change. At this point the route services starts 374 | * resolving all of the dependencies needed for the route change to occur. 375 | * Typically this involves fetching the view template as well as any dependencies 376 | * defined in `resolve` route property. Once all of the dependencies are resolved 377 | * `$routeChangeSuccess` is fired. 378 | * 379 | * @param {Object} angularEvent Synthetic event object. 380 | * @param {Route} next Future route information. 381 | * @param {Route} current Current route information. 382 | */ 383 | 384 | /** 385 | * @ngdoc event 386 | * @name $route#$routeChangeSuccess 387 | * @eventType broadcast on root scope 388 | * @description 389 | * Broadcasted after a route dependencies are resolved. 390 | * {@link ngRoute.directive:ngView ngView} listens for the directive 391 | * to instantiate the controller and render the view. 392 | * 393 | * @param {Object} angularEvent Synthetic event object. 394 | * @param {Route} current Current route information. 395 | * @param {Route|Undefined} previous Previous route information, or undefined if current is 396 | * first route entered. 397 | */ 398 | 399 | /** 400 | * @ngdoc event 401 | * @name $route#$routeChangeError 402 | * @eventType broadcast on root scope 403 | * @description 404 | * Broadcasted if any of the resolve promises are rejected. 405 | * 406 | * @param {Object} angularEvent Synthetic event object 407 | * @param {Route} current Current route information. 408 | * @param {Route} previous Previous route information. 409 | * @param {Route} rejection Rejection of the promise. Usually the error of the failed promise. 410 | */ 411 | 412 | /** 413 | * @ngdoc event 414 | * @name $route#$routeUpdate 415 | * @eventType broadcast on root scope 416 | * @description 417 | * 418 | * The `reloadOnSearch` property has been set to false, and we are reusing the same 419 | * instance of the Controller. 420 | */ 421 | 422 | var forceReload = false, 423 | $route = { 424 | routes: routes, 425 | 426 | /** 427 | * @ngdoc method 428 | * @name $route#reload 429 | * 430 | * @description 431 | * Causes `$route` service to reload the current route even if 432 | * {@link ng.$location $location} hasn't changed. 433 | * 434 | * As a result of that, {@link ngRoute.directive:ngView ngView} 435 | * creates new scope, reinstantiates the controller. 436 | */ 437 | reload: function() { 438 | forceReload = true; 439 | $rootScope.$evalAsync(updateRoute); 440 | } 441 | }; 442 | 443 | $rootScope.$on('$locationChangeSuccess', updateRoute); 444 | 445 | return $route; 446 | 447 | ///////////////////////////////////////////////////// 448 | 449 | /** 450 | * @param on {string} current url 451 | * @param route {Object} route regexp to match the url against 452 | * @return {?Object} 453 | * 454 | * @description 455 | * Check if the route matches the current url. 456 | * 457 | * Inspired by match in 458 | * visionmedia/express/lib/router/router.js. 459 | */ 460 | function switchRouteMatcher(on, route) { 461 | var keys = route.keys, 462 | params = {}; 463 | 464 | if (!route.regexp) return null; 465 | 466 | var m = route.regexp.exec(on); 467 | if (!m) return null; 468 | 469 | for (var i = 1, len = m.length; i < len; ++i) { 470 | var key = keys[i - 1]; 471 | 472 | var val = 'string' == typeof m[i] 473 | ? decodeURIComponent(m[i]) 474 | : m[i]; 475 | 476 | if (key && val) { 477 | params[key.name] = val; 478 | } 479 | } 480 | return params; 481 | } 482 | 483 | function updateRoute() { 484 | var next = parseRoute(), 485 | last = $route.current; 486 | 487 | if (next && last && next.$$route === last.$$route 488 | && angular.equals(next.pathParams, last.pathParams) 489 | && !next.reloadOnSearch && !forceReload) { 490 | last.params = next.params; 491 | angular.copy(last.params, $routeParams); 492 | $rootScope.$broadcast('$routeUpdate', last); 493 | } else if (next || last) { 494 | forceReload = false; 495 | $rootScope.$broadcast('$routeChangeStart', next, last); 496 | $route.current = next; 497 | if (next) { 498 | if (next.redirectTo) { 499 | if (angular.isString(next.redirectTo)) { 500 | $location.path(interpolate(next.redirectTo, next.params)).search(next.params) 501 | .replace(); 502 | } else { 503 | $location.url(next.redirectTo(next.pathParams, $location.path(), $location.search())) 504 | .replace(); 505 | } 506 | } 507 | } 508 | 509 | $q.when(next). 510 | then(function() { 511 | if (next) { 512 | var locals = angular.extend({}, next.resolve), 513 | template, templateUrl; 514 | 515 | angular.forEach(locals, function(value, key) { 516 | locals[key] = angular.isString(value) ? 517 | $injector.get(value) : $injector.invoke(value); 518 | }); 519 | 520 | if (angular.isDefined(template = next.template)) { 521 | if (angular.isFunction(template)) { 522 | template = template(next.params); 523 | } 524 | } else if (angular.isDefined(templateUrl = next.templateUrl)) { 525 | if (angular.isFunction(templateUrl)) { 526 | templateUrl = templateUrl(next.params); 527 | } 528 | templateUrl = $sce.getTrustedResourceUrl(templateUrl); 529 | if (angular.isDefined(templateUrl)) { 530 | next.loadedTemplateUrl = templateUrl; 531 | template = $http.get(templateUrl, {cache: $templateCache}). 532 | then(function(response) { return response.data; }); 533 | } 534 | } 535 | if (angular.isDefined(template)) { 536 | locals['$template'] = template; 537 | } 538 | return $q.all(locals); 539 | } 540 | }). 541 | // after route change 542 | then(function(locals) { 543 | if (next == $route.current) { 544 | if (next) { 545 | next.locals = locals; 546 | angular.copy(next.params, $routeParams); 547 | } 548 | $rootScope.$broadcast('$routeChangeSuccess', next, last); 549 | } 550 | }, function(error) { 551 | if (next == $route.current) { 552 | $rootScope.$broadcast('$routeChangeError', next, last, error); 553 | } 554 | }); 555 | } 556 | } 557 | 558 | 559 | /** 560 | * @returns {Object} the current active route, by matching it against the URL 561 | */ 562 | function parseRoute() { 563 | // Match a route 564 | var params, match; 565 | angular.forEach(routes, function(route, path) { 566 | if (!match && (params = switchRouteMatcher($location.path(), route))) { 567 | match = inherit(route, { 568 | params: angular.extend({}, $location.search(), params), 569 | pathParams: params}); 570 | match.$$route = route; 571 | } 572 | }); 573 | // No route matched; fallback to "otherwise" route 574 | return match || routes[null] && inherit(routes[null], {params: {}, pathParams:{}}); 575 | } 576 | 577 | /** 578 | * @returns {string} interpolation of the redirect path with the parameters 579 | */ 580 | function interpolate(string, params) { 581 | var result = []; 582 | angular.forEach((string||'').split(':'), function(segment, i) { 583 | if (i === 0) { 584 | result.push(segment); 585 | } else { 586 | var segmentMatch = segment.match(/(\w+)(.*)/); 587 | var key = segmentMatch[1]; 588 | result.push(params[key]); 589 | result.push(segmentMatch[2] || ''); 590 | delete params[key]; 591 | } 592 | }); 593 | return result.join(''); 594 | } 595 | }]; 596 | } 597 | 598 | ngRouteModule.provider('$routeParams', $RouteParamsProvider); 599 | 600 | 601 | /** 602 | * @ngdoc service 603 | * @name $routeParams 604 | * @requires $route 605 | * 606 | * @description 607 | * The `$routeParams` service allows you to retrieve the current set of route parameters. 608 | * 609 | * Requires the {@link ngRoute `ngRoute`} module to be installed. 610 | * 611 | * The route parameters are a combination of {@link ng.$location `$location`}'s 612 | * {@link ng.$location#search `search()`} and {@link ng.$location#path `path()`}. 613 | * The `path` parameters are extracted when the {@link ngRoute.$route `$route`} path is matched. 614 | * 615 | * In case of parameter name collision, `path` params take precedence over `search` params. 616 | * 617 | * The service guarantees that the identity of the `$routeParams` object will remain unchanged 618 | * (but its properties will likely change) even when a route change occurs. 619 | * 620 | * Note that the `$routeParams` are only updated *after* a route change completes successfully. 621 | * This means that you cannot rely on `$routeParams` being correct in route resolve functions. 622 | * Instead you can use `$route.current.params` to access the new route's parameters. 623 | * 624 | * @example 625 | * ```js 626 | * // Given: 627 | * // URL: http://server.com/index.html#/Chapter/1/Section/2?search=moby 628 | * // Route: /Chapter/:chapterId/Section/:sectionId 629 | * // 630 | * // Then 631 | * $routeParams ==> {chapterId:1, sectionId:2, search:'moby'} 632 | * ``` 633 | */ 634 | function $RouteParamsProvider() { 635 | this.$get = function() { return {}; }; 636 | } 637 | 638 | ngRouteModule.directive('ngView', ngViewFactory); 639 | ngRouteModule.directive('ngView', ngViewFillContentFactory); 640 | 641 | 642 | /** 643 | * @ngdoc directive 644 | * @name ngView 645 | * @restrict ECA 646 | * 647 | * @description 648 | * # Overview 649 | * `ngView` is a directive that complements the {@link ngRoute.$route $route} service by 650 | * including the rendered template of the current route into the main layout (`index.html`) file. 651 | * Every time the current route changes, the included view changes with it according to the 652 | * configuration of the `$route` service. 653 | * 654 | * Requires the {@link ngRoute `ngRoute`} module to be installed. 655 | * 656 | * @animations 657 | * enter - animation is used to bring new content into the browser. 658 | * leave - animation is used to animate existing content away. 659 | * 660 | * The enter and leave animation occur concurrently. 661 | * 662 | * @scope 663 | * @priority 400 664 | * @param {string=} onload Expression to evaluate whenever the view updates. 665 | * 666 | * @param {string=} autoscroll Whether `ngView` should call {@link ng.$anchorScroll 667 | * $anchorScroll} to scroll the viewport after the view is updated. 668 | * 669 | * - If the attribute is not set, disable scrolling. 670 | * - If the attribute is set without value, enable scrolling. 671 | * - Otherwise enable scrolling only if the `autoscroll` attribute value evaluated 672 | * as an expression yields a truthy value. 673 | * @example 674 | 677 | 678 |
679 | Choose: 680 | Moby | 681 | Moby: Ch1 | 682 | Gatsby | 683 | Gatsby: Ch4 | 684 | Scarlet Letter
685 | 686 |
687 |
688 |
689 |
690 | 691 |
$location.path() = {{main.$location.path()}}
692 |
$route.current.templateUrl = {{main.$route.current.templateUrl}}
693 |
$route.current.params = {{main.$route.current.params}}
694 |
$route.current.scope.name = {{main.$route.current.scope.name}}
695 |
$routeParams = {{main.$routeParams}}
696 |
697 |
698 | 699 | 700 |
701 | controller: {{book.name}}
702 | Book Id: {{book.params.bookId}}
703 |
704 |
705 | 706 | 707 |
708 | controller: {{chapter.name}}
709 | Book Id: {{chapter.params.bookId}}
710 | Chapter Id: {{chapter.params.chapterId}} 711 |
712 |
713 | 714 | 715 | .view-animate-container { 716 | position:relative; 717 | height:100px!important; 718 | position:relative; 719 | background:white; 720 | border:1px solid black; 721 | height:40px; 722 | overflow:hidden; 723 | } 724 | 725 | .view-animate { 726 | padding:10px; 727 | } 728 | 729 | .view-animate.ng-enter, .view-animate.ng-leave { 730 | -webkit-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 1.5s; 731 | transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 1.5s; 732 | 733 | display:block; 734 | width:100%; 735 | border-left:1px solid black; 736 | 737 | position:absolute; 738 | top:0; 739 | left:0; 740 | right:0; 741 | bottom:0; 742 | padding:10px; 743 | } 744 | 745 | .view-animate.ng-enter { 746 | left:100%; 747 | } 748 | .view-animate.ng-enter.ng-enter-active { 749 | left:0; 750 | } 751 | .view-animate.ng-leave.ng-leave-active { 752 | left:-100%; 753 | } 754 | 755 | 756 | 757 | angular.module('ngViewExample', ['ngRoute', 'ngAnimate'], 758 | function($routeProvider, $locationProvider) { 759 | $routeProvider.when('/Book/:bookId', { 760 | templateUrl: 'book.html', 761 | controller: BookCntl, 762 | controllerAs: 'book' 763 | }); 764 | $routeProvider.when('/Book/:bookId/ch/:chapterId', { 765 | templateUrl: 'chapter.html', 766 | controller: ChapterCntl, 767 | controllerAs: 'chapter' 768 | }); 769 | 770 | // configure html5 to get links working on jsfiddle 771 | $locationProvider.html5Mode(true); 772 | }); 773 | 774 | function MainCntl($route, $routeParams, $location) { 775 | this.$route = $route; 776 | this.$location = $location; 777 | this.$routeParams = $routeParams; 778 | } 779 | 780 | function BookCntl($routeParams) { 781 | this.name = "BookCntl"; 782 | this.params = $routeParams; 783 | } 784 | 785 | function ChapterCntl($routeParams) { 786 | this.name = "ChapterCntl"; 787 | this.params = $routeParams; 788 | } 789 | 790 | 791 | 792 | it('should load and compile correct template', function() { 793 | element(by.linkText('Moby: Ch1')).click(); 794 | var content = element(by.css('[ng-view]')).getText(); 795 | expect(content).toMatch(/controller\: ChapterCntl/); 796 | expect(content).toMatch(/Book Id\: Moby/); 797 | expect(content).toMatch(/Chapter Id\: 1/); 798 | 799 | element(by.partialLinkText('Scarlet')).click(); 800 | 801 | content = element(by.css('[ng-view]')).getText(); 802 | expect(content).toMatch(/controller\: BookCntl/); 803 | expect(content).toMatch(/Book Id\: Scarlet/); 804 | }); 805 | 806 |
807 | */ 808 | 809 | 810 | /** 811 | * @ngdoc event 812 | * @name ngView#$viewContentLoaded 813 | * @eventType emit on the current ngView scope 814 | * @description 815 | * Emitted every time the ngView content is reloaded. 816 | */ 817 | ngViewFactory.$inject = ['$route', '$anchorScroll', '$animate']; 818 | function ngViewFactory( $route, $anchorScroll, $animate) { 819 | return { 820 | restrict: 'ECA', 821 | terminal: true, 822 | priority: 400, 823 | transclude: 'element', 824 | link: function(scope, $element, attr, ctrl, $transclude) { 825 | var currentScope, 826 | currentElement, 827 | previousElement, 828 | autoScrollExp = attr.autoscroll, 829 | onloadExp = attr.onload || ''; 830 | 831 | scope.$on('$routeChangeSuccess', update); 832 | update(); 833 | 834 | function cleanupLastView() { 835 | if(previousElement) { 836 | previousElement.remove(); 837 | previousElement = null; 838 | } 839 | if(currentScope) { 840 | currentScope.$destroy(); 841 | currentScope = null; 842 | } 843 | if(currentElement) { 844 | $animate.leave(currentElement, function() { 845 | previousElement = null; 846 | }); 847 | previousElement = currentElement; 848 | currentElement = null; 849 | } 850 | } 851 | 852 | function update() { 853 | var locals = $route.current && $route.current.locals, 854 | template = locals && locals.$template; 855 | 856 | if (angular.isDefined(template)) { 857 | var newScope = scope.$new(); 858 | var current = $route.current; 859 | 860 | // Note: This will also link all children of ng-view that were contained in the original 861 | // html. If that content contains controllers, ... they could pollute/change the scope. 862 | // However, using ng-view on an element with additional content does not make sense... 863 | // Note: We can't remove them in the cloneAttchFn of $transclude as that 864 | // function is called before linking the content, which would apply child 865 | // directives to non existing elements. 866 | var clone = $transclude(newScope, function(clone) { 867 | $animate.enter(clone, null, currentElement || $element, function onNgViewEnter () { 868 | if (angular.isDefined(autoScrollExp) 869 | && (!autoScrollExp || scope.$eval(autoScrollExp))) { 870 | $anchorScroll(); 871 | } 872 | }); 873 | cleanupLastView(); 874 | }); 875 | 876 | currentElement = clone; 877 | currentScope = current.scope = newScope; 878 | currentScope.$emit('$viewContentLoaded'); 879 | currentScope.$eval(onloadExp); 880 | } else { 881 | cleanupLastView(); 882 | } 883 | } 884 | } 885 | }; 886 | } 887 | 888 | // This directive is called during the $transclude call of the first `ngView` directive. 889 | // It will replace and compile the content of the element with the loaded template. 890 | // We need this directive so that the element content is already filled when 891 | // the link function of another directive on the same element as ngView 892 | // is called. 893 | ngViewFillContentFactory.$inject = ['$compile', '$controller', '$route']; 894 | function ngViewFillContentFactory($compile, $controller, $route) { 895 | return { 896 | restrict: 'ECA', 897 | priority: -400, 898 | link: function(scope, $element) { 899 | var current = $route.current, 900 | locals = current.locals; 901 | 902 | $element.html(locals.$template); 903 | 904 | var link = $compile($element.contents()); 905 | 906 | if (current.controller) { 907 | locals.$scope = scope; 908 | var controller = $controller(current.controller, locals); 909 | if (current.controllerAs) { 910 | scope[current.controllerAs] = controller; 911 | } 912 | $element.data('$ngControllerController', controller); 913 | $element.children().data('$ngControllerController', controller); 914 | } 915 | 916 | link(scope); 917 | } 918 | }; 919 | } 920 | 921 | 922 | })(window, window.angular); 923 | -------------------------------------------------------------------------------- /resources/app/angularjs/bower_components/todomvc-common/base.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | margin: 0; 4 | padding: 0; 5 | } 6 | 7 | button { 8 | margin: 0; 9 | padding: 0; 10 | border: 0; 11 | background: none; 12 | font-size: 100%; 13 | vertical-align: baseline; 14 | font-family: inherit; 15 | color: inherit; 16 | -webkit-appearance: none; 17 | -ms-appearance: none; 18 | -o-appearance: none; 19 | appearance: none; 20 | } 21 | 22 | body { 23 | font: 14px 'Helvetica Neue', Helvetica, Arial, sans-serif; 24 | line-height: 1.4em; 25 | background: #eaeaea url('bg.png'); 26 | color: #4d4d4d; 27 | width: 550px; 28 | margin: 0 auto; 29 | -webkit-font-smoothing: antialiased; 30 | -moz-font-smoothing: antialiased; 31 | -ms-font-smoothing: antialiased; 32 | -o-font-smoothing: antialiased; 33 | font-smoothing: antialiased; 34 | } 35 | 36 | button, 37 | input[type="checkbox"] { 38 | outline: none; 39 | } 40 | 41 | #todoapp { 42 | background: #fff; 43 | background: rgba(255, 255, 255, 0.9); 44 | margin: 130px 0 40px 0; 45 | border: 1px solid #ccc; 46 | position: relative; 47 | border-top-left-radius: 2px; 48 | border-top-right-radius: 2px; 49 | box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.2), 50 | 0 25px 50px 0 rgba(0, 0, 0, 0.15); 51 | } 52 | 53 | #todoapp:before { 54 | content: ''; 55 | border-left: 1px solid #f5d6d6; 56 | border-right: 1px solid #f5d6d6; 57 | width: 2px; 58 | position: absolute; 59 | top: 0; 60 | left: 40px; 61 | height: 100%; 62 | } 63 | 64 | #todoapp input::-webkit-input-placeholder { 65 | font-style: italic; 66 | } 67 | 68 | #todoapp input::-moz-placeholder { 69 | font-style: italic; 70 | color: #a9a9a9; 71 | } 72 | 73 | #todoapp h1 { 74 | position: absolute; 75 | top: -120px; 76 | width: 100%; 77 | font-size: 70px; 78 | font-weight: bold; 79 | text-align: center; 80 | color: #b3b3b3; 81 | color: rgba(255, 255, 255, 0.3); 82 | text-shadow: -1px -1px rgba(0, 0, 0, 0.2); 83 | -webkit-text-rendering: optimizeLegibility; 84 | -moz-text-rendering: optimizeLegibility; 85 | -ms-text-rendering: optimizeLegibility; 86 | -o-text-rendering: optimizeLegibility; 87 | text-rendering: optimizeLegibility; 88 | } 89 | 90 | #header { 91 | padding-top: 15px; 92 | border-radius: inherit; 93 | } 94 | 95 | #header:before { 96 | content: ''; 97 | position: absolute; 98 | top: 0; 99 | right: 0; 100 | left: 0; 101 | height: 15px; 102 | z-index: 2; 103 | border-bottom: 1px solid #6c615c; 104 | background: #8d7d77; 105 | background: -webkit-gradient(linear, left top, left bottom, from(rgba(132, 110, 100, 0.8)),to(rgba(101, 84, 76, 0.8))); 106 | background: -webkit-linear-gradient(top, rgba(132, 110, 100, 0.8), rgba(101, 84, 76, 0.8)); 107 | background: linear-gradient(top, rgba(132, 110, 100, 0.8), rgba(101, 84, 76, 0.8)); 108 | filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr='#9d8b83', EndColorStr='#847670'); 109 | border-top-left-radius: 1px; 110 | border-top-right-radius: 1px; 111 | } 112 | 113 | #new-todo, 114 | .edit { 115 | position: relative; 116 | margin: 0; 117 | width: 100%; 118 | font-size: 24px; 119 | font-family: inherit; 120 | line-height: 1.4em; 121 | border: 0; 122 | outline: none; 123 | color: inherit; 124 | padding: 6px; 125 | border: 1px solid #999; 126 | box-shadow: inset 0 -1px 5px 0 rgba(0, 0, 0, 0.2); 127 | -moz-box-sizing: border-box; 128 | -ms-box-sizing: border-box; 129 | -o-box-sizing: border-box; 130 | box-sizing: border-box; 131 | -webkit-font-smoothing: antialiased; 132 | -moz-font-smoothing: antialiased; 133 | -ms-font-smoothing: antialiased; 134 | -o-font-smoothing: antialiased; 135 | font-smoothing: antialiased; 136 | } 137 | 138 | #new-todo { 139 | padding: 16px 16px 16px 60px; 140 | border: none; 141 | background: rgba(0, 0, 0, 0.02); 142 | z-index: 2; 143 | box-shadow: none; 144 | } 145 | 146 | #main { 147 | position: relative; 148 | z-index: 2; 149 | border-top: 1px dotted #adadad; 150 | } 151 | 152 | label[for='toggle-all'] { 153 | display: none; 154 | } 155 | 156 | #toggle-all { 157 | position: absolute; 158 | top: -42px; 159 | left: -4px; 160 | width: 40px; 161 | text-align: center; 162 | /* Mobile Safari */ 163 | border: none; 164 | } 165 | 166 | #toggle-all:before { 167 | content: '»'; 168 | font-size: 28px; 169 | color: #d9d9d9; 170 | padding: 0 25px 7px; 171 | } 172 | 173 | #toggle-all:checked:before { 174 | color: #737373; 175 | } 176 | 177 | #todo-list { 178 | margin: 0; 179 | padding: 0; 180 | list-style: none; 181 | } 182 | 183 | #todo-list li { 184 | position: relative; 185 | font-size: 24px; 186 | border-bottom: 1px dotted #ccc; 187 | } 188 | 189 | #todo-list li:last-child { 190 | border-bottom: none; 191 | } 192 | 193 | #todo-list li.editing { 194 | border-bottom: none; 195 | padding: 0; 196 | } 197 | 198 | #todo-list li.editing .edit { 199 | display: block; 200 | width: 506px; 201 | padding: 13px 17px 12px 17px; 202 | margin: 0 0 0 43px; 203 | } 204 | 205 | #todo-list li.editing .view { 206 | display: none; 207 | } 208 | 209 | #todo-list li .toggle { 210 | text-align: center; 211 | width: 40px; 212 | /* auto, since non-WebKit browsers doesn't support input styling */ 213 | height: auto; 214 | position: absolute; 215 | top: 0; 216 | bottom: 0; 217 | margin: auto 0; 218 | /* Mobile Safari */ 219 | border: none; 220 | -webkit-appearance: none; 221 | -ms-appearance: none; 222 | -o-appearance: none; 223 | appearance: none; 224 | } 225 | 226 | #todo-list li .toggle:after { 227 | content: '✔'; 228 | /* 40 + a couple of pixels visual adjustment */ 229 | line-height: 43px; 230 | font-size: 20px; 231 | color: #d9d9d9; 232 | text-shadow: 0 -1px 0 #bfbfbf; 233 | } 234 | 235 | #todo-list li .toggle:checked:after { 236 | color: #85ada7; 237 | text-shadow: 0 1px 0 #669991; 238 | bottom: 1px; 239 | position: relative; 240 | } 241 | 242 | #todo-list li label { 243 | white-space: pre; 244 | word-break: break-word; 245 | padding: 15px 60px 15px 15px; 246 | margin-left: 45px; 247 | display: block; 248 | line-height: 1.2; 249 | -webkit-transition: color 0.4s; 250 | transition: color 0.4s; 251 | } 252 | 253 | #todo-list li.completed label { 254 | color: #a9a9a9; 255 | text-decoration: line-through; 256 | } 257 | 258 | #todo-list li .destroy { 259 | display: none; 260 | position: absolute; 261 | top: 0; 262 | right: 10px; 263 | bottom: 0; 264 | width: 40px; 265 | height: 40px; 266 | margin: auto 0; 267 | font-size: 22px; 268 | color: #a88a8a; 269 | -webkit-transition: all 0.2s; 270 | transition: all 0.2s; 271 | } 272 | 273 | #todo-list li .destroy:hover { 274 | text-shadow: 0 0 1px #000, 275 | 0 0 10px rgba(199, 107, 107, 0.8); 276 | -webkit-transform: scale(1.3); 277 | -ms-transform: scale(1.3); 278 | transform: scale(1.3); 279 | } 280 | 281 | #todo-list li .destroy:after { 282 | content: '✖'; 283 | } 284 | 285 | #todo-list li:hover .destroy { 286 | display: block; 287 | } 288 | 289 | #todo-list li .edit { 290 | display: none; 291 | } 292 | 293 | #todo-list li.editing:last-child { 294 | margin-bottom: -1px; 295 | } 296 | 297 | #footer { 298 | color: #777; 299 | padding: 0 15px; 300 | position: absolute; 301 | right: 0; 302 | bottom: -31px; 303 | left: 0; 304 | height: 20px; 305 | z-index: 1; 306 | text-align: center; 307 | } 308 | 309 | #footer:before { 310 | content: ''; 311 | position: absolute; 312 | right: 0; 313 | bottom: 31px; 314 | left: 0; 315 | height: 50px; 316 | z-index: -1; 317 | box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), 318 | 0 6px 0 -3px rgba(255, 255, 255, 0.8), 319 | 0 7px 1px -3px rgba(0, 0, 0, 0.3), 320 | 0 43px 0 -6px rgba(255, 255, 255, 0.8), 321 | 0 44px 2px -6px rgba(0, 0, 0, 0.2); 322 | } 323 | 324 | #todo-count { 325 | float: left; 326 | text-align: left; 327 | } 328 | 329 | #filters { 330 | margin: 0; 331 | padding: 0; 332 | list-style: none; 333 | position: absolute; 334 | right: 0; 335 | left: 0; 336 | } 337 | 338 | #filters li { 339 | display: inline; 340 | } 341 | 342 | #filters li a { 343 | color: #83756f; 344 | margin: 2px; 345 | text-decoration: none; 346 | } 347 | 348 | #filters li a.selected { 349 | font-weight: bold; 350 | } 351 | 352 | #clear-completed { 353 | float: right; 354 | position: relative; 355 | line-height: 20px; 356 | text-decoration: none; 357 | background: rgba(0, 0, 0, 0.1); 358 | font-size: 11px; 359 | padding: 0 10px; 360 | border-radius: 3px; 361 | box-shadow: 0 -1px 0 0 rgba(0, 0, 0, 0.2); 362 | } 363 | 364 | #clear-completed:hover { 365 | background: rgba(0, 0, 0, 0.15); 366 | box-shadow: 0 -1px 0 0 rgba(0, 0, 0, 0.3); 367 | } 368 | 369 | #info { 370 | margin: 65px auto 0; 371 | color: #a6a6a6; 372 | font-size: 12px; 373 | text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7); 374 | text-align: center; 375 | } 376 | 377 | #info a { 378 | color: inherit; 379 | } 380 | 381 | /* 382 | Hack to remove background from Mobile Safari. 383 | Can't use it globally since it destroys checkboxes in Firefox and Opera 384 | */ 385 | 386 | @media screen and (-webkit-min-device-pixel-ratio:0) { 387 | #toggle-all, 388 | #todo-list li .toggle { 389 | background: none; 390 | } 391 | 392 | #todo-list li .toggle { 393 | height: 40px; 394 | } 395 | 396 | #toggle-all { 397 | top: -56px; 398 | left: -15px; 399 | width: 65px; 400 | height: 41px; 401 | -webkit-transform: rotate(90deg); 402 | -ms-transform: rotate(90deg); 403 | transform: rotate(90deg); 404 | -webkit-appearance: none; 405 | appearance: none; 406 | } 407 | } 408 | 409 | .hidden { 410 | display: none; 411 | } 412 | 413 | hr { 414 | margin: 20px 0; 415 | border: 0; 416 | border-top: 1px dashed #C5C5C5; 417 | border-bottom: 1px dashed #F7F7F7; 418 | } 419 | 420 | .learn a { 421 | font-weight: normal; 422 | text-decoration: none; 423 | color: #b83f45; 424 | } 425 | 426 | .learn a:hover { 427 | text-decoration: underline; 428 | color: #787e7e; 429 | } 430 | 431 | .learn h3, 432 | .learn h4, 433 | .learn h5 { 434 | margin: 10px 0; 435 | font-weight: 500; 436 | line-height: 1.2; 437 | color: #000; 438 | } 439 | 440 | .learn h3 { 441 | font-size: 24px; 442 | } 443 | 444 | .learn h4 { 445 | font-size: 18px; 446 | } 447 | 448 | .learn h5 { 449 | margin-bottom: 0; 450 | font-size: 14px; 451 | } 452 | 453 | .learn ul { 454 | padding: 0; 455 | margin: 0 0 30px 25px; 456 | } 457 | 458 | .learn li { 459 | line-height: 20px; 460 | } 461 | 462 | .learn p { 463 | font-size: 15px; 464 | font-weight: 300; 465 | line-height: 1.3; 466 | margin-top: 0; 467 | margin-bottom: 0; 468 | } 469 | 470 | .quote { 471 | border: none; 472 | margin: 20px 0 60px 0; 473 | } 474 | 475 | .quote p { 476 | font-style: italic; 477 | } 478 | 479 | .quote p:before { 480 | content: '“'; 481 | font-size: 50px; 482 | opacity: .15; 483 | position: absolute; 484 | top: -20px; 485 | left: 3px; 486 | } 487 | 488 | .quote p:after { 489 | content: '”'; 490 | font-size: 50px; 491 | opacity: .15; 492 | position: absolute; 493 | bottom: -42px; 494 | right: 3px; 495 | } 496 | 497 | .quote footer { 498 | position: absolute; 499 | bottom: -40px; 500 | right: 0; 501 | } 502 | 503 | .quote footer img { 504 | border-radius: 3px; 505 | } 506 | 507 | .quote footer a { 508 | margin-left: 5px; 509 | vertical-align: middle; 510 | } 511 | 512 | .speech-bubble { 513 | position: relative; 514 | padding: 10px; 515 | background: rgba(0, 0, 0, .04); 516 | border-radius: 5px; 517 | } 518 | 519 | .speech-bubble:after { 520 | content: ''; 521 | position: absolute; 522 | top: 100%; 523 | right: 30px; 524 | border: 13px solid transparent; 525 | border-top-color: rgba(0, 0, 0, .04); 526 | } 527 | 528 | .learn-bar > .learn { 529 | position: absolute; 530 | width: 272px; 531 | top: 8px; 532 | left: -300px; 533 | padding: 10px; 534 | border-radius: 5px; 535 | background-color: rgba(255, 255, 255, .6); 536 | -webkit-transition-property: left; 537 | transition-property: left; 538 | -webkit-transition-duration: 500ms; 539 | transition-duration: 500ms; 540 | } 541 | 542 | @media (min-width: 899px) { 543 | .learn-bar { 544 | width: auto; 545 | margin: 0 0 0 300px; 546 | } 547 | 548 | .learn-bar > .learn { 549 | left: 8px; 550 | } 551 | 552 | .learn-bar #todoapp { 553 | width: 550px; 554 | margin: 130px auto 40px auto; 555 | } 556 | } 557 | -------------------------------------------------------------------------------- /resources/app/angularjs/bower_components/todomvc-common/base.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | 'use strict'; 3 | 4 | // Underscore's Template Module 5 | // Courtesy of underscorejs.org 6 | var _ = (function (_) { 7 | _.defaults = function (object) { 8 | if (!object) { 9 | return object; 10 | } 11 | for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) { 12 | var iterable = arguments[argsIndex]; 13 | if (iterable) { 14 | for (var key in iterable) { 15 | if (object[key] == null) { 16 | object[key] = iterable[key]; 17 | } 18 | } 19 | } 20 | } 21 | return object; 22 | } 23 | 24 | // By default, Underscore uses ERB-style template delimiters, change the 25 | // following template settings to use alternative delimiters. 26 | _.templateSettings = { 27 | evaluate : /<%([\s\S]+?)%>/g, 28 | interpolate : /<%=([\s\S]+?)%>/g, 29 | escape : /<%-([\s\S]+?)%>/g 30 | }; 31 | 32 | // When customizing `templateSettings`, if you don't want to define an 33 | // interpolation, evaluation or escaping regex, we need one that is 34 | // guaranteed not to match. 35 | var noMatch = /(.)^/; 36 | 37 | // Certain characters need to be escaped so that they can be put into a 38 | // string literal. 39 | var escapes = { 40 | "'": "'", 41 | '\\': '\\', 42 | '\r': 'r', 43 | '\n': 'n', 44 | '\t': 't', 45 | '\u2028': 'u2028', 46 | '\u2029': 'u2029' 47 | }; 48 | 49 | var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g; 50 | 51 | // JavaScript micro-templating, similar to John Resig's implementation. 52 | // Underscore templating handles arbitrary delimiters, preserves whitespace, 53 | // and correctly escapes quotes within interpolated code. 54 | _.template = function(text, data, settings) { 55 | var render; 56 | settings = _.defaults({}, settings, _.templateSettings); 57 | 58 | // Combine delimiters into one regular expression via alternation. 59 | var matcher = new RegExp([ 60 | (settings.escape || noMatch).source, 61 | (settings.interpolate || noMatch).source, 62 | (settings.evaluate || noMatch).source 63 | ].join('|') + '|$', 'g'); 64 | 65 | // Compile the template source, escaping string literals appropriately. 66 | var index = 0; 67 | var source = "__p+='"; 68 | text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { 69 | source += text.slice(index, offset) 70 | .replace(escaper, function(match) { return '\\' + escapes[match]; }); 71 | 72 | if (escape) { 73 | source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; 74 | } 75 | if (interpolate) { 76 | source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; 77 | } 78 | if (evaluate) { 79 | source += "';\n" + evaluate + "\n__p+='"; 80 | } 81 | index = offset + match.length; 82 | return match; 83 | }); 84 | source += "';\n"; 85 | 86 | // If a variable is not specified, place data values in local scope. 87 | if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; 88 | 89 | source = "var __t,__p='',__j=Array.prototype.join," + 90 | "print=function(){__p+=__j.call(arguments,'');};\n" + 91 | source + "return __p;\n"; 92 | 93 | try { 94 | render = new Function(settings.variable || 'obj', '_', source); 95 | } catch (e) { 96 | e.source = source; 97 | throw e; 98 | } 99 | 100 | if (data) return render(data, _); 101 | var template = function(data) { 102 | return render.call(this, data, _); 103 | }; 104 | 105 | // Provide the compiled function source as a convenience for precompilation. 106 | template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}'; 107 | 108 | return template; 109 | }; 110 | 111 | return _; 112 | })({}); 113 | 114 | if (location.hostname === 'todomvc.com') { 115 | window._gaq = [['_setAccount','UA-31081062-1'],['_trackPageview']];(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src='//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)}(document,'script')); 116 | } 117 | 118 | function redirect() { 119 | if (location.hostname === 'tastejs.github.io') { 120 | location.href = location.href.replace('tastejs.github.io/todomvc', 'todomvc.com'); 121 | } 122 | } 123 | 124 | function findRoot() { 125 | var base; 126 | 127 | [/labs/, /\w*-examples/].forEach(function (href) { 128 | var match = location.href.match(href); 129 | 130 | if (!base && match) { 131 | base = location.href.indexOf(match); 132 | } 133 | }); 134 | 135 | return location.href.substr(0, base); 136 | } 137 | 138 | function getFile(file, callback) { 139 | if (!location.host) { 140 | return console.info('Miss the info bar? Run TodoMVC from a server to avoid a cross-origin error.'); 141 | } 142 | 143 | var xhr = new XMLHttpRequest(); 144 | 145 | xhr.open('GET', findRoot() + file, true); 146 | xhr.send(); 147 | 148 | xhr.onload = function () { 149 | if (xhr.status === 200 && callback) { 150 | callback(xhr.responseText); 151 | } 152 | }; 153 | } 154 | 155 | function Learn(learnJSON, config) { 156 | if (!(this instanceof Learn)) { 157 | return new Learn(learnJSON, config); 158 | } 159 | 160 | var template, framework; 161 | 162 | if (typeof learnJSON !== 'object') { 163 | try { 164 | learnJSON = JSON.parse(learnJSON); 165 | } catch (e) { 166 | return; 167 | } 168 | } 169 | 170 | if (config) { 171 | template = config.template; 172 | framework = config.framework; 173 | } 174 | 175 | if (!template && learnJSON.templates) { 176 | template = learnJSON.templates.todomvc; 177 | } 178 | 179 | if (!framework && document.querySelector('[data-framework]')) { 180 | framework = document.querySelector('[data-framework]').getAttribute('data-framework'); 181 | } 182 | 183 | 184 | if (template && learnJSON[framework]) { 185 | this.frameworkJSON = learnJSON[framework]; 186 | this.template = template; 187 | 188 | this.append(); 189 | } 190 | } 191 | 192 | Learn.prototype.append = function () { 193 | var aside = document.createElement('aside'); 194 | aside.innerHTML = _.template(this.template, this.frameworkJSON); 195 | aside.className = 'learn'; 196 | 197 | // Localize demo links 198 | var demoLinks = aside.querySelectorAll('.demo-link'); 199 | Array.prototype.forEach.call(demoLinks, function (demoLink) { 200 | demoLink.setAttribute('href', findRoot() + demoLink.getAttribute('href')); 201 | }); 202 | 203 | document.body.className = (document.body.className + ' learn-bar').trim(); 204 | document.body.insertAdjacentHTML('afterBegin', aside.outerHTML); 205 | }; 206 | 207 | redirect(); 208 | getFile('learn.json', Learn); 209 | })(); 210 | -------------------------------------------------------------------------------- /resources/app/angularjs/bower_components/todomvc-common/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/r3b/grunt-protractor-coverage/de6857e792cedebb38524e4281ea98fc4b4fe192/resources/app/angularjs/bower_components/todomvc-common/bg.png -------------------------------------------------------------------------------- /resources/app/angularjs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AngularJS • TodoMVC 6 | 7 | 8 | 9 | 10 | 11 | 12 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /resources/app/angularjs/js/app.js: -------------------------------------------------------------------------------- 1 | /*global angular */ 2 | 3 | /** 4 | * The main TodoMVC app module 5 | * 6 | * @type {angular.Module} 7 | */ 8 | angular.module('todomvc', ['ngRoute']) 9 | .config(function ($routeProvider) { 10 | 'use strict'; 11 | 12 | $routeProvider.when('/', { 13 | controller: 'TodoCtrl', 14 | templateUrl: 'todomvc-index.html' 15 | }).when('/:status', { 16 | controller: 'TodoCtrl', 17 | templateUrl: 'todomvc-index.html' 18 | }).otherwise({ 19 | redirectTo: '/' 20 | }); 21 | }); 22 | -------------------------------------------------------------------------------- /resources/app/angularjs/js/controllers/todoCtrl.js: -------------------------------------------------------------------------------- 1 | /*global angular */ 2 | 3 | /** 4 | * The main controller for the app. The controller: 5 | * - retrieves and persists the model via the todoStorage service 6 | * - exposes the model to the template and provides event handlers 7 | */ 8 | angular.module('todomvc') 9 | .controller('TodoCtrl', function TodoCtrl($scope, $routeParams, $filter, todoStorage) { 10 | 'use strict'; 11 | 12 | var todos = $scope.todos = todoStorage.get(); 13 | 14 | $scope.newTodo = ''; 15 | $scope.editedTodo = null; 16 | 17 | $scope.$watch('todos', function (newValue, oldValue) { 18 | $scope.remainingCount = $filter('filter')(todos, { completed: false }).length; 19 | $scope.completedCount = todos.length - $scope.remainingCount; 20 | $scope.allChecked = !$scope.remainingCount; 21 | if (newValue !== oldValue) { // This prevents unneeded calls to the local storage 22 | todoStorage.put(todos); 23 | } 24 | }, true); 25 | 26 | // Monitor the current route for changes and adjust the filter accordingly. 27 | $scope.$on('$routeChangeSuccess', function () { 28 | var status = $scope.status = $routeParams.status || ''; 29 | 30 | $scope.statusFilter = (status === 'active') ? 31 | { completed: false } : (status === 'completed') ? 32 | { completed: true } : null; 33 | }); 34 | 35 | $scope.addTodo = function () { 36 | var newTodo = $scope.newTodo.trim(); 37 | if (!newTodo.length) { 38 | return; 39 | } 40 | 41 | todos.push({ 42 | title: newTodo, 43 | completed: false 44 | }); 45 | 46 | $scope.newTodo = ''; 47 | }; 48 | 49 | $scope.editTodo = function (todo) { 50 | $scope.editedTodo = todo; 51 | // Clone the original todo to restore it on demand. 52 | $scope.originalTodo = angular.extend({}, todo); 53 | }; 54 | 55 | $scope.doneEditing = function (todo) { 56 | $scope.editedTodo = null; 57 | todo.title = todo.title.trim(); 58 | 59 | if (!todo.title) { 60 | $scope.removeTodo(todo); 61 | } 62 | }; 63 | 64 | $scope.revertEditing = function (todo) { 65 | todos[todos.indexOf(todo)] = $scope.originalTodo; 66 | $scope.doneEditing($scope.originalTodo); 67 | }; 68 | 69 | $scope.removeTodo = function (todo) { 70 | todos.splice(todos.indexOf(todo), 1); 71 | }; 72 | 73 | $scope.clearCompletedTodos = function () { 74 | $scope.todos = todos = todos.filter(function (val) { 75 | return !val.completed; 76 | }); 77 | }; 78 | 79 | $scope.markAll = function (completed) { 80 | todos.forEach(function (todo) { 81 | todo.completed = !completed; 82 | }); 83 | }; 84 | }); 85 | -------------------------------------------------------------------------------- /resources/app/angularjs/js/directives/todoEscape.js: -------------------------------------------------------------------------------- 1 | /*global angular */ 2 | 3 | /** 4 | * Directive that executes an expression when the element it is applied to gets 5 | * an `escape` keydown event. 6 | */ 7 | angular.module('todomvc') 8 | .directive('todoEscape', function () { 9 | 'use strict'; 10 | 11 | var ESCAPE_KEY = 27; 12 | 13 | return function (scope, elem, attrs) { 14 | elem.bind('keydown', function (event) { 15 | if (event.keyCode === ESCAPE_KEY) { 16 | scope.$apply(attrs.todoEscape); 17 | } 18 | }); 19 | }; 20 | }); 21 | -------------------------------------------------------------------------------- /resources/app/angularjs/js/directives/todoFocus.js: -------------------------------------------------------------------------------- 1 | /*global angular */ 2 | 3 | /** 4 | * Directive that places focus on the element it is applied to when the 5 | * expression it binds to evaluates to true 6 | */ 7 | angular.module('todomvc') 8 | .directive('todoFocus', function todoFocus($timeout) { 9 | 'use strict'; 10 | 11 | return function (scope, elem, attrs) { 12 | scope.$watch(attrs.todoFocus, function (newVal) { 13 | if (newVal) { 14 | $timeout(function () { 15 | elem[0].focus(); 16 | }, 0, false); 17 | } 18 | }); 19 | }; 20 | }); 21 | -------------------------------------------------------------------------------- /resources/app/angularjs/js/services/todoStorage.js: -------------------------------------------------------------------------------- 1 | /*global angular */ 2 | 3 | /** 4 | * Services that persists and retrieves TODOs from localStorage 5 | */ 6 | angular.module('todomvc') 7 | .factory('todoStorage', function () { 8 | 'use strict'; 9 | 10 | var STORAGE_ID = 'todos-angularjs'; 11 | 12 | return { 13 | get: function () { 14 | return JSON.parse(localStorage.getItem(STORAGE_ID) || '[]'); 15 | }, 16 | 17 | put: function (todos) { 18 | localStorage.setItem(STORAGE_ID, JSON.stringify(todos)); 19 | } 20 | }; 21 | }); 22 | -------------------------------------------------------------------------------- /resources/app/angularjs/readme.md: -------------------------------------------------------------------------------- 1 | # AngularJS TodoMVC Example 2 | 3 | > HTML is great for declaring static documents, but it falters when we try to use it for declaring dynamic views in web-applications. AngularJS lets you extend HTML vocabulary for your application. The resulting environment is extraordinarily expressive, readable, and quick to develop. 4 | 5 | > _[AngularJS - angularjs.org](http://angularjs.org)_ 6 | 7 | 8 | ## Learning AngularJS 9 | The [AngularJS website](http://angularjs.org) is a great resource for getting started. 10 | 11 | Here are some links you may find helpful: 12 | 13 | * [Tutorial](http://docs.angularjs.org/tutorial) 14 | * [API Reference](http://docs.angularjs.org/api) 15 | * [Developer Guide](http://docs.angularjs.org/guide) 16 | * [Applications built with AngularJS](http://builtwith.angularjs.org) 17 | * [Blog](http://blog.angularjs.org) 18 | * [FAQ](http://docs.angularjs.org/misc/faq) 19 | * [AngularJS Meetups](http://www.youtube.com/angularjs) 20 | 21 | Articles and guides from the community: 22 | 23 | * [Code School AngularJS course](http://www.codeschool.com/code_tv/angularjs-part-1) 24 | * [5 Awesome AngularJS Features](http://net.tutsplus.com/tutorials/javascript-ajax/5-awesome-angularjs-features) 25 | * [Using Yeoman with AngularJS](http://briantford.com/blog/angular-yeoman.html) 26 | * [me&ngular - an introduction to MVW](http://stephenplusplus.github.io/meangular) 27 | 28 | Get help from other AngularJS users: 29 | 30 | * [Walkthroughs and Tutorials on YouTube](http://www.youtube.com/playlist?list=PL1w1q3fL4pmgqpzb-XhG7Clgi67d_OHXz) 31 | * [Google Groups mailing list](https://groups.google.com/forum/?fromgroups#!forum/angular) 32 | * [angularjs on Stack Overflow](http://stackoverflow.com/questions/tagged/angularjs) 33 | * [AngularJS on Twitter](https://twitter.com/angularjs) 34 | * [AngularjS on Google +](https://plus.google.com/+AngularJS/posts) 35 | 36 | _If you have other helpful links to share, or find any of the links above no longer work, please [let us know](https://github.com/tastejs/todomvc/issues)._ 37 | -------------------------------------------------------------------------------- /resources/app/angularjs/test/config/karma.conf.js: -------------------------------------------------------------------------------- 1 | module.exports = function (config) { 2 | 'use strict'; 3 | 4 | config.set({ 5 | basePath: '../../', 6 | frameworks: ['jasmine'], 7 | files: [ 8 | 'bower_components/angular/angular.js', 9 | 'bower_components/angular-route/angular-route.js', 10 | 'bower_components/angular-mocks/angular-mocks.js', 11 | 'js/**/*.js', 12 | 'test/unit/**/*.js' 13 | ], 14 | autoWatch: true, 15 | singleRun: false, 16 | browsers: ['Chrome', 'Firefox'] 17 | }); 18 | }; 19 | -------------------------------------------------------------------------------- /resources/app/angularjs/test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "todomvc-angular-tests", 3 | "description": "Unit tests for the AngularJS example of TodoMVC", 4 | "author": "Pascal Hartig ", 5 | "version": "1.0.0", 6 | "devDependencies": { 7 | "karma": "~0.10.0" 8 | }, 9 | "scripts": { 10 | "test": "karma start config/karma.conf.js" 11 | }, 12 | "dependencies": {} 13 | } 14 | -------------------------------------------------------------------------------- /resources/app/angularjs/test/readme.md: -------------------------------------------------------------------------------- 1 | Angular Unit Tests 2 | ================== 3 | 4 | To run the test suite, run these commands: 5 | 6 | npm install 7 | npm test 8 | -------------------------------------------------------------------------------- /resources/app/angularjs/test/unit/directivesSpec.js: -------------------------------------------------------------------------------- 1 | /*global describe, it, beforeEach, inject, expect, angular*/ 2 | (function () { 3 | 'use strict'; 4 | 5 | beforeEach(module('todomvc')); 6 | 7 | describe('todoFocus directive', function () { 8 | var scope, compile, browser; 9 | 10 | beforeEach(inject(function ($rootScope, $compile, $browser) { 11 | scope = $rootScope.$new(); 12 | compile = $compile; 13 | browser = $browser; 14 | })); 15 | 16 | it('should focus on truthy expression', function () { 17 | var el = angular.element(''); 18 | scope.focus = false; 19 | 20 | compile(el)(scope); 21 | expect(browser.deferredFns.length).toBe(0); 22 | 23 | scope.$apply(function () { 24 | scope.focus = true; 25 | }); 26 | 27 | expect(browser.deferredFns.length).toBe(1); 28 | }); 29 | }); 30 | }()); 31 | -------------------------------------------------------------------------------- /resources/app/angularjs/test/unit/todoCtrlSpec.js: -------------------------------------------------------------------------------- 1 | /*global describe, it, beforeEach, inject, expect*/ 2 | (function () { 3 | 'use strict'; 4 | 5 | describe('Todo Controller', function () { 6 | var ctrl, scope; 7 | var todoList; 8 | var todoStorage = { 9 | storage: {}, 10 | get: function () { 11 | return this.storage; 12 | }, 13 | put: function (value) { 14 | this.storage = value; 15 | } 16 | }; 17 | 18 | // Load the module containing the app, only 'ng' is loaded by default. 19 | beforeEach(module('todomvc')); 20 | 21 | beforeEach(inject(function ($controller, $rootScope) { 22 | scope = $rootScope.$new(); 23 | ctrl = $controller('TodoCtrl', { $scope: scope }); 24 | })); 25 | 26 | it('should not have an edited Todo on start', function () { 27 | expect(scope.editedTodo).toBeNull(); 28 | }); 29 | 30 | it('should not have any Todos on start', function () { 31 | expect(scope.todos.length).toBe(0); 32 | }); 33 | 34 | it('should have all Todos completed', function () { 35 | scope.$digest(); 36 | expect(scope.allChecked).toBeTruthy(); 37 | }); 38 | 39 | describe('the filter', function () { 40 | it('should default to ""', function () { 41 | scope.$emit('$routeChangeSuccess'); 42 | 43 | expect(scope.status).toBe(''); 44 | expect(scope.statusFilter).toBeNull(); 45 | }); 46 | 47 | describe('being at /active', function () { 48 | it('should filter non-completed', inject(function ($controller) { 49 | ctrl = $controller('TodoCtrl', { 50 | $scope: scope, 51 | $routeParams: { 52 | status: 'active' 53 | } 54 | }); 55 | 56 | scope.$emit('$routeChangeSuccess'); 57 | expect(scope.statusFilter.completed).toBeFalsy(); 58 | })); 59 | }); 60 | 61 | describe('being at /completed', function () { 62 | it('should filter completed', inject(function ($controller) { 63 | ctrl = $controller('TodoCtrl', { 64 | $scope: scope, 65 | $routeParams: { 66 | status: 'completed' 67 | } 68 | }); 69 | 70 | scope.$emit('$routeChangeSuccess'); 71 | expect(scope.statusFilter.completed).toBeTruthy(); 72 | })); 73 | }); 74 | }); 75 | 76 | describe('having no Todos', function () { 77 | var ctrl; 78 | 79 | beforeEach(inject(function ($controller) { 80 | todoStorage.storage = []; 81 | ctrl = $controller('TodoCtrl', { 82 | $scope: scope, 83 | todoStorage: todoStorage 84 | }); 85 | scope.$digest(); 86 | })); 87 | 88 | it('should not add empty Todos', function () { 89 | scope.newTodo = ''; 90 | scope.addTodo(); 91 | scope.$digest(); 92 | expect(scope.todos.length).toBe(0); 93 | }); 94 | 95 | it('should not add items consisting only of whitespaces', function () { 96 | scope.newTodo = ' '; 97 | scope.addTodo(); 98 | scope.$digest(); 99 | expect(scope.todos.length).toBe(0); 100 | }); 101 | 102 | 103 | it('should trim whitespace from new Todos', function () { 104 | scope.newTodo = ' buy some unicorns '; 105 | scope.addTodo(); 106 | scope.$digest(); 107 | expect(scope.todos.length).toBe(1); 108 | expect(scope.todos[0].title).toBe('buy some unicorns'); 109 | }); 110 | }); 111 | 112 | describe('having some saved Todos', function () { 113 | var ctrl; 114 | 115 | beforeEach(inject(function ($controller) { 116 | todoList = [{ 117 | 'title': 'Uncompleted Item 0', 118 | 'completed': false 119 | }, { 120 | 'title': 'Uncompleted Item 1', 121 | 'completed': false 122 | }, { 123 | 'title': 'Uncompleted Item 2', 124 | 'completed': false 125 | }, { 126 | 'title': 'Completed Item 0', 127 | 'completed': true 128 | }, { 129 | 'title': 'Completed Item 1', 130 | 'completed': true 131 | }]; 132 | 133 | todoStorage.storage = todoList; 134 | ctrl = $controller('TodoCtrl', { 135 | $scope: scope, 136 | todoStorage: todoStorage 137 | }); 138 | scope.$digest(); 139 | })); 140 | 141 | it('should count Todos correctly', function () { 142 | expect(scope.todos.length).toBe(5); 143 | expect(scope.remainingCount).toBe(3); 144 | expect(scope.completedCount).toBe(2); 145 | expect(scope.allChecked).toBeFalsy(); 146 | }); 147 | 148 | it('should save Todos to local storage', function () { 149 | expect(todoStorage.storage.length).toBe(5); 150 | }); 151 | 152 | it('should remove Todos w/o title on saving', function () { 153 | var todo = todoList[2]; 154 | todo.title = ''; 155 | 156 | scope.doneEditing(todo); 157 | expect(scope.todos.length).toBe(4); 158 | }); 159 | 160 | it('should trim Todos on saving', function () { 161 | var todo = todoList[0]; 162 | todo.title = ' buy moar unicorns '; 163 | 164 | scope.doneEditing(todo); 165 | expect(scope.todos[0].title).toBe('buy moar unicorns'); 166 | }); 167 | 168 | it('clearCompletedTodos() should clear completed Todos', function () { 169 | scope.clearCompletedTodos(); 170 | expect(scope.todos.length).toBe(3); 171 | }); 172 | 173 | it('markAll() should mark all Todos completed', function () { 174 | scope.markAll(); 175 | scope.$digest(); 176 | expect(scope.completedCount).toBe(5); 177 | }); 178 | 179 | it('revertTodo() get a Todo to its previous state', function () { 180 | var todo = todoList[0]; 181 | scope.editTodo(todo); 182 | todo.title = 'Unicorn sparkly skypuffles.'; 183 | scope.revertEditing(todo); 184 | scope.$digest(); 185 | expect(scope.todos[0].title).toBe('Uncompleted Item 0'); 186 | }); 187 | }); 188 | }); 189 | }()); 190 | -------------------------------------------------------------------------------- /resources/saveCoverage.tmpl: -------------------------------------------------------------------------------- 1 | var fs=fs||require("fs"); 2 | var http=http||require("http"); 3 | var options = { 4 | hostname: 'localhost', 5 | port: <%=collectorPort%>, 6 | path: '/data', 7 | method: 'POST', 8 | headers:{ 9 | 'Content-Type':'application/json' 10 | } 11 | }; 12 | function saveCoverage(data){ 13 | var req = http.request(options, function(res) { 14 | res.on('data', function (chunk) { 15 | }); 16 | }); 17 | req.on('error', function(e) { 18 | console.log('problem with request: ' + e.message); 19 | }); 20 | 21 | // write data to request body 22 | req.write(JSON.stringify(data)); 23 | req.write('\n'); 24 | req.end(); 25 | } 26 | 27 | function runCoverageGlobal(){ 28 | browser.driver.executeScript("return ('<%=coverage%>' in window)?window.<%=coverage%>:null;").then(function(val) { 29 | if (val) { 30 | saveCoverage(val); 31 | } else { 32 | console.warn('No coverage object in the browser.'); 33 | } 34 | }); 35 | } 36 | 37 | afterEach(runCoverageGlobal); 38 | -------------------------------------------------------------------------------- /resources/specFile.tmpl: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var fs = require('fs'); 3 | describe('Output the code coverage objects', function() { 4 | var browserCoverageObject = "return ('<%=coverage%>' in window)?window.<%=coverage%>:null;"; 5 | browser.sleep(3000); 6 | browser.driver.get(browser.baseUrl + '#'); 7 | browser.waitForAngular(); 8 | browser.wait(function() { 9 | return element(by.id('new-todo')).isPresent(); 10 | }); 11 | 12 | browser.driver.executeScript(browserCoverageObject).then(function(val) { 13 | if (val) { 14 | fs.writeFile("<%=filename%>", JSON.stringify(val), function(err) { 15 | if (err) { 16 | console.error('Could not write coverage object to <%=filename%>'); 17 | } else { 18 | console.log('Test coverage written to <%=filename%>'); 19 | } 20 | }); 21 | } else { 22 | console.warn('No coverage object in the browser.'); 23 | } 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /tasks/protractor_coverage.js: -------------------------------------------------------------------------------- 1 | /* 2 | * grunt-protractor-coverage 3 | * https://github.com/r3b/grunt-protractor-coverage 4 | * 5 | * Copyright (c) 2014 ryan bridges 6 | * Licensed under the APLv2 license. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | var http = require('http'); 12 | var util = require('util'); 13 | var fs = require('fs'); 14 | var path = require('path'); 15 | var dargs = require('dargs-object'); 16 | var tmp = require('temporary'); 17 | var esprima=require('esprima'); 18 | var estraverse=require('estraverse'); 19 | var escodegen=require('escodegen'); 20 | module.exports = function(grunt) { 21 | function resolvePath(filename, paths){ 22 | var filepaths=paths.map(function(p){ 23 | try{ 24 | return require.resolve(path.resolve(p, filename)); 25 | }catch(e){ 26 | return null; 27 | } 28 | }); 29 | return filepaths.shift(); 30 | } 31 | function instrumentSpecFile(payload, file, configDir){ 32 | var code= grunt.file.read(file); 33 | var ast=esprima.parse(code); 34 | if(!ast){ 35 | return; 36 | } 37 | estraverse.traverse(ast, { 38 | enter: function (node, parent) { 39 | if(node.type==='CallExpression' && node.callee.type==='Identifier'){ 40 | if(node.callee.name==='describe'){ 41 | node.arguments 42 | .filter(function(n){return n.type==='FunctionExpression';}) 43 | .forEach(function(f){ 44 | f.body.body=payload.body.concat(f.body.body); 45 | }); 46 | }else if(node.callee.name==='require'){ 47 | if(node.arguments){ 48 | node.arguments=node.arguments 49 | .map(function(f){ 50 | if(f.type==='Literal'){ 51 | if(/^\.\.?\//.test(f.value)){ 52 | grunt.verbose.writeln("Spec file %s requires %s", file, f.value); 53 | var filepaths=[path.dirname(file), process.cwd()]; 54 | if(configDir){ 55 | filepaths.push(configDir); 56 | } 57 | var filepath=resolvePath(f.value, filepaths); 58 | if(filepath){ 59 | grunt.verbose.writeln("Rewriting %s as %s", f.value, filepath); 60 | f.value=filepath; 61 | }else{ 62 | grunt.warn("Unable to rewrite "+ f.value); 63 | } 64 | } 65 | // f.value=f.value.replace(/^\.\//, path.dirname(file)+'/'); 66 | } 67 | return f; 68 | }); 69 | } 70 | } 71 | } 72 | } 73 | }); 74 | var newSpecFile=(new tmp.File()).path; 75 | grunt.verbose.writeln("Writing new Spec file: %s", newSpecFile); 76 | grunt.file.write(newSpecFile, escodegen.generate(ast)); 77 | return newSpecFile; 78 | } 79 | 80 | grunt.registerMultiTask('protractor_coverage', 'Instrument your code and gather coverage data from Protractor E2E tests', function() { 81 | // '.../node_modules/protractor/lib/protractor.js' 82 | var protractorMainPath = require.resolve('protractor'); 83 | // '.../node_modules/protractor/bin/protractor' 84 | var protractorBinPath = path.resolve(protractorMainPath, '../../bin/protractor'); 85 | // '.../node_modules/protractor/referenceConf.js' 86 | var protractorRefConfPath = path.resolve(protractorMainPath, '../../referenceConf.js'); 87 | // Merge task-specific and/or target-specific options with these defaults. 88 | var opts = this.options({ 89 | configFile: (!grunt.util._.isUndefined(this.data.configFile)) ? this.data.configFile : protractorRefConfPath, 90 | keepAlive: (!grunt.util._.isUndefined(this.data.keepAlive)) ? this.data.keepAlive : true, 91 | noColor: false, 92 | noInject: false, 93 | debug: false, 94 | collectorPort: 3001, 95 | args: {}, 96 | saveCoverageTemplate: "resources/saveCoverage.tmpl" 97 | }); 98 | var saveCoverageTemplate = grunt.file.expand([ opts.saveCoverageTemplate, "node_modules/grunt-protractor-coverage/resources/saveCoverage.tmpl", path.join(__dirname, '..') + '/**/resources/saveCoverage.tmpl']).shift(); 99 | if(!saveCoverageTemplate){ 100 | grunt.fail.fatal("Coverage template file not found."); 101 | } 102 | var coverageDir = path.resolve(opts.coverageDir||'coverage/'); 103 | coverageDir = coverageDir.replace(/\\/g,'/'); 104 | var noInject = opts.noInject; 105 | if (!noInject) { 106 | var saveCoverageSource = grunt.file.read(saveCoverageTemplate); 107 | var saveCoverageContent=grunt.template.process( saveCoverageSource, { 108 | data: { 109 | dirname: coverageDir, 110 | collectorPort: opts.collectorPort, 111 | coverage: '__coverage__' 112 | } 113 | }); 114 | var saveCoverageAST=esprima.parse(saveCoverageContent); 115 | } 116 | grunt.verbose.writeln("Options: " + util.inspect(opts)); 117 | 118 | var keepAlive = opts['keepAlive']; 119 | var supportedArgs = [ 120 | //string 121 | "seleniumAddress", "seleniumServerJar", "seleniumPort", "baseUrl", 122 | "rootElement", "browser", "chromeDriver", "chromeOnly", "sauceUser", 123 | "sauceKey", "framework", "coverageFilename", 124 | //list 125 | "specs","exclude", 126 | //boolean 127 | "includeStackTrace", "verbose", 128 | //object 129 | "params", "capabilities", "cucumberOpts","keepAlive" 130 | ]; 131 | var args = [protractorBinPath, opts.configFile]; 132 | if (opts.noColor) { 133 | args.push('--no-jasmineNodeOpts.showColors'); 134 | } 135 | if (!grunt.util._.isUndefined(opts.debug) && opts.debug === true) { 136 | args.splice(1, 0, 'debug'); 137 | } 138 | 139 | var suppliedArgs = supportedArgs.reduce(function(args, arg) { 140 | var value = grunt.option(arg) || opts.args[arg]; 141 | if ("undefined" !== typeof value && value != null) { 142 | args[arg] = value; 143 | } 144 | return args; 145 | }, {}); 146 | 147 | var coverageFilename=suppliedArgs['coverageFilename'] ? suppliedArgs['coverageFilename'].replace(".json", "") : 'coverage'; 148 | var configDir=path.dirname(path.resolve(opts.configFile)); 149 | grunt.file.mkdir(coverageDir); 150 | 151 | var pConfigs = require(path.resolve(opts.configFile)); 152 | var specs=suppliedArgs.specs || []; 153 | var excludes=suppliedArgs.exclude || []; 154 | suppliedArgs.specs=[]; 155 | specs = specs.concat(pConfigs.config.specs || []); 156 | excludes= excludes.concat(pConfigs.config.exclude || []); 157 | excludes=grunt.file.expand(excludes); 158 | grunt.verbose.writeln("Provided specs:", specs); 159 | grunt.verbose.writeln("Exclusions:", excludes); 160 | var files = grunt.file.expand(specs).filter(function(file){return excludes.indexOf(file)===-1;}); 161 | grunt.verbose.writeln("Expanded specs:", files); 162 | if (!noInject) { 163 | //for each spec file, wrap each method call with a closure to save the coverage object 164 | suppliedArgs.specs=files.map(function(file){return instrumentSpecFile(saveCoverageAST, file);}); 165 | } else { 166 | suppliedArgs.specs=files; 167 | } 168 | 169 | args = args 170 | .concat(dargs(suppliedArgs, { 171 | joinLists: true 172 | })); 173 | var gargs=grunt.option.flags() 174 | .filter(function(f){return args.indexOf(f)===-1;}) 175 | .map(function(f){ 176 | if(f.indexOf('--debug') === 0) { 177 | f = '--debug'; 178 | } 179 | return f.split('=');}) 180 | .reduce(function(a, f){return a.concat(f);},[]); 181 | args=args.concat(gargs); 182 | 183 | grunt.verbose.writeln("Specs: \n\t" + suppliedArgs.specs.join("\n\t")); 184 | grunt.verbose.writeln("Spawn node with arguments: " + args); 185 | // start the collector 186 | var collector=require('coverage-collector'); 187 | collector({port: opts.collectorPort}); 188 | function cleanup(callback){ 189 | if (!noInject) { 190 | suppliedArgs.specs.forEach(function(f){grunt.file.delete(f, {force:true});}); 191 | } 192 | } 193 | function getCoverageData(callback){ 194 | http.get("http://localhost:" + opts.collectorPort + "/data", function(res) { 195 | var payload=""; 196 | res.on('data', function (chunk) { 197 | payload+=chunk; 198 | // grunt.log.warn('BODY: ' + chunk); 199 | }); 200 | res.on('end', function(){ 201 | http.get("http://localhost:" + opts.collectorPort + "/done", function(res) { 202 | cleanup(); 203 | if(callback){callback(payload);} 204 | }) 205 | .on('error', function(e) { 206 | cleanup(); 207 | grunt.log.error("Got error: " + e.message); 208 | if(callback){callback(payload);} 209 | }); 210 | }); 211 | }).on('error', function(e) { 212 | cleanup(); 213 | grunt.log.error("Got error: " + e.message); 214 | if(callback){callback();} 215 | }); 216 | } 217 | // Spawn protractor command 218 | var done = this.async(); 219 | process.env["NODE_PATH"]=[process.env["NODE_PATH"],process.cwd()+'/node_modules'].join(path.delimiter); 220 | grunt.util.spawn({ 221 | cmd: 'node', 222 | args: args, 223 | opts: { 224 | stdio: 'inherit' 225 | } 226 | }, 227 | function(error, result, code) { 228 | 229 | if (error) { 230 | grunt.log.error(String(result)); 231 | if ((code === 1 || code === 100) && keepAlive) { 232 | // Test fails but do not want to stop the grunt process. 233 | grunt.log.oklns("Test failed but keep the grunt process alive."); 234 | } else { 235 | // Test fails and want to stop the grunt process, 236 | // or protractor exited with other reason. 237 | grunt.warn('Tests failed, protractor exited with code: ' + code, code); 238 | } 239 | } 240 | getCoverageData(function(payload){ 241 | try{ 242 | var filename=path.normalize([coverageDir,'/'+coverageFilename+'.json'].join('')); 243 | fs.writeFileSync(filename, payload); 244 | }catch(e){ 245 | grunt.log.error("Got error: " + e.message); 246 | } finally { 247 | done(); 248 | done = null; 249 | } 250 | }); 251 | } 252 | ); 253 | }); 254 | }; 255 | -------------------------------------------------------------------------------- /test/cucumber.conf.js: -------------------------------------------------------------------------------- 1 | exports.config = { 2 | // The address of a running selenium server. If specified, Protractor will 3 | // connect to an already running instance of selenium. This usually looks like 4 | seleniumAddress: 'http://localhost:4444/wd/hub', 5 | 6 | // Spec patterns are relative to the location of this config. 7 | specs: [ 8 | 'test/features/*.feature' 9 | ], 10 | 11 | // A base URL for your application under test. Calls to protractor.get() 12 | // with relative paths will be prepended with this. 13 | baseUrl: 'http://localhost:3000/', 14 | 15 | // Test framework to use. This may be one of: 16 | // jasmine, jasmine2, cucumber, mocha or custom. 17 | framework: 'cucumber', 18 | 19 | // Options to be passed to Cucumber. 20 | cucumberOpts: {} 21 | }; -------------------------------------------------------------------------------- /test/features/step_definitions/stepDefinitions.js: -------------------------------------------------------------------------------- 1 | //var coverage = require('grunt-protractor-coverage/cucumber'); 2 | var coverage = require('../../../cucumber'); 3 | 4 | module.exports = function() { 5 | 6 | this.After(coverage.getCoverage); 7 | 8 | this.Given(/^(\d+) seconds? has passed$/, function (seconds) { 9 | return browser.sleep(seconds * 1000); 10 | }); 11 | 12 | this.When(/^the user goes to the home page$/, function () { 13 | return browser.driver.get(browser.baseUrl + '#'); 14 | }); 15 | 16 | this.Then(/^the todo list is present$/, function () { 17 | browser.waitForAngular(); 18 | return browser.wait(function() { 19 | return element(by.id('new-todo')).isPresent(); 20 | }); 21 | }); 22 | 23 | }; -------------------------------------------------------------------------------- /test/features/test.feature: -------------------------------------------------------------------------------- 1 | Feature: Plugin works 2 | 3 | Scenario: It should not really do much 4 | Given 3 seconds has passed 5 | When the user goes to the home page 6 | Then the todo list is present 7 | 8 | Scenario: It should continue doing nothing 9 | Given 1 second has passed 10 | When the user goes to the home page 11 | Then the todo list is present -------------------------------------------------------------------------------- /test/myTemplate.tmpl: -------------------------------------------------------------------------------- 1 | var fs=fs||require("fs"); 2 | var http=http||require("http"); 3 | var options = { 4 | hostname: 'localhost', 5 | port: <%=collectorPort%>, 6 | path: '/data', 7 | method: 'POST', 8 | headers:{ 9 | 'Content-Type':'application/json' 10 | } 11 | }; 12 | function saveCoverage(data){ 13 | var req = http.request(options, function(res) { 14 | res.on('data', function (chunk) { 15 | }); 16 | }); 17 | req.on('error', function(e) { 18 | console.log('problem with request: ' + e.message); 19 | }); 20 | 21 | // write data to request body 22 | req.write(JSON.stringify(data)); 23 | req.write('\n'); 24 | req.end(); 25 | } 26 | 27 | function runCoverageGlobal(){ 28 | browser.driver.executeScript("return ('<%=coverage%>' in window)?window.<%=coverage%>:null;").then(function(val) { 29 | if (val) { 30 | saveCoverage(val); 31 | } else { 32 | console.warn('No coverage object in the browser.'); 33 | } 34 | }); 35 | } 36 | 37 | afterEach(runCoverageGlobal); 38 | 39 | function ownFunction(){ 40 | /******** My own template file. Check /tmp/user/[id]/tmp_files ************************/ 41 | } 42 | 43 | -------------------------------------------------------------------------------- /test/protractor/exclude.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | describe('Ensure that the file globbing works', function() { 3 | it('should not be run.', function() { 4 | browser.sleep(3000); 5 | browser.driver.get(browser.baseUrl+'#'); 6 | browser.waitForAngular(); 7 | browser.wait(function() { 8 | return element(by.id('new-todo')).isPresent(); 9 | }); 10 | 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /test/protractor/exclude2.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | describe('Ensure that the file globbing works', function() { 3 | it('also should not be run.', function() { 4 | browser.sleep(3000); 5 | browser.driver.get(browser.baseUrl+'#'); 6 | browser.waitForAngular(); 7 | browser.wait(function() { 8 | return element(by.id('new-todo')).isPresent(); 9 | }); 10 | 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /test/protractor/test.spec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | require('./../protractor_coverage_test'); 3 | require('coverage-collector'); 4 | describe('Ensure that the plugin works', function() { 5 | it('should not really do much.', function() { 6 | browser.sleep(3000); 7 | browser.driver.get(browser.baseUrl+'#'); 8 | browser.waitForAngular(); 9 | browser.wait(function() { 10 | return element(by.id('new-todo')).isPresent(); 11 | }); 12 | 13 | }); 14 | it('should continue doing nothing.', function() { 15 | browser.sleep(1000); 16 | browser.driver.get(browser.baseUrl+'#'); 17 | browser.waitForAngular(); 18 | browser.wait(function() { 19 | return element(by.id('new-todo')).isPresent(); 20 | }); 21 | 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /test/protractorConf.js: -------------------------------------------------------------------------------- 1 | // A reference configuration file. 2 | exports.config = { 3 | // ----- How to setup Selenium ----- 4 | // 5 | // There are three ways to specify how to use Selenium. Specify one of the 6 | // following: 7 | // 8 | // 1. seleniumServerJar - to start Selenium Standalone locally. 9 | // 2. seleniumAddress - to connect to a Selenium server which is already 10 | // running. 11 | // 3. sauceUser/sauceKey - to use remote Selenium servers via SauceLabs. 12 | // 13 | // If the chromeOnly option is specified, no Selenium server will be started, 14 | // and chromeDriver will be used directly (from the location specified in 15 | // chromeDriver) 16 | 17 | // The location of the selenium standalone server .jar file, relative 18 | // to the location of this config. If no other method of starting selenium 19 | // is found, this will default to protractor/selenium/selenium-server... 20 | seleniumServerJar: null,//'./selenium/selenium-server-standalone-2.37.0.jar', 21 | // The port to start the selenium server on, or null if the server should 22 | // find its own unused port. 23 | seleniumPort: 3010,//3010, 24 | // Chromedriver location is used to help the selenium standalone server 25 | // find chromedriver. This will be passed to the selenium jar as 26 | // the system property webdriver.chrome.driver. If null, selenium will 27 | // attempt to find chromedriver using PATH. 28 | chromeDriver: './selenium/chromedriver', 29 | // If true, only chromedriver will be started, not a standalone selenium. 30 | // Tests for browsers other than chrome will not run. 31 | chromeOnly: false, 32 | // Additional command line options to pass to selenium. For example, 33 | // if you need to change the browser timeout, use 34 | // seleniumArgs: ['-browserTimeout=60'], 35 | seleniumArgs: [], 36 | 37 | // The address of a running selenium server. If specified, Protractor will 38 | // connect to an already running instance of selenium. This usually looks like 39 | seleniumAddress: 'http://localhost:4444/wd/hub', 40 | // If sauceUser and sauceKey are specified, seleniumServerJar will be ignored. 41 | // The tests will be run remotely using SauceLabs. 42 | 43 | // The timeout for each script run on the browser. This should be longer 44 | // than the maximum time your application needs to stabilize between tasks. 45 | allScriptsTimeout: 30000, 46 | 47 | // ----- What tests to run ----- 48 | // 49 | // Spec patterns are relative to the location of this config. 50 | specs: [ 51 | 'test/protractor/*.spec.js', 52 | '!**/exclude.spec.js' 53 | ], 54 | exclude: ['test/protractor/exclude2.spec.js'], 55 | // ----- Capabilities to be passed to the webdriver instance ---- 56 | // 57 | // For a full list of available capabilities, see 58 | // https://code.google.com/p/selenium/wiki/DesiredCapabilities 59 | // and 60 | // https://code.google.com/p/selenium/source/browse/javascript/webdriver/capabilities.js 61 | capabilities: { 62 | 'browserName': 'chrome', 63 | // 'browserName': 'firefox' 64 | // 'browserName': 'phantomjs' 65 | }, 66 | params: { 67 | 68 | 69 | }, 70 | // ----- More information for your tests ---- 71 | // 72 | // A base URL for your application under test. Calls to protractor.get() 73 | // with relative paths will be prepended with this. 74 | baseUrl: 'http://localhost:3000/', 75 | 76 | 77 | // Options to be passed to Jasmine-node. 78 | jasmineNodeOpts: { 79 | showColors: true, // Use colors in the command line report. 80 | isVerbose: true, // List all tests in the console 81 | includeStackTrace: true, 82 | defaultTimeoutInterval: 90000 83 | 84 | } 85 | }; 86 | -------------------------------------------------------------------------------- /test/protractorConf.remote.js: -------------------------------------------------------------------------------- 1 | // A reference configuration file. 2 | exports.config = { 3 | // ----- How to setup Selenium ----- 4 | // 5 | // There are three ways to specify how to use Selenium. Specify one of the 6 | // following: 7 | // 8 | // 1. seleniumServerJar - to start Selenium Standalone locally. 9 | // 2. seleniumAddress - to connect to a Selenium server which is already 10 | // running. 11 | // 3. sauceUser/sauceKey - to use remote Selenium servers via SauceLabs. 12 | // 13 | // If the chromeOnly option is specified, no Selenium server will be started, 14 | // and chromeDriver will be used directly (from the location specified in 15 | // chromeDriver) 16 | 17 | // The location of the selenium standalone server .jar file, relative 18 | // to the location of this config. If no other method of starting selenium 19 | // is found, this will default to protractor/selenium/selenium-server... 20 | seleniumServerJar: null,//'./selenium/selenium-server-standalone-2.37.0.jar', 21 | // The port to start the selenium server on, or null if the server should 22 | // find its own unused port. 23 | seleniumPort: 3010,//3010, 24 | // Chromedriver location is used to help the selenium standalone server 25 | // find chromedriver. This will be passed to the selenium jar as 26 | // the system property webdriver.chrome.driver. If null, selenium will 27 | // attempt to find chromedriver using PATH. 28 | chromeDriver: './selenium/chromedriver', 29 | // If true, only chromedriver will be started, not a standalone selenium. 30 | // Tests for browsers other than chrome will not run. 31 | chromeOnly: false, 32 | // Additional command line options to pass to selenium. For example, 33 | // if you need to change the browser timeout, use 34 | // seleniumArgs: ['-browserTimeout=60'], 35 | seleniumArgs: [], 36 | 37 | // The address of a running selenium server. If specified, Protractor will 38 | // connect to an already running instance of selenium. This usually looks like 39 | // seleniumAddress: 'http://localhost:4444/wd/hub', 40 | seleniumAddress: 'http://ondemand.saucelabs.com/wd/hub', 41 | // If sauceUser and sauceKey are specified, seleniumServerJar will be ignored. 42 | // The tests will be run remotely using SauceLabs. 43 | // sauceUser: 'fasterness', 44 | // sauceKey: '128690e9-57c0-485c-9728-464a08acbf69', 45 | // The timeout for each script run on the browser. This should be longer 46 | // than the maximum time your application needs to stabilize between tasks. 47 | allScriptsTimeout: 30000, 48 | 49 | // ----- What tests to run ----- 50 | // 51 | // Spec patterns are relative to the location of this config. 52 | specs: [ 53 | 'test/protractor/*.spec.js', 54 | '!**/exclude.spec.js' 55 | ], 56 | 57 | // ----- Capabilities to be passed to the webdriver instance ---- 58 | // 59 | // For a full list of available capabilities, see 60 | // https://code.google.com/p/selenium/wiki/DesiredCapabilities 61 | // and 62 | // https://code.google.com/p/selenium/source/browse/javascript/webdriver/capabilities.js 63 | capabilities: { 64 | 'username': process.env['SAUCE_USERNAME'], 65 | 'accessKey':process.env['SAUCE_ACCESS_KEY'], 66 | 'browserName': 'chrome', 67 | // 'browserName': 'firefox' 68 | // 'browserName': 'phantomjs' 69 | 'build': process.env['TRAVIS_BUILD_NUMBER'], 70 | 'tags': ['CI'], 71 | 'tunnel-identifier': process.env['TRAVIS_JOB_NUMBER'], 72 | }, 73 | params: { 74 | 75 | 76 | }, 77 | // ----- More information for your tests ---- 78 | // 79 | // A base URL for your application under test. Calls to protractor.get() 80 | // with relative paths will be prepended with this. 81 | baseUrl: 'http://localhost:3000/', 82 | 83 | 84 | // Options to be passed to Jasmine-node. 85 | jasmineNodeOpts: { 86 | showColors: true, // Use colors in the command line report. 87 | isVerbose: true, // List all tests in the console 88 | includeStackTrace: true, 89 | defaultTimeoutInterval: 90000 90 | 91 | } 92 | }; 93 | -------------------------------------------------------------------------------- /test/protractor_coverage_test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var grunt = require('grunt'); 4 | var protractorCoverage=require('../tasks/protractor_coverage'); 5 | 6 | /* 7 | ======== A Handy Little Nodeunit Reference ======== 8 | https://github.com/caolan/nodeunit 9 | 10 | Test methods: 11 | test.expect(numAssertions) 12 | test.done() 13 | Test assertions: 14 | test.ok(value, [message]) 15 | test.equal(actual, expected, [message]) 16 | test.notEqual(actual, expected, [message]) 17 | test.deepEqual(actual, expected, [message]) 18 | test.notDeepEqual(actual, expected, [message]) 19 | test.strictEqual(actual, expected, [message]) 20 | test.notStrictEqual(actual, expected, [message]) 21 | test.throws(block, [error], [message]) 22 | test.doesNotThrow(block, [error], [message]) 23 | test.ifError(value) 24 | */ 25 | 26 | exports.protractor_coverage = { 27 | setUp: function(done) { 28 | // setup here if necessary 29 | done(); 30 | }, 31 | protractor_coverage: function(test) { 32 | test.done(); 33 | }, 34 | }; 35 | --------------------------------------------------------------------------------