Skip to content

Commit 73bdfcc

Browse files
authored
Merge pull request #1 from AndreyBelym/implement-provider
Implement provider
2 parents fc5f90f + 8c1c7cc commit 73bdfcc

13 files changed

Lines changed: 695 additions & 0 deletions

File tree

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This file is for unifying the coding style for different editors and IDEs
2+
# editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
end_of_line = lf
8+
charset = utf-8
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
indent_style = space
12+
indent_size = 4
13+
14+
[{.eslintrc,*.json,.travis.yml}]
15+
indent_size = 2

.eslintrc

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"parser": "babel-eslint",
3+
"extends": "eslint:recommended",
4+
"rules": {
5+
"no-alert": "error",
6+
"no-array-constructor": "error",
7+
"no-caller": "error",
8+
"no-catch-shadow": "error",
9+
"no-console": "error",
10+
"no-eval": "error",
11+
"no-extend-native": "error",
12+
"no-extra-bind": "error",
13+
"no-implied-eval": "error",
14+
"no-iterator": "error",
15+
"no-label-var": "error",
16+
"no-labels": "error",
17+
"no-lone-blocks": "error",
18+
"no-loop-func": "error",
19+
"no-multi-str": "error",
20+
"no-native-reassign": "error",
21+
"no-new": "error",
22+
"no-new-func": "error",
23+
"no-new-object": "error",
24+
"no-new-wrappers": "error",
25+
"no-octal-escape": "error",
26+
"no-proto": "error",
27+
"no-return-assign": "error",
28+
"no-script-url": "error",
29+
"no-sequences": "error",
30+
"no-shadow": "error",
31+
"no-shadow-restricted-names": "error",
32+
"no-spaced-func": "error",
33+
"no-undef-init": "error",
34+
"no-unused-expressions": "error",
35+
"no-with": "error",
36+
"camelcase": "error",
37+
"comma-spacing": "error",
38+
"consistent-return": "error",
39+
"eqeqeq": "error",
40+
"semi": "error",
41+
"semi-spacing": ["error", {"before": false, "after": true}],
42+
"space-infix-ops": "error",
43+
"space-unary-ops": ["error", { "words": true, "nonwords": false }],
44+
"yoda": ["error", "never"],
45+
"brace-style": ["error", "stroustrup", { "allowSingleLine": false }],
46+
"eol-last": "error",
47+
"indent": ["error", 4, { "SwitchCase": 1 }],
48+
"key-spacing": ["error", { "align": "value" }],
49+
"max-nested-callbacks": ["error", 3],
50+
"new-parens": "error",
51+
"newline-after-var": ["error", "always"],
52+
"no-lonely-if": "error",
53+
"no-multiple-empty-lines": ["error", { "max": 2 }],
54+
"no-nested-ternary": "error",
55+
"no-underscore-dangle": "off",
56+
"no-unneeded-ternary": "error",
57+
"object-curly-spacing": ["error", "always"],
58+
"operator-assignment": ["error", "always"],
59+
"quotes": ["error", "single", "avoid-escape"],
60+
"keyword-spacing" : "error",
61+
"space-before-blocks": ["error", "always"],
62+
"prefer-const": "error",
63+
"no-path-concat": "error",
64+
"no-undefined": "error",
65+
"strict": "off",
66+
"curly": ["error", "multi-or-nest"],
67+
"dot-notation": "off",
68+
"no-else-return": "error",
69+
"one-var": ["error", "never"],
70+
"no-multi-spaces": ["error", {
71+
"exceptions": {
72+
"VariableDeclarator": true,
73+
"AssignmentExpression": true
74+
}
75+
}],
76+
"radix": "error",
77+
"no-extra-parens": "error",
78+
"new-cap": ["error", { "capIsNew": false }],
79+
"space-before-function-paren": ["error", "always"],
80+
"no-use-before-define" : ["error", "nofunc"],
81+
"handle-callback-err": "off"
82+
},
83+
"env": {
84+
"node": true
85+
}
86+
}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
lib
2+
node_modules
3+
.screenshots
4+
.idea

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
language: node_js
2+
node_js:
3+
- stable
4+
- '0.10'

Gulpfile.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
var path = require('path');
2+
var gulp = require('gulp');
3+
var babel = require('gulp-babel');
4+
var mocha = require('gulp-mocha');
5+
var sequence = require('gulp-sequence');
6+
var del = require('del');
7+
var nodeVersion = require('node-version');
8+
var execa = require('execa');
9+
10+
11+
var PACKAGE_PARENT_DIR = path.join(__dirname, '../');
12+
var PACKAGE_SEARCH_PATH = (process.env.NODE_PATH ? process.env.NODE_PATH + path.delimiter : '') + PACKAGE_PARENT_DIR;
13+
14+
15+
gulp.task('clean', function () {
16+
return del('lib');
17+
});
18+
19+
gulp.task('lint', function () {
20+
// TODO: eslint supports node version 4 or higher.
21+
// Remove this condition once we get rid of node 0.10 support.
22+
if (nodeVersion.major === '0')
23+
return null;
24+
25+
var eslint = require('gulp-eslint');
26+
27+
return gulp
28+
.src([
29+
'src/**/*.js',
30+
'test/**/*.js',
31+
'Gulpfile.js'
32+
])
33+
.pipe(eslint())
34+
.pipe(eslint.format())
35+
.pipe(eslint.failAfterError());
36+
});
37+
38+
gulp.task('build', ['lint', 'clean'], function () {
39+
return gulp
40+
.src('src/**/*.js')
41+
.pipe(babel())
42+
.pipe(gulp.dest('lib'));
43+
});
44+
45+
gulp.task('test-mocha', ['build'], function () {
46+
if (!process.env.BROWSERSTACK_USERNAME || !process.env.BROWSERSTACK_ACCESS_KEY)
47+
throw new Error('Specify your credentials by using the BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY environment variables to authenticate to BrowserStack.');
48+
49+
process.env.NODE_PATH = PACKAGE_SEARCH_PATH;
50+
51+
return gulp
52+
.src('test/mocha/**.js')
53+
.pipe(mocha({
54+
ui: 'bdd',
55+
reporter: 'spec',
56+
timeout: typeof v8debug === 'undefined' ? 2000 : Infinity // NOTE: disable timeouts in debug
57+
}));
58+
});
59+
60+
gulp.task('test-testcafe', ['build'], function () {
61+
if (!process.env.BROWSERSTACK_USERNAME || !process.env.BROWSERSTACK_ACCESS_KEY)
62+
throw new Error('Specify your credentials by using the BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY environment variables to authenticate to BrowserStack.');
63+
64+
var testCafeCmd = path.join(__dirname, 'node_modules/.bin/testcafe');
65+
66+
var testCafeOpts = [
67+
'browserstack:chrome',
68+
'test/testcafe/**/*.js',
69+
'-s', '.screenshots'
70+
];
71+
72+
// NOTE: we must add the parent of plugin directory to NODE_PATH, otherwise testcafe will not be able
73+
// to find the plugin. So this function starts testcafe with proper NODE_PATH.
74+
process.env.NODE_PATH = PACKAGE_SEARCH_PATH;
75+
76+
var child = execa(testCafeCmd, testCafeOpts);
77+
78+
child.stdout.pipe(process.stdout);
79+
child.stderr.pipe(process.stderr);
80+
81+
return child;
82+
});
83+
84+
gulp.task('test', sequence('test-mocha', 'test-testcafe'));

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 Developer Express Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# testcafe-browser-provider-browserstack
2+
[![Build Status](https://travis-ci.org/DevExpress/testcafe-browser-provider-browserstack.svg)](https://travis-ci.org/DevExpress/testcafe-browser-provider-browserstack)
3+
4+
This plugin integrates [TestCafe](http://devexpress.github.io/testcafe) with the [BrowserStack Testing Cloud](https://browserstack.com/).
5+
6+
## Install
7+
8+
```
9+
npm install testcafe-browser-provider-browserstack
10+
```
11+
12+
## Usage
13+
Before using this plugin, save the BrowserStack username and access key to environment variables `BROWSERSTACK_USERNAME` and `BROWSERSTACK_ACCESS_KEY`.
14+
15+
You can determine the available browser aliases by running
16+
```
17+
testcafe -b browserstack
18+
```
19+
20+
If you run tests from the command line, use the alias when specifying browsers:
21+
22+
```
23+
testcafe "browserstack:Chrome@53.0:Windows 10" "path/to/test/file.js"
24+
```
25+
26+
27+
When you use API, pass the alias to the `browsers()` method:
28+
29+
```js
30+
testCafe
31+
.createRunner()
32+
.src('path/to/test/file.js')
33+
.browsers('browserstack:Chrome@53.0:Windows 10')
34+
.run();
35+
```
36+
37+
Tip: you can skip version (`@53.0`) or/and OS name (`:Windows 10`).
38+
39+
## Author
40+
Developer Express Inc. (https://devexpress.com)

package.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"name": "testcafe-browser-provider-browserstack",
3+
"version": "0.0.1",
4+
"description": "browserstack TestCafe browser provider plugin.",
5+
"repository": "https://github.com/DevExpress/testcafe-browser-provider-browserstack",
6+
"homepage": "https://github.com/DevExpress/testcafe-browser-provider-browserstack",
7+
"author": {
8+
"name": "Andrey Belym",
9+
"email": "belym.a.2105@gmail.com",
10+
"url": "https://github.com/DevExpress/testcafe-browser-provider-browserstack"
11+
},
12+
"main": "lib/index",
13+
"files": [
14+
"lib"
15+
],
16+
"scripts": {
17+
"test": "gulp test",
18+
"publish-please": "publish-please",
19+
"prepublish": "publish-please guard"
20+
},
21+
"keywords": [
22+
"testcafe",
23+
"browser provider",
24+
"plugin",
25+
"browserstack"
26+
],
27+
"license": "MIT",
28+
"dependencies": {
29+
"babel-runtime": "^6.11.6",
30+
"browserstack-local": "^1.3.0",
31+
"desired-capabilities": "^0.1.0",
32+
"jimp": "^0.2.27",
33+
"os-family": "^1.0.0",
34+
"pinkie": "^2.0.4",
35+
"request": "^2.79.0",
36+
"request-promise": "^4.1.1"
37+
},
38+
"devDependencies": {
39+
"babel-eslint": "^6.1.2",
40+
"babel-plugin-add-module-exports": "^0.2.1",
41+
"babel-plugin-transform-runtime": "^6.12.0",
42+
"babel-preset-es2015": "^6.13.2",
43+
"babel-preset-es2015-loose": "^7.0.0",
44+
"babel-preset-stage-3": "^6.11.0",
45+
"chai": "^3.5.0",
46+
"del": "^2.2.2",
47+
"execa": "^0.4.0",
48+
"gulp": "^3.9.0",
49+
"gulp-babel": "^6.1.2",
50+
"gulp-eslint": "^3.0.1",
51+
"gulp-mocha": "^3.0.1",
52+
"gulp-sequence": "^0.4.6",
53+
"node-version": "^1.0.0",
54+
"publish-please": "^2.1.4",
55+
"testcafe": "^0.13.0",
56+
"tmp": "0.0.31"
57+
}
58+
}

src/.babelrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compact": false,
3+
"presets": [
4+
"es2015-loose",
5+
"babel-preset-stage-3"
6+
],
7+
"plugins": [
8+
"transform-runtime",
9+
"add-module-exports"
10+
]
11+
}

0 commit comments

Comments
 (0)