From c13bbeec24c98f2413fc316a524c32381a335fb1 Mon Sep 17 00:00:00 2001 From: "Marcos Neves | ubuntu@home" Date: Thu, 17 May 2018 06:12:20 -0300 Subject: [PATCH] Keyboard testing using codecept.JS --- codecept.json | 14 ++ cypress/integration/build_spec.js | 8 +- package.json | 2 + test/e2e_spec.js | 4 +- test/index.html | 10 +- test/keyboard_scenario.js | 21 +++ test/puppeteer.js | 42 +++++ yarn.lock | 255 ++++++++++++++++++++++++++++-- 8 files changed, 330 insertions(+), 26 deletions(-) create mode 100644 codecept.json create mode 100644 test/keyboard_scenario.js create mode 100644 test/puppeteer.js diff --git a/codecept.json b/codecept.json new file mode 100644 index 00000000..8d98758b --- /dev/null +++ b/codecept.json @@ -0,0 +1,14 @@ +{ + "tests": "./test/*_scenario.js", + "timeout": 10000, + "output": "./output", + "helpers": { + "Puppeteer": { + "url": "http://localhost:5000/test" + } + }, + "include": {}, + "bootstrap": false, + "mocha": {}, + "name": "vue-the-mask" +} diff --git a/cypress/integration/build_spec.js b/cypress/integration/build_spec.js index e8a350d6..b5923229 100644 --- a/cypress/integration/build_spec.js +++ b/cypress/integration/build_spec.js @@ -1,13 +1,13 @@ -const PATH = '/cypress/build-fixture.html' +const PATH = '/test/index.html' describe('dist build test', function() { it('loads VueTheMask at window', function() { - const o = { delay: 500 } + const o = { delay: 1000 } cy .visit(PATH) .get('#input') - .type('0{leftarrow}1', o) - .then(input => console.log(input.get(0).selectionEnd)) + .type('0{leftarrow}12{leftarrow}{backspace}98', o) + .then(input => console.log(input.get(0))) // .should('have.value', '+1 0') // .should('have.value', '+1 02') // .type('3', o) diff --git a/package.json b/package.json index 89b5c9f7..f4ab07e5 100644 --- a/package.json +++ b/package.json @@ -83,12 +83,14 @@ "@vue/cli-service": "^3.0.0-beta.10", "babel-jest": "^22.4.3", "babel-preset-vue-app": "^2.0.0", + "codeceptjs-puppeteer": "^1.2.0", "cypress": "^2.1.0", "jest": "^22.4.3", "jest-serializer-vue": "^1.0.0", "nightwatch": "^0.9.21", "npm-check-updates": "^2.14.2", "npmlog": "4.1.2", + "puppeteer": "^1.4.0", "serve": "^6.5.7", "size-limit": "^0.18.0", "testcafe": "^0.20.0", diff --git a/test/e2e_spec.js b/test/e2e_spec.js index 71260f2f..2934323b 100644 --- a/test/e2e_spec.js +++ b/test/e2e_spec.js @@ -34,7 +34,7 @@ https: test('correctly insert in the middle', async t => { .typeText(input, '0234.') .expect(input.value) .eql('+1 02.34.') - .pressKey('left left left left 0') + .pressKey('left left left left 9 8') .expect(input.value) - .eql('+1 02.03.4') + .eql('+1 02.983.4') }) diff --git a/test/index.html b/test/index.html index e8f270ef..02ada416 100644 --- a/test/index.html +++ b/test/index.html @@ -7,12 +7,14 @@
- - - {{cursor}} + + + +
- + +