├── .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 | [](https://travis-ci.org/r3b/grunt-protractor-coverage)
3 | [](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 |