-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit d51bba0
Showing
12 changed files
with
5,269 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = 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,4 @@ | ||
.DS_Store | ||
coverage | ||
node_modules | ||
npm-debug.log |
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,17 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "grunt", | ||
"program": "${workspaceFolder}/node_modules/grunt/bin/grunt", | ||
"args": [ | ||
"--verbose" | ||
] | ||
} | ||
] | ||
} |
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,8 @@ | ||
// Place your settings in this file to overwrite default and user settings. | ||
{ | ||
"files.exclude": { | ||
"coverage": true, | ||
"node_modules": true, | ||
"npm-debug.log": 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,70 @@ | ||
module.exports = function (grunt) { | ||
const coverage = grunt.option('coverage') | ||
const alternativePort = '9517' | ||
|
||
grunt.initConfig({ | ||
safaridriver: { | ||
quiet: {}, | ||
verbose: { verbose: true, args: [`--port=${alternativePort}`] }, | ||
otherPort: { port: +alternativePort, findAvailablePort: true }, | ||
fail: { args: ['--invalid'] } | ||
}, | ||
|
||
standard: { | ||
all: { | ||
src: [ | ||
'Gruntfile.js', | ||
'tasks/**/*.js', | ||
'<%= nodeunit.started %>', | ||
'<%= nodeunit.stopped %>' | ||
] | ||
} | ||
}, | ||
|
||
instrument: { | ||
files: 'tasks/**/*.js', | ||
options: { | ||
lazy: true, | ||
basePath: 'coverage/' | ||
} | ||
}, | ||
|
||
storeCoverage: { | ||
options: { dir: 'coverage' } | ||
}, | ||
|
||
makeReport: { | ||
src: 'coverage/coverage.json', | ||
options: { | ||
type: 'lcov', | ||
dir: 'coverage', | ||
print: 'detail' | ||
} | ||
}, | ||
|
||
nodeunit: { | ||
started: ['test/started.js'], | ||
stopped: ['test/stopped.js'] | ||
} | ||
}) | ||
|
||
grunt.loadNpmTasks('grunt-contrib-nodeunit') | ||
grunt.loadNpmTasks('grunt-istanbul') | ||
grunt.loadNpmTasks('grunt-standard') | ||
grunt.loadTasks(coverage ? 'coverage/tasks' : 'tasks') | ||
|
||
process.env.SAFARIDRIVER_PORT = undefined | ||
grunt.registerTask('switchPort', 'Grunt task switching the safaridriver port.', function () { | ||
process.env.SAFARIDRIVER_PORT = alternativePort | ||
}) | ||
|
||
let test = [ | ||
'standard', 'nodeunit:stopped', 'safaridriver:quiet:start', | ||
'nodeunit:started', 'safaridriver:quiet:stop', | ||
'nodeunit:stopped', 'safaridriver:verbose:start', 'switchPort', | ||
'nodeunit:started', 'safaridriver:verbose:stop', 'nodeunit:stopped', | ||
'safaridriver:otherPort:start', 'nodeunit:started' | ||
] | ||
if (coverage) test = test.concat(['storeCoverage', 'makeReport']) | ||
grunt.registerTask('default', test) | ||
} |
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 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Ferdinand Prantl | ||
|
||
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,144 @@ | ||
# grunt-safaridriver | ||
[![NPM version](https://badge.fury.io/js/grunt-safaridriver.png)](http://badge.fury.io/js/grunt-safaridriver) | ||
[![Build Status](https://travis-ci.org/prantlf/grunt-safaridriver.png)](https://travis-ci.org/prantlf/grunt-safaridriver) | ||
[![codecov](https://codecov.io/gh/prantlf/grunt-safaridriver/branch/master/graph/badge.svg)](https://codecov.io/gh/prantlf/grunt-safaridriver) | ||
[![codebeat badge](https://codebeat.co/badges/1777e780-ea70-4ebd-8f5a-df278c5761d6)](https://codebeat.co/projects/github-com-prantlf-grunt-safaridriver-master) | ||
[![Dependency Status](https://david-dm.org/prantlf/grunt-safaridriver.svg)](https://david-dm.org/prantlf/grunt-safaridriver) | ||
[![devDependency Status](https://david-dm.org/prantlf/grunt-safaridriver/dev-status.svg)](https://david-dm.org/prantlf/grunt-safaridriver#info=devDependencies) | ||
[![peerDependency Status](https://david-dm.org/prantlf/grunt-safaridriver/peer-status.svg)](https://david-dm.org/prantlf/grunt-safaridriver#info=peerDependencies) | ||
|
||
[![NPM Downloads](https://nodei.co/npm/grunt-safaridriver.png?downloads=true&stars=true)](https://www.npmjs.com/package/grunt-safaridriver) | ||
|
||
Controls Safari on OSX using the WebDriver interface via safaridriver without Selenium. | ||
|
||
If you use a modern test driver like [webdriverio], you will not need [Selenium] to run the tests, because the browser driver itself implements the [WebDriver] interface. This module provides a [Grunt] multi-task for installing, starting and stopping the [safaridriver] executable. You take care of maintaining the reasonably recent vewsion of OSX and Safari. Starting with Safari 10 on OS X El Capitan and macOS Sierra, Safari comes bundled with a new driver implementation that's maintained by the Web Developer Experience team at Apple. You might need to run `safaridriver --enable` to enable this feature. | ||
|
||
This task, [grunt-chromedriver] and [grunt-geckodriver] can be used as a replacement for [grunt-selenium-standalone] for tasks like [grunt-html-dom-snapshot], to simplify the whole scenario by removing [Selenium] and [Java] from the requirements. | ||
|
||
## Installation | ||
|
||
You need [node >= 10][node], [npm] and [grunt >= 1.0.0][Grunt] installed and | ||
your project build managed by a [Gruntfile]. If you have not used Grunt before, | ||
be sure to check out the [Getting Started] guide, as it explains how to create | ||
a Gruntfile as well as install and use Grunt plugins. Once you are familiar | ||
with that process, you may install this plugin with this command: | ||
|
||
npm install grunt-safaridriver --save-dev | ||
|
||
## Configuration | ||
|
||
Add the `safaridriver` entry with one or more tasks to the options of the | ||
`grunt.initConfig` method in `Gruntfile.js`: | ||
|
||
```js | ||
grunt.initConfig({ | ||
safaridriver: { | ||
default: {} | ||
} | ||
}); | ||
``` | ||
|
||
Load the plugin: | ||
|
||
```javascript | ||
grunt.loadNpmTasks('grunt-safaridriver'); | ||
``` | ||
|
||
Add use the task to start and stop the browser driver before and after the tests: | ||
|
||
```js | ||
grunt.registerTask('default', ['safaridriver:default:start', ..., 'safaridriver:default:stop']); | ||
``` | ||
|
||
### Options | ||
|
||
Default task options support the most usual usage scenario: | ||
|
||
```js | ||
safaridriver: { | ||
default: { | ||
port: 4444, | ||
findAvailablePort: false, | ||
args: [], | ||
force: false | ||
} | ||
} | ||
``` | ||
|
||
#### port | ||
Type: `Number` | ||
Default value: `4444` | ||
|
||
The port for the `safaridriver` to listen to. If `findAvailablePort` is set to | ||
`true`, this port will be used to start the search for a free port with. | ||
|
||
### findAvailablePort | ||
Type: `Boolean` | ||
Default value: `false` | ||
|
||
If set to `true`, the value of `port` will be used to start the search for a | ||
free port with. | ||
|
||
### args | ||
Type: `Array<String>` | ||
Default value: `[]` | ||
|
||
Command-line arguments for the `safaridriver` executable. Available ones: | ||
|
||
-p, --port Port number the driver should use. If the server | ||
is already running, the port cannot be changed. | ||
If port 0 is specified, a default port will be used. | ||
--enable Applies configuration changes so that subsequent WebDriver | ||
sessions will run without further authentication. | ||
--diagnose Causes safaridriver to log diagnostic information for | ||
all sessions hosted by this instance. See the safaridriver(1) | ||
man page for more details about diagnostic logging. | ||
|
||
### force | ||
Type: `Boolean` | ||
Default value: `false` | ||
|
||
If set to `true`, it suppresses failures. Instead of making the Grunt fail, | ||
the errors will be written only to the console. | ||
|
||
### Events | ||
|
||
If `findAvailablePort` is set to `true`, the actual chosen port can be read by: | ||
|
||
```js | ||
grunt.config.get(`safaridriver.<task-name>.port`) | ||
``` | ||
|
||
As soon es the browser driver process starts listening, an event will be | ||
triggered with the actually chosen port: | ||
|
||
```js | ||
grunt.event.on(`safaridriver.<task-name>.listening`, port => {...}) | ||
``` | ||
|
||
## Contributing | ||
|
||
In lieu of a formal styleguide, take care to maintain the existing coding | ||
style. Add unit tests for any new or changed functionality. Lint and test | ||
your code using Grunt. | ||
|
||
## License | ||
|
||
Copyright (c) 2020 Ferdinand Prantl | ||
|
||
Licensed under the MIT license. | ||
|
||
[node]: https://nodejs.org | ||
[npm]: https://npmjs.org | ||
[Grunt]: https://gruntjs.com | ||
[Gruntfile]: https://gruntjs.com/sample-gruntfile | ||
[Getting Gtarted]: https://github.com/gruntjs/grunt/wiki/Getting-started | ||
[Selenium]: http://www.seleniumhq.org/download/ | ||
[safaridriver]: https://developer.apple.com/documentation/webkit/testing_with_webdriver_in_safari | ||
[webdriverio]: http://webdriver.io/ | ||
[Java]: https://java.com/en/download/ | ||
[WebDriver]: https://www.w3.org/TR/webdriver/ | ||
[grunt-html-dom-snapshot]: https://github.com/prantlf/grunt-html-dom-snapshot#readme | ||
[grunt-selenium-standalone]: https://github.com/zs-zs/grunt-selenium-standalone#readme | ||
[grunt-chromedriver]: https://github.com/prantlf/grunt-chromedriver#readme | ||
[grunt-geckodriver]: https://github.com/prantlf/grunt-geckodriver#readme |
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,59 @@ | ||
{ | ||
"name": "grunt-safaridriver", | ||
"description": "Controls Safari on OSX using the WebDriver interface via safaridriver without Selenium.", | ||
"version": "0.0.1", | ||
"homepage": "https://github.com/prantlf/grunt-safaridriver#readme", | ||
"author": { | ||
"name": "Ferdinand Prantl", | ||
"email": "[email protected]", | ||
"url": "http://prantl.tk" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/prantlf/grunt-safaridriver.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/prantlf/grunt-safaridriver/issues" | ||
}, | ||
"license": "MIT", | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/prantlf/grunt-safaridriver/blob/master/LICENSE" | ||
} | ||
], | ||
"engines": { | ||
"node": ">=10" | ||
}, | ||
"files": [ | ||
"tasks" | ||
], | ||
"scripts": { | ||
"lint": "grunt standard", | ||
"test": "grunt", | ||
"coverage": "grunt instrument && grunt --coverage" | ||
}, | ||
"dependencies": { | ||
"portscanner": "2.2.0", | ||
"tcp-port-used": "1.0.1" | ||
}, | ||
"devDependencies": { | ||
"grunt": "1.2.1", | ||
"grunt-contrib-nodeunit": "2.1.0", | ||
"grunt-istanbul": "0.8.0", | ||
"grunt-standard": "3.2.0", | ||
"webdriverio": "6.4.0" | ||
}, | ||
"peerDependencies": { | ||
"grunt": ">=1.2.1" | ||
}, | ||
"keywords": [ | ||
"grunt-task", | ||
"gruntplugin", | ||
"testing", | ||
"browser", | ||
"webdriver", | ||
"safaridriver", | ||
"safari" | ||
] | ||
} |
Oops, something went wrong.