Skip to content

Commit

Permalink
Remove nightwatch in favour of puppeteer
Browse files Browse the repository at this point in the history
  • Loading branch information
jalkoby committed Nov 29, 2017
1 parent 9e61191 commit 11d8153
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 248 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules
/node_modules
.DS_Store
reports
selenium-debug.log
/package-lock.json
7 changes: 2 additions & 5 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
e2e_helpers
tests
nightwatch.json
selenium-debug.log
index.html
test
index.html
38 changes: 8 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,11 @@
language: node_js
node_js:
- "4.2"

env:
- E2E_BROWSER_VENDOR="internet explorer" E2E_PLATFORM="Windows 8.1" E2E_BROWSER_VERSION="latest"
- E2E_BROWSER_VENDOR="internet explorer" E2E_PLATFORM="Windows 10" E2E_BROWSER_VERSION="latest"
- E2E_BROWSER_VENDOR="MicrosoftEdge" E2E_PLATFORM="Windows 10" E2E_BROWSER_VERSION="latest"
- E2E_BROWSER_VENDOR="chrome" E2E_PLATFORM="Windows 8.1" E2E_BROWSER_VERSION="latest"
- E2E_BROWSER_VENDOR="chrome" E2E_PLATFORM="Windows 8.1" E2E_BROWSER_VERSION="latest-1"
- E2E_BROWSER_VENDOR="chrome" E2E_PLATFORM="Windows 10" E2E_BROWSER_VERSION="latest"
- E2E_BROWSER_VENDOR="chrome" E2E_PLATFORM="Windows 10" E2E_BROWSER_VERSION="latest-1"
- E2E_BROWSER_VENDOR="firefox" E2E_PLATFORM="Windows 8.1" E2E_BROWSER_VERSION="latest"
- E2E_BROWSER_VENDOR="firefox" E2E_PLATFORM="Windows 8.1" E2E_BROWSER_VERSION="latest-1"
- E2E_BROWSER_VENDOR="firefox" E2E_PLATFORM="Windows 10" E2E_BROWSER_VERSION="latest"
- E2E_BROWSER_VENDOR="firefox" E2E_PLATFORM="Windows 10" E2E_BROWSER_VERSION="latest-1"
# TODO: add workaround for chromedriver issue
# - E2E_BROWSER_VENDOR="chrome" E2E_PLATFORM="OS X 10.11" E2E_BROWSER_VERSION="latest"
# - E2E_BROWSER_VENDOR="chrome" E2E_PLATFORM="OS X 10.11" E2E_BROWSER_VERSION="latest-1"
# TODO: look into execCommand(“copy”) support in Safari
# window.document.queryCommandSupported('copy') - false in 9.1.1
# - E2E_BROWSER_VENDOR="safari" E2E_PLATFORM="OS X 10.11" E2E_BROWSER_VERSION="latest"
- E2E_BROWSER_VENDOR="firefox" E2E_PLATFORM="OS X 10.11" E2E_BROWSER_VERSION="latest"
- E2E_BROWSER_VENDOR="firefox" E2E_PLATFORM="OS X 10.11" E2E_BROWSER_VERSION="latest-1"

- 8
addons:
sauce_connect:
username: "sudodoki"
access_key:
secure: "MBHn7+lxuJ0uNuFC8HjIZtosuOHICNW52fEhvtnJhXmaGOUXGLrQFUCvECJOoGrdOWmkiFaGgYINdF57HbYpyAICmv51UBlzHYftkTspYooH5+vni0ezPPpvxqNpUM/dlwfrdzC/ag97VYDeIxdYRKREwhRsNd5npE0Zrx1xmvzmnpdqdVhQ7Z/wQUDjv7talKC2fkaIYP+wEhVblnr18u0phFLqyADNsCV7D9QmILQWC4ieSz6ylTW9fb69B4rZElLj+D8qGvyvgmLnu+dK4Vlh0WuTdmVZ8TZS4OeBRIbjq/Mi2vMVuQLXz3DTiGWRZeDOBB5PYm/orgjgsnNg5hPx6t7yc4ypcBYf2gHxc31lV9VZRb10py33D8qPtcmPptwIWlsCQ4ANDyOwxck0FejMpjT+Ktkyme4nAvt9op289x8KKI0w8W7nHIB930lEookJCeMHWjyycPLJDTwYe60zBS24vNRF46ixhfpeO1zGw8nEj5qqSoEltunCOQ3Uvl25tNEuk9R649TyWbegjTuS4txqAsSjUnVMGvRBcZef4YyOQsggos1YbJMNnFSvDH9VaPYiJbg/qR7tb0YJ8gtAC9/6iqba6EZadkJQe9DHs6qu5zuoiwfSgBZTON2oWL6AGwySADm44SL7ikKJN8Zb8bLjQ1o15KinBVKLuOk="

script:
- REMOTE_SELENIUM=true npm test -- -e saucelabs
apt:
packages:
- xvfb
before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ copy('Text', {

Works everywhere where `prompt`* is available. Works best (i.e. without additional keystrokes) in Chrome, FF, Safari 10+, and, supposedly, IE/Edge.

Note: **does not work on some older iOS devices.**
Note: **does not work on some older iOS devices.**
`*` – even though **Safari 8** has `prompt`, you cannot specify prefilled content for prompt modal – thus it **doesn't work** as expected.

# Installation
Expand All @@ -56,7 +56,7 @@ You will have `window.copyToClipboard` exposed for you to use.
+ [April 2015 update on Cut and Copy Commands](http://updates.html5rocks.com/2015/04/cut-and-copy-commands)

# Running Tests
This project has some automated tests, that will run using [nightwatch](nightwatchjs.org) on top of [selenium](http://www.seleniumhq.org/).
This project has some automated tests, that will run using [ava](https://github.com/avajs/ava) on top of [puppeteer](https://github.com/GoogleChrome/puppeteer).

```
npm i
Expand Down
45 changes: 0 additions & 45 deletions e2e_helpers/assertions/assertBuffer.js

This file was deleted.

Empty file removed e2e_helpers/commands/.gitkeep
Empty file.
21 changes: 0 additions & 21 deletions e2e_helpers/globals.js

This file was deleted.

25 changes: 0 additions & 25 deletions e2e_helpers/pages/helper.js

This file was deleted.

29 changes: 14 additions & 15 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ function copy(text, options) {
range = document.createRange();
selection = document.getSelection();

mark = document.createElement('mark');
mark = document.createElement('span');
mark.textContent = text;
mark.setAttribute('style', [
// prevents scrolling to the end of the page
'position: fixed',
'top: 0',
'clip: rect(0, 0, 0, 0)',
// used to preserve spaces and line breaks
'white-space: pre',
// do not inherit user-select (it may be `none`)
'-webkit-user-select: text',
'-moz-user-select: text',
'-ms-user-select: text',
'user-select: text',
].join(';'));
// reset user styles for span element
mark.style.all = 'unset';
// prevents scrolling to the end of the page
mark.style.position = 'fixed';
mark.style.top = 0;
mark.style.clip = 'rect(0, 0, 0, 0)';
// used to preserve spaces and line breaks
mark.style.whiteSpace = 'pre';
// do not inherit user-select (it may be `none`)
mark.style.webkitUserSelect = 'text';
mark.style.MozUserSelect = 'text';
mark.style.msUserSelect = 'text';
mark.style.userSelect = 'text';

document.body.appendChild(mark);

Expand Down Expand Up @@ -79,7 +79,6 @@ function copy(text, options) {
module.exports = copy;

},{"toggle-selection":2}],2:[function(require,module,exports){
var module = module || {};

module.exports = function () {
var selection = document.getSelection();
Expand Down
44 changes: 0 additions & 44 deletions nightwatch.json

This file was deleted.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"types": "index.d.ts",
"scripts": {
"pretest": "browserify ./index.js -o ./example/index.js --standalone copyToClipboard",
"test": "nightwatch"
"test": "ava -s"
},
"keywords": [
"clipboard",
Expand All @@ -32,9 +32,9 @@
"example": "example"
},
"devDependencies": {
"ava": "^0.24.0",
"browserify": "^13.0.1",
"nightwatch": "^0.9.1",
"node-static": "^0.7.7",
"selenium-server-standalone-jar": "2.53.0"
"clipboardy": "^1.2.2",
"puppeteer": "^0.13.0"
}
}
13 changes: 13 additions & 0 deletions test/_open-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const puppeteer = require('puppeteer');
const path = require('path');

let browser;

module.exports = async () => {
if(!browser) {
browser = await puppeteer.launch({ headless: true, args: ['--no-sandbox', '--allow-no-sandbox-job'] });
}
let page = await browser.newPage();
await page.goto(`file://${path.resolve(__dirname, '../example/index.html')}`);
return page;
}
26 changes: 26 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const openPage = require('./_open-page');
const test = require('ava');
const clipboardy = require('clipboardy');

test('Sanity check', async t => {
let page = await openPage();
t.is(await page.$eval('[data-test="heading"]', el => el.innerText), 'copy-to-clipboard Repo');
});

test('Basic Text Copy', async t => {
let page = await openPage();
await page.click('[data-test="init-basic-text"]');
t.is(await clipboardy.read(), "Hello, I'm new content from your clipboard");
});

test('Multiline Text Copy', async t => {
let page = await openPage();
await page.click('[data-test="init-multiline-text"]');
t.is(await clipboardy.read(), "This would be\nsome multiline text\nfor us to copy");
});

test('Text w/ Markup Copy', async t => {
let page = await openPage();
await page.click('[data-test="init-markup-text"]');
t.is(await clipboardy.read(), "<script>\n alert\('this is some script'\)\n</script>");
});
17 changes: 0 additions & 17 deletions tests/00_sanity-check.js

This file was deleted.

13 changes: 0 additions & 13 deletions tests/01_basic-text.js

This file was deleted.

12 changes: 0 additions & 12 deletions tests/02_multiline-text.js

This file was deleted.

13 changes: 0 additions & 13 deletions tests/03_markup-text.js

This file was deleted.

0 comments on commit 11d8153

Please sign in to comment.