1 | # grunt-blueprint-test-runner
|
2 |
|
3 | [![npm version](https://badge.fury.io/js/grunt-blueprint-test-runner.svg)](http://badge.fury.io/js/grunt-blueprint-test-runner) [![Build Status](https://travis-ci.org/Aconex/grunt-blueprint-test-runner.svg)](https://travis-ci.org/Aconex/grunt-blueprint-test-runner)
|
4 |
|
5 | > API Blueprint and Protractor Test Runner.
|
6 |
|
7 | A Grunt plugin for running Angular.js functional tests combining [Drakov](https://github.com/Aconex/drakov) and [Protractor](https://github.com/angular/protractor).
|
8 |
|
9 |
|
10 | ## Getting Started
|
11 | This plugin requires Grunt `~0.4.5`
|
12 |
|
13 | ```shell
|
14 | npm install grunt-blueprint-test-runner --save-dev
|
15 | ```
|
16 |
|
17 | Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
|
18 |
|
19 | ```js
|
20 | grunt.loadNpmTasks('grunt-blueprint-test-runner');
|
21 | ```
|
22 |
|
23 | ## The "blueprint_test_runner" task
|
24 |
|
25 | ### Overview
|
26 | In your project's Gruntfile, add a section named `blueprint-test-runner` to the data object passed into `grunt.initConfig()`.
|
27 |
|
28 | ```js
|
29 | grunt.initConfig({
|
30 | blueprint_test_runner: {
|
31 | your_target: {
|
32 | drakov: {
|
33 | sourceFiles: 'path/to/blueprint/files/**/*.md',
|
34 | serverPort: 3000,
|
35 | staticPaths: 'path/to/static/files'
|
36 | },
|
37 | protractor: {
|
38 | suites: {
|
39 | test-suite1: 'path/to/specs/**.js'
|
40 | }
|
41 | }
|
42 | }
|
43 | }
|
44 | });
|
45 | ```
|
46 |
|
47 | **NOTE:** The plugin defaults to running the tests with selenium + phantomjs. *See example below to run with chromedriver.*
|
48 |
|
49 | ### Usage Examples
|
50 |
|
51 | #### Default Options
|
52 | This is an example of a minimum configuration config.
|
53 |
|
54 | The `sourceFiles` property is required in the `drakov` object below. `suites` is also required to have entries like the example below.
|
55 |
|
56 | ```js
|
57 | grunt.initConfig({
|
58 | blueprint_test_runner: {
|
59 | your_target: {
|
60 | drakov: {
|
61 | sourceFiles: 'path/to/blueprint/files/**/*.md',
|
62 | },
|
63 | protractor: {
|
64 | suites: {
|
65 | test-suite1: 'path/to/specs/**.js'
|
66 | }
|
67 | }
|
68 | }
|
69 | }
|
70 | });
|
71 | ```
|
72 |
|
73 |
|
74 | #### Specifying browserName when running with Selenium standalone
|
75 |
|
76 | You can specify the browser to run with Selenenium, simply add `browserName: <browser>` inside your target properties.
|
77 |
|
78 | ```js
|
79 | grunt.initConfig({
|
80 | blueprint_test_runner: {
|
81 | your_target: {
|
82 | browserName: 'firefox',
|
83 | ...
|
84 | }
|
85 | }
|
86 | });
|
87 | ```
|
88 |
|
89 |
|
90 | #### Running with the chromedriver
|
91 | This is an example of a minimum configuration config.
|
92 |
|
93 | Instead of running with selenium and phantomjs, simply add `chromeDriver: true` inside your target properties.
|
94 |
|
95 | ```js
|
96 | grunt.initConfig({
|
97 | blueprint_test_runner: {
|
98 | your_target: {
|
99 | chromeDriver: true,
|
100 | drakov: {
|
101 | sourceFiles: 'path/to/blueprint/files/**/*.md',
|
102 | },
|
103 | protractor: {
|
104 | suites: {
|
105 | test-suite1: 'path/to/specs/**.js'
|
106 | }
|
107 | }
|
108 | }
|
109 | }
|
110 | });
|
111 | ```
|
112 |
|
113 | #### Configuration to run protractor tests without Drakov
|
114 | In case you wish to execute protractor tests without Drakov running simple leave out the `drakov` property
|
115 |
|
116 |
|
117 |
|
118 | #### Configuration with additional protractor properties
|
119 | There are some defaults configured for running protractor. You can as a minimum just include `specs` or `suites`.
|
120 |
|
121 | If you require additions to the protractor configuration, these are passed directly from the `protractor` property in your target configuration.
|
122 |
|
123 | See
|
124 |
|
125 | ```js
|
126 | grunt.initConfig({
|
127 | blueprint_test_runner: {
|
128 | your_target: {
|
129 | drakov: {
|
130 | sourceFiles: 'path/to/blueprint/files/**/*.md',
|
131 | serverPort: 3000,
|
132 | staticPaths: 'path/to/static/files'
|
133 | },
|
134 | protractor: {
|
135 | specs: [
|
136 | 'path/to/some/specs/**/*.js'
|
137 | ]
|
138 | params: {
|
139 | foo: function() {
|
140 | return 'bar';
|
141 | }
|
142 | }
|
143 | }
|
144 | }
|
145 | }
|
146 | });
|
147 | ```
|
148 |
|
149 |
|
150 | #### Configuration with additional Drakov properties
|
151 | This is an example of all the extra properties for Drakov including server port and a basic static route.
|
152 |
|
153 | The `sourceFiles` property is required in the `drakov` object below.
|
154 |
|
155 | ```js
|
156 | grunt.initConfig({
|
157 | blueprint_test_runner: {
|
158 | your_target: {
|
159 | drakov: {
|
160 | sourceFiles: 'path/to/blueprint/files/**/*.md',
|
161 | serverPort: 3000,
|
162 | staticPaths: 'path/to/static/files'
|
163 | },
|
164 | protractor: {
|
165 | suites: {
|
166 | test-suite1: 'path/to/specs/**.js'
|
167 | }
|
168 | }
|
169 | }
|
170 | }
|
171 | });
|
172 | ```
|
173 |
|
174 | `staticPaths` can also take a path with a mount point, i.e. `staticPaths: 'path/to/static/files=/url/mnt'`. This will mount the files at the url base path of `/url/mnt`.
|
175 |
|
176 | You can also provide multiple paths/mounts by substituting the value with an array.
|
177 |
|
178 | For example:
|
179 | ```js
|
180 | ...
|
181 | staticPaths: [
|
182 | 'path/to/static/files',
|
183 | 'another/path/to/static/files=/mnt/me/here'
|
184 | ]
|
185 | ...
|
186 | ```
|