Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify semantics and usage of copying and script inclusion #16

Closed
wants to merge 9 commits into from
15 changes: 13 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,20 @@ module.exports = function (grunt) {
},
jasmine_chromeapp: {
selftest: {
src: 'test/*.js',
files: [ { src: ['test/*.js'] } ],
scripts: ['test/selftest.js'],
options: {
paths: 'test/selftest.js'
outDir: '.build/self-test1/'
}
},
selftest2: {
files: [
{ cwd: 'test', src: ['selftest.js'] },
{ src: ['test/helper.js'], dest: 'test/helper.js' }
],
scripts: ['selftest.js'],
options: {
outDir: '.build/self-test2/'
}
}
}
Expand Down
70 changes: 48 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

[![Build Status](https://api.shippable.com/projects/54d3c81a5ab6cc13528afac2/badge?branchName=master)](https://app.shippable.com/projects/54d3c81a5ab6cc13528afac2/builds/latest)

Getting Started
---------------
## Getting Started

This plugin requires Grunt ```~0.4.0```

Expand All @@ -21,36 +20,69 @@ Once the plugin has been installed, it may be enabled with this line of JavaScri
grunt.loadNpmTasks('grunt-jasmine-chromeapp');
```

Jasmine Task
------------
## The Jasmine ChromeApp Task

Run this task with the ```grunt jasmine_chromeapp``` command.

Automatically builds and maintains the spec runner and reports results back to the grunt console.
This automatically builds and maintains the spec runner and reports results back to the grunt console.
Starts chrome with a dynamically created packaged application which runs jasmine specs. The package
reports results back to a web server run by the plugin, which then reports back to the console.
This structure is chosen becasue selenium is unable to debug or instrument packaged applications
directly.

Customize your SpecRunner
-------------------------
### Example specification of the jasmine-chromeapp task

Use your own files in the app to customize your tests.
An example `jasmine_chromeapp` task defined in your Gruntfiles.js
```
jasmine_chromeapp:
tcp:
# Files that are copied into the Chrome App 'files' subdirectory.
files: [
{
cwd: 'build/integration-tests/tcp/',
src: ['**/*', '!jasmine_chromeapp/**/*'],
dest: './', # Relative to |options.outdir| specified below
expand: true
}
],
# Script tags that are added to the HTML in the chrome app's main.html
scripts: [
'freedom-for-chrome/freedom-for-chrome.js',
'tcp.core-env.spec.static.js'
],
# Optional settings for the output path, and to keep the spec runner
# alive after tests complete, which can be useful for debugging.
options: {
outdir: 'build/integration-tests/tcp/jasmine_chromeapp/',
keepRunner: true
}
```

## Customize your SpecRunner

Use your own files in the app to customize your tests.

### Options

#### src
Type: `String|Array`
#### files

Type: `{ cwd :string; src :string[]; dest :string; expand :boolean}[]`

Your source files and specs. These are the files you are testing.
This specifies the files copied into the ChromeApp that is used to run the jasmine tests. It has the same parameters as the [grunt-contrib-copy](https://github.com/gruntjs/grunt-contrib-copy) task.

#### options.paths
Type: `String|Array`
Files of the form `cwd/src/*` get copied to `dest/files/src/*` if `expand` is true. If expand is false, they get copied to `dest/*`.

Listing of which files should be included as script tags in the test runner. If not set, defaults
to all files listed as source files, but can define a subset of those files to support copying
non-js files, or other support files which should not be directly included.
#### scripts

Type: `string[]`

This specifies the additional paths for `<script ... >` tags which get added to the `main.html`. This should include your JS spec files. The ordering of the script tags in the HTML follows the ordering specified in this parameter.

#### options.outDir
Type: `string`
Default: `.build`

The directory to stage the chrome app into. To debug bad paths, it is useful to have the `keepRunner` option set to true, and then explore path structure in `outDir`.

#### options.keepRunner
Type: `Boolean`
Expand Down Expand Up @@ -80,9 +112,3 @@ Type: `Number`
Default: `30000`

How many milliseconds to wait for the browser to start up before failing.

#### options.outfile
Type: `String`
Default: `.build`

The directory to stage the chrome app into.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "grunt-jasmine-chromeapp",
"version": "1.8.0",
"version": "2.0.0",
"description": "Grunt task to run jasmine tests in a chrome packaged app",
"scripts": {
"test": "grunt test"
Expand Down Expand Up @@ -31,7 +31,8 @@
"chalk": "^0.5.1",
"fs-extra": "^0.16.0",
"glob": "^4.4.0",
"node-chrome-runner": "^0.0.5"
"node-chrome-runner": "^0.0.5",
"file-sync-cmp": "^0.1.1"
},
"peerDependencies": {
"grunt": "~0.4.0"
Expand Down
Loading