Skip to content

Commit

Permalink
Implement provider
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyBelym committed Feb 20, 2017
1 parent fc5f90f commit a927d56
Show file tree
Hide file tree
Showing 13 changed files with 661 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
@@ -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
86 changes: 86 additions & 0 deletions .eslintrc
@@ -0,0 +1,86 @@
{
"parser": "babel-eslint",
"extends": "eslint:recommended",
"rules": {
"no-alert": "error",
"no-array-constructor": "error",
"no-caller": "error",
"no-catch-shadow": "error",
"no-console": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-implied-eval": "error",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-loop-func": "error",
"no-multi-str": "error",
"no-native-reassign": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-proto": "error",
"no-return-assign": "error",
"no-script-url": "error",
"no-sequences": "error",
"no-shadow": "error",
"no-shadow-restricted-names": "error",
"no-spaced-func": "error",
"no-undef-init": "error",
"no-unused-expressions": "error",
"no-with": "error",
"camelcase": "error",
"comma-spacing": "error",
"consistent-return": "error",
"eqeqeq": "error",
"semi": "error",
"semi-spacing": ["error", {"before": false, "after": true}],
"space-infix-ops": "error",
"space-unary-ops": ["error", { "words": true, "nonwords": false }],
"yoda": ["error", "never"],
"brace-style": ["error", "stroustrup", { "allowSingleLine": false }],
"eol-last": "error",
"indent": ["error", 4, { "SwitchCase": 1 }],
"key-spacing": ["error", { "align": "value" }],
"max-nested-callbacks": ["error", 3],
"new-parens": "error",
"newline-after-var": ["error", "always"],
"no-lonely-if": "error",
"no-multiple-empty-lines": ["error", { "max": 2 }],
"no-nested-ternary": "error",
"no-underscore-dangle": "off",
"no-unneeded-ternary": "error",
"object-curly-spacing": ["error", "always"],
"operator-assignment": ["error", "always"],
"quotes": ["error", "single", "avoid-escape"],
"keyword-spacing" : "error",
"space-before-blocks": ["error", "always"],
"prefer-const": "error",
"no-path-concat": "error",
"no-undefined": "error",
"strict": "off",
"curly": ["error", "multi-or-nest"],
"dot-notation": "off",
"no-else-return": "error",
"one-var": ["error", "never"],
"no-multi-spaces": ["error", {
"exceptions": {
"VariableDeclarator": true,
"AssignmentExpression": true
}
}],
"radix": "error",
"no-extra-parens": "error",
"new-cap": ["error", { "capIsNew": false }],
"space-before-function-paren": ["error", "always"],
"no-use-before-define" : ["error", "nofunc"],
"handle-callback-err": "off"
},
"env": {
"node": true
}
}
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
lib
node_modules
.screenshots
.idea
6 changes: 6 additions & 0 deletions .travis.yml
@@ -0,0 +1,6 @@
language: node_js
node_js:
- stable
- v4
- '0.12'
- '0.10'
84 changes: 84 additions & 0 deletions Gulpfile.js
@@ -0,0 +1,84 @@
var path = require('path');
var gulp = require('gulp');
var babel = require('gulp-babel');
var mocha = require('gulp-mocha');
var sequence = require('gulp-sequence');
var del = require('del');
var nodeVersion = require('node-version');
var execa = require('execa');


var PACKAGE_PARENT_DIR = path.join(__dirname, '../');
var PACKAGE_SEARCH_PATH = (process.env.NODE_PATH ? process.env.NODE_PATH + path.delimiter : '') + PACKAGE_PARENT_DIR;


gulp.task('clean', function () {
return del('lib');
});

gulp.task('lint', function () {
// TODO: eslint supports node version 4 or higher.
// Remove this condition once we get rid of node 0.10 support.
if (nodeVersion.major === '0')
return null;

var eslint = require('gulp-eslint');

return gulp
.src([
'src/**/*.js',
'test/**/*.js',
'Gulpfile.js'
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});

gulp.task('build', ['lint', 'clean'], function () {
return gulp
.src('src/**/*.js')
.pipe(babel())
.pipe(gulp.dest('lib'));
});

gulp.task('test-mocha', ['build'], function () {
if (!process.env.BROWSERSTACK_USERNAME || !process.env.BROWSERSTACK_ACCESS_KEY)
throw new Error('Specify your credentials by using the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables to authenticate to SauceLabs.');

process.env.NODE_PATH = PACKAGE_SEARCH_PATH;

return gulp
.src('test/mocha/**.js')
.pipe(mocha({
ui: 'bdd',
reporter: 'spec',
timeout: typeof v8debug === 'undefined' ? 2000 : Infinity // NOTE: disable timeouts in debug
}));
});

gulp.task('test-testcafe', ['build'], function () {
if (!process.env.BROWSERSTACK_USERNAME || !process.env.BROWSERSTACK_ACCESS_KEY)
throw new Error('Specify your credentials by using the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables to authenticate to SauceLabs.');

var testCafeCmd = path.join(__dirname, 'node_modules/.bin/testcafe');

var testCafeOpts = [
'browserstack:chrome',
'test/testcafe/**/*.js',
'-s', '.screenshots'
];

// NOTE: we must add the parent of plugin directory to NODE_PATH, otherwise testcafe will not be able
// to find the plugin. So this function starts testcafe with proper NODE_PATH.
process.env.NODE_PATH = PACKAGE_SEARCH_PATH;

var child = execa(testCafeCmd, testCafeOpts);

child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);

return child;
});

gulp.task('test', sequence('test-mocha', 'test-testcafe'));
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2017 Developer Express Inc.

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.
38 changes: 38 additions & 0 deletions README.md
@@ -0,0 +1,38 @@
# testcafe-browser-provider-browserstack
[![Build Status](https://travis-ci.org/DevExpress/testcafe-browser-provider-browserstack.svg)](https://travis-ci.org/DevExpress/testcafe-browser-provider-browserstack)

This is the [TestCafe](http://devexpress.github.io/testcafe) browser provider plugin for the integration with the [BrowserStack Testing Cloud](https://browserstack.com/).

## Install

```
npm install testcafe-browser-provider-browserstack
```

## Usage
Before using the provider, save the BrowserStack username and access key to environment variables `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY`.

You can determine the available browser aliases by running
```
testcafe -b browserstack
```

When you run tests from the command line, use the alias when specifying browsers:

```
testcafe "browserstack:Chrome@53.0:Windows 10" "path/to/test/file.js"
```


When you use API, pass the alias to the `browsers()` method:

```js
testCafe
.createRunner()
.src('path/to/test/file.js')
.browsers('browserstack:Chrome@53.0:Windows 10')
.run();
```

## Author
Developer Express Inc. (https://devexpress.com)
57 changes: 57 additions & 0 deletions package.json
@@ -0,0 +1,57 @@
{
"name": "testcafe-browser-provider-browserstack",
"version": "1.0.0",
"description": "browserstack TestCafe browser provider plugin.",
"repository": "https://github.com/DevExpress/testcafe-browser-provider-browserstack",
"homepage": "https://github.com/DevExpress/testcafe-browser-provider-browserstack",
"author": {
"name": "Andrey Belym",
"email": "belym.a.2105@gmail.com",
"url": "https://github.com/DevExpress/testcafe-browser-provider-browserstack"
},
"main": "lib/index",
"files": [
"lib"
],
"scripts": {
"test": "gulp test",
"publish-please": "publish-please",
"prepublish": "publish-please guard"
},
"keywords": [
"testcafe",
"browser provider",
"plugin"
],
"license": "MIT",
"dependencies": {
"babel-runtime": "^6.11.6",
"browserstack-local": "^1.3.0",
"desired-capabilities": "^0.1.0",
"jimp": "^0.2.27",
"pinkie": "^2.0.4",
"request": "^2.79.0",
"request-promise": "^4.1.1",
"stream-to": "^2.0.0"
},
"devDependencies": {
"babel-eslint": "^6.1.2",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-runtime": "^6.12.0",
"babel-preset-es2015": "^6.13.2",
"babel-preset-es2015-loose": "^7.0.0",
"babel-preset-stage-3": "^6.11.0",
"chai": "^3.5.0",
"del": "^2.2.2",
"execa": "^0.4.0",
"gulp": "^3.9.0",
"gulp-babel": "^6.1.2",
"gulp-eslint": "^3.0.1",
"gulp-mocha": "^3.0.1",
"gulp-sequence": "^0.4.6",
"node-version": "^1.0.0",
"publish-please": "^2.1.4",
"testcafe": "^0.13.0",
"tmp": "0.0.31"
}
}
11 changes: 11 additions & 0 deletions src/.babelrc
@@ -0,0 +1,11 @@
{
"compact": false,
"presets": [
"es2015-loose",
"babel-preset-stage-3"
],
"plugins": [
"transform-runtime",
"add-module-exports"
]
}

0 comments on commit a927d56

Please sign in to comment.