-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
677 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.idea | ||
node_modules | ||
test/temp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,85 @@ | ||
'use strict'; | ||
var yeoman = require('yeoman-generator'); | ||
var chalk = require('chalk'); | ||
var yosay = require('yosay'); | ||
var yeoman = require('yeoman-generator'); | ||
var slugify = require('underscore.string').slugify; | ||
var normalizeUrl = require('normalize-url'); | ||
|
||
function filterProjectName (name) { | ||
return slugify(name.replace(/^testcafe(-|\s)reporter(-|\s)/i, '')); | ||
} | ||
|
||
module.exports = yeoman.generators.Base.extend({ | ||
prompting: function () { | ||
var done = this.async(); | ||
var gen = this; | ||
|
||
this.log(yosay( | ||
'Welcome to the astounding ' + chalk.red('generator-testcafe-reporter') + ' generator!' | ||
)); | ||
|
||
var prompts = [{ | ||
type: 'confirm', | ||
name: 'someOption', | ||
message: 'Would you like to enable this option?', | ||
default: true | ||
}]; | ||
var prompts = [ | ||
{ | ||
name: 'reporterName', | ||
message: 'How do you want to name your reporter?', | ||
default: filterProjectName(this.appname), | ||
filter: filterProjectName | ||
}, | ||
{ | ||
name: 'githubUsername', | ||
message: 'What is your GitHub username?', | ||
store: true, | ||
validate: function (name) { | ||
return name.length ? true : 'You should provide a username'; | ||
} | ||
}, | ||
{ | ||
name: 'website', | ||
message: 'What is the URL of your website?', | ||
store: true, | ||
filter: function (url) { | ||
return url && normalizeUrl(url); | ||
} | ||
}, | ||
{ | ||
name: 'errorDecorator', | ||
message: 'Do you want to implement custom error decorator?', | ||
type: 'confirm', | ||
default: false | ||
} | ||
]; | ||
|
||
this.prompt(prompts, function (props) { | ||
this.props = props; | ||
// To access props later use this.props.someOption; | ||
gen.props = props; | ||
|
||
done(); | ||
}.bind(this)); | ||
}); | ||
}, | ||
|
||
writing: function () { | ||
this.fs.copy( | ||
this.templatePath('dummyfile.txt'), | ||
this.destinationPath('dummyfile.txt') | ||
); | ||
var gen = this; | ||
|
||
var tmplProps = { | ||
author: this.user.git.name(), | ||
email: this.user.git.email(), | ||
website: this.props.website, | ||
reporterName: this.props.reporterName, | ||
githubUsername: this.props.githubUsername, | ||
errorDecorator: this.props.errorDecorator | ||
}; | ||
|
||
var unescaped = { | ||
'_.editorconfig': '.editorconfig', | ||
'_.eslintrc': '.eslintrc', | ||
'_.gitignore': '.gitignore', | ||
'test/_.eslintrc': 'test/.eslintrc', | ||
'_.travis.yml': '.travis.yml', | ||
'_package.json': 'package.json' | ||
}; | ||
|
||
this.fs.copyTpl(this.templatePath() + '/**/!(*.png)', this.destinationPath(), tmplProps); | ||
this.fs.copy(this.templatePath() + '/**/*.png', this.destinationPath()); | ||
|
||
Object.keys(unescaped).forEach(function (escaped) { | ||
gen.fs.move(gen.destinationPath(escaped), gen.destinationPath(unescaped[escaped])); | ||
}); | ||
}, | ||
|
||
install: function () { | ||
this.installDependencies(); | ||
this.installDependencies({ bower: false }); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
var gulp = require('gulp'); | ||
var eslint = require('gulp-eslint'); | ||
var babel = require('gulp-babel'); | ||
var mocha = require('gulp-mocha'); | ||
var del = require('del'); | ||
var publish = require('publish-please'); | ||
|
||
gulp.task('clean', function (cb) { | ||
del('lib', cb); | ||
}); | ||
|
||
gulp.task('lint', function () { | ||
return gulp | ||
.src([ | ||
'src/**/*.js', | ||
'test/**/*.js', | ||
'Gulpfile.js' | ||
]) | ||
.pipe(eslint()) | ||
.pipe(eslint.format()) | ||
.pipe(eslint.failAfterError()); | ||
}); | ||
|
||
gulp.task('build', ['clean', 'lint'], function () { | ||
return gulp | ||
.src('src/**/*.js') | ||
.pipe(babel()) | ||
.pipe(gulp.dest('lib')); | ||
}); | ||
|
||
gulp.task('test', ['build'], function () { | ||
return gulp | ||
.src('test/**.js') | ||
.pipe(mocha({ | ||
ui: 'bdd', | ||
reporter: 'spec', | ||
timeout: typeof v8debug === 'undefined' ? 2000 : Infinity // NOTE: disable timeouts in debug | ||
})); | ||
}); | ||
|
||
gulp.task('preview', ['build'], function () { | ||
var pluginTestingUtils = require('testcafe').pluginTestingUtils; | ||
var pluginFactory = require('./lib'); | ||
var testCalls = require('./test/data/test-calls'); | ||
var plugin = pluginTestingUtils.buildReporterPlugin(pluginFactory); | ||
|
||
console.log(); | ||
|
||
testCalls.forEach(function (call) { | ||
plugin[call.method].apply(plugin, call.args); | ||
}); | ||
|
||
process.exit(0); | ||
}); | ||
|
||
gulp.task('publish', ['test'], function () { | ||
return publish(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) <%= author %> <<%= email %>> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# testcafe-reporter-<%= reporterName %> | ||
[](https://travis-ci.org/<%= githubUsername %>/testcafe-reporter-<%= reporterName %>) | ||
|
||
This is the **<%= reporterName %>** reporter plugin for [TestCafe](http://devexpress.github.io/testcafe). | ||
|
||
<p align="center"> | ||
<img src="https://raw.github.com/<%= githubUsername %>/testcafe-reporter-<%= reporterName %>/master/media/preview.png" alt="preview" /> | ||
</p> | ||
|
||
## Install | ||
|
||
``` | ||
npm install -g testcafe-reporter-<%= reporterName %> | ||
``` | ||
|
||
## Usage | ||
|
||
When you run tests from the command line, specify the reporter name by using the `--reporter` option: | ||
|
||
``` | ||
testcafe chrome 'path/to/test/file.js' --reporter <%= reporterName %> | ||
``` | ||
|
||
|
||
When you use API, pass the reporter name to the `reporter()` method: | ||
|
||
```js | ||
testCafe | ||
.createRunner() | ||
.src('path/to/test/file.js') | ||
.browsers('chrome') | ||
.reporter('<%= reporterName %>') // <- | ||
.run(); | ||
``` | ||
|
||
## Author | ||
<%= author %> <% if (website) { %>(<%= website %>)<% } %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# This file is for unifying the coding style for different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
charset = utf-8 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[{.eslintrc,*.json,.travis.yml}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{ | ||
"parser": "babel-eslint", | ||
"extends": "eslint:recommended", | ||
"rules": { | ||
"no-alert": 2, | ||
"no-array-constructor": 2, | ||
"no-caller": 2, | ||
"no-catch-shadow": 2, | ||
"no-console": 0, | ||
"no-empty-label": 2, | ||
"no-eval": 2, | ||
"no-extend-native": 2, | ||
"no-extra-bind": 2, | ||
"no-implied-eval": 2, | ||
"no-iterator": 2, | ||
"no-label-var": 2, | ||
"no-labels": 2, | ||
"no-lone-blocks": 2, | ||
"no-loop-func": 2, | ||
"no-multi-str": 2, | ||
"no-native-reassign": 2, | ||
"no-new": 2, | ||
"no-new-func": 2, | ||
"no-new-object": 2, | ||
"no-new-wrappers": 2, | ||
"no-octal-escape": 2, | ||
"no-proto": 2, | ||
"no-return-assign": 2, | ||
"no-script-url": 2, | ||
"no-sequences": 2, | ||
"no-shadow": 2, | ||
"no-shadow-restricted-names": 2, | ||
"no-spaced-func": 2, | ||
"no-undef-init": 2, | ||
"no-unused-expressions": 2, | ||
"no-with": 2, | ||
"camelcase": 2, | ||
"comma-spacing": 2, | ||
"consistent-return": 2, | ||
"eqeqeq": 2, | ||
"semi": 2, | ||
"semi-spacing": [2, {"before": false, "after": true}], | ||
"space-infix-ops": 2, | ||
"space-return-throw-case": 2, | ||
"space-unary-ops": [2, { "words": true, "nonwords": false }], | ||
"yoda": [2, "never"], | ||
"brace-style": [2, "stroustrup", { "allowSingleLine": false }], | ||
"eol-last": 2, | ||
"indent": 2, | ||
"key-spacing": [2, { "align": "value" }], | ||
"max-nested-callbacks": [2, 3], | ||
"new-parens": 2, | ||
"newline-after-var": [2, "always"], | ||
"no-lonely-if": 2, | ||
"no-multiple-empty-lines": [2, { "max": 2 }], | ||
"no-nested-ternary": 2, | ||
"no-underscore-dangle": 0, | ||
"no-unneeded-ternary": 2, | ||
"object-curly-spacing": [2, "always"], | ||
"operator-assignment": [2, "always"], | ||
"quotes": [2, "single", "avoid-escape"], | ||
"space-after-keywords": [2, "always"], | ||
"space-before-blocks": [2, "always"], | ||
"prefer-const": 2, | ||
"no-path-concat": 2, | ||
"no-undefined": 2, | ||
"strict": 0, | ||
"curly": [2, "multi-or-nest"], | ||
"dot-notation": 0, | ||
"no-else-return": 2, | ||
"one-var": [2, "never"], | ||
"no-multi-spaces": [2, { | ||
"exceptions": { | ||
"VariableDeclarator": true, | ||
"AssignmentExpression": true | ||
} | ||
}], | ||
"radix": 2, | ||
"no-extra-parens": 2, | ||
"new-cap": [2, { "capIsNew": false }], | ||
"space-before-function-paren": [2, "always"], | ||
"no-use-before-define" : [2, "nofunc"], | ||
"handle-callback-err": 0 | ||
}, | ||
"env": { | ||
"node": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
lib | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
language: node_js | ||
node_js: | ||
- stable | ||
- v4 | ||
- '0.12' | ||
- '0.10' |
Oops, something went wrong.