Giter Site home page Giter Site logo

vue-cli-plugin-e2e-webdriverio's Introduction

vue-cli-plugin-e2e-webdriverio

e2e-webdriver plugin for vue-cli

Injected Commands

Run e2e tests with WebdriverIO

  Usage:
    yarn run test:e2e [options]
    yarn run test:e2e
      --baseUrl http://localhost:8080
      --capabilities desktop,iphone
      --specs spec/**
      --headless
      --debug
      --mode development
    yarn run test:e2e --config wdio.conf.js
    yarn run test:e2e --suite focus --bail 1

  Options:
    -b, --baseUrl [STRING<URI>]      Run e2e tests against dev server running at given url. Auto starts dev server if absent.
    --capabilities [STRING[,STRING]] Specify browser capabilities to run (default: desktop)
    --config [STRING<PATH>]          Use your own WebdriverIO configuration; overrides plugin defaults (relative to <projectRoot>)
    --headless, --no-headless        Run e2e tests in headless mode without GUI (default capabilities only)
    --debug, --no-debug              Enable Node inspector and debugging tools
    --mode [STRING]                  Run the dev server in specified mode (default: production)
    --specs [STRING[,STRING]]        Glob pattern determines specs to run (relative to <projectRoot>)

Additionally, all WebdriverIO CLI options are supported.

The task may also be run via vue ui.

Compatibility

Configuration

Defaults defined on plugin invocation will be stored in vue.config.js.

Defaults will be overriden by command line options on command invocation.

Settings defined within <projectRoot>/wdio.conf.js will be merged with the plugin's defaults.

To override internal configuration entirely use option --config to specify alternate configuration file. If you haven't already, run ./node_modules/.bin/wdio to configure WebdriverIO.


This plugin provides a number of WebdriverIO capabilities each utilising ChromeDriver. If you wish to run e2e tests with different capabilities, define them within <projectRoot>/wdio.conf.js.

When using --capabilities to run specs against a subset of devices, you must first capabilities.register within <projectRoot>/wdio.conf.js.

  // wdio.conf.js
  const { capabilities, Chrome } = require('vue-cli-plugin-e2e-webdriverio').capabilities

  capabilities.register('device', new Chrome({
    // ...options
  }))

  capabilities.register('other', new Chrome({
    // ...options
  }))

Then you can run a subset of capabilities like so yarn test:e2e --capabilities device


By default, tests are run in interactive mode, to run in headless mode (for CI) use option --headless.


Selenium commands will be executed synchronously by default. To override:

  // wdio.conf.js
  exports.config = {
    sync: false
    // ...
  }

WebdriverIO hooks defined in <projectRoot>/wdio.conf.js will be appended to behaviour provided by plugin defaults unless run with alternate --config.

  // wdio.conf.js
  const { WDIOConfigDefault, capabilities, util } = require('vue-cli-plugin-e2e-webdriverio')
  const { resizeViewport, isDebug } = util
  const { Chrome } = capabilities

  const base = WDIOConfigDefault().config

  exports.config = {
    ...base,
    // your overrides here...
    capabilities: [
      new Chrome({
        browserName: 'chrome',
        chromeOptions: {
          args: [
            '--headless',
            // etc...
          ]
        },
        viewportSize: {
          width: 1024,
          height: 768,
        },
        // etc...
      })
    ],

    beforeSuite: [
      resizeViewport,
      anotherFunction,
    ]

    afterTest: [
      (test) => {
        if (isDebug() && !test.passed) {
          saveScreenshot(test, 'path/to/screenshot.png')
        }
      },
      // ...
    }

    // OR

    beforeSuite: (suite) => {
      resizeViewport()
      // your behaviour here...
    }
  }

Consult WebdriverIO Configuration for available options and browser configuration.


You may need to set NODE_ENV and VUE_CLI_MODE if running tests in mode other than plugin default, production. The enviroment variable must be set before Vue CLI Service loadEnv called.

  // package.json
  {
    "scripts": {
      "test:e2e": "NODE_ENV=development VUE_CLI_MODE=development vue-cli-service test:e2e"
    }
  }

Refer to Vue CLI Service Plugin defaultModes

API

WDIOConfigDefault() : object

Returns the plugin's internal WebdriverIO configuration.

capabilities.Chrome

new(options)

Constructor prepares ChromeDriver options from given input.

viewportSize { width: number, height: number }

userAgent : string

mobileEmulation : object

capabilities.find(names: string | string[]) : Array<object>

Returns a list of registered capabilities matching given name(s). Accepts a comma delimited list or Array.

capabilities.register(name: string, capability: object)

Adds the named capability to the capabilities container.

capabilities.desktop(options: object) : capabilities.Chrome

Returns the predefined capability.

capabilities.iphone(options: object) : capabilities.Chrome

Returns the predefined capability.

capabilities.ipad(options: object) : capabilities.Chrome

Returns the predefined capability.

capabilities.android(options: object) : capabilities.Chrome

Returns the predefined capability.

util.resizeViewport() : void

If current capability has property viewportSize this function will issue WebdriverIO command to resize the current browser window so that inner dimensions match viewportSize.

util.saveScreenshot(test: object, path: string) : void

Saves screenshot to given path or tmp directory and logs error info to stdout.

util.printBrowserConsole() : void

Log all browser output to stdout.

Installing in an Already Created Project

Commit your project and run vue add vue-cli-plugin-e2e-webdriverio

vue-cli-plugin-e2e-webdriverio's People

Contributors

darrelfrancis avatar jamesdiacono avatar piktur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

vue-cli-plugin-e2e-webdriverio's Issues

Export factories

module.exports.capabilities = () => require('./lib/capabilities')
module.exports.util = () => require('./lib/util')

Any reason why these exports are functions? They look like they'd function as singletons, and capabilities seems to be used as such by vue-shared

ES6 support

Hi
did you by any chance got ES6 working?
I have tried several ways of getting babel to compile my specs but I can't seem make it work without breaking unit tests and/or serve

Failing tests should return a non-zero exit code

> vue-cli-service test:e2e --mode development --no-debug --headless

✖ Browse my event clears search and sees event again
  Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

[chrome #0-0] Running: chrome
[chrome #0-0]
[chrome #0-0] Browse my event
[chrome #0-0]   ✓ non compliant user visits event list; agrees to T&Cs; sees events
[chrome #0-0]   ✓ compliant user visits event list; sees events
[chrome #0-0]   ✓ tries to search for other events
[chrome #0-0]   1) clears search and sees event again
[chrome #0-0]
[chrome #0-0]
[chrome #0-0] 3 passing (2m, 8s)
[chrome #0-0] 1 failing
[chrome #0-0]
[chrome #0-0] 1) Browse my event clears search and sees event again:
[chrome #0-0] Timeout of 120000ms exceeded. Try to reduce the run time or increase your timeout for test specs (http://webdriver.io/guide/testrunner/timeouts.html); if returning a Promise, ensure it resolves.

 ERROR  Command failed: node_modules/webdriverio/bin/wdio --baseUrl http://localhost:8009 --port 54017 node_modules/vue-cli-plugin-e2e-webdriverio/wdio.conf.default.js

> vue-cli-service build


⠙  Building for production...

It should not be building for production after failing!!!

I will sort this out.

An unexpected error occurred, not found (registry)

When I run vue add vue-cli-plugin-e2e-webdriver im getting the following error:

WARN  There are uncommited changes in the current repository, it's recommended to commit or stash them first.
? Still proceed? Yes

📦  Installing vue-cli-plugin-e2e-webdriver...

yarn add v1.22.4
info No lockfile found.
[1/4] 🔍  Resolving packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/vue-cli-plugin-e2e-webdriver: Not found".
info If you think this is a bug, please open a bug report with the information provided in "/Users/youri/code/PIDZ/test/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
 ERROR  command failed: yarn add vue-cli-plugin-e2e-webdriver -D --tilde

After changing the registry to npm:

WARN  There are uncommited changes in the current repository, it's recommended to commit or stash them first.
? Still proceed? Yes

📦  Installing vue-cli-plugin-e2e-webdriver...

yarn add v1.22.4
info No lockfile found.
[1/4] 🔍  Resolving packages...
error An unexpected error occurred: "https://registry.npmjs.org/vue-cli-plugin-e2e-webdriver: Not found".
info If you think this is a bug, please open a bug report with the information provided in "/Users/youri/code/PIDZ/test/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Both https://registry.yarnpkg.com/vue-cli-plugin-e2e-webdriver and https://registry.npmjs.org/vue-cli-plugin-e2e-webdriver gives not found...

I am using Yarn

Generator should set `mode` rather than env vars

I had success replacing the NODE_ENV=development VUE_CLI... with just a --mode development.

Current behaviour

"test:e2e": "NODE_ENV=development ... vue-cli-service test:e2e

Expected behaviour

"test:e2e": "vue-cli-service test:e2e --mode development"

release v2.0.3

@piktur I've already bumped the package version and added tag, if you would be so kind as to npm publish that would be grand. tests are passing!

ECONNREFUSED 127.0.0.1:55317

I am repeatedly getting this error, with the port number randomising each time:

$ yarn test --spec test/specs/login.js 
yarn run v1.10.1
warning package.json: No license field
$ vue-cli-service test:e2e --mode development --no-debug --headless --spec test/specs/login.js
ERROR: connect ECONNREFUSED 127.0.0.1:55317
chrome
    at new RuntimeError (/Users/me/Code/com10/node_modules/webdriverio/build/lib/utils/ErrorHandler.js:143:12)
    at Request._callback (/Users/me/Code/com10/node_modules/webdriverio/build/lib/utils/RequestHandler.js:330:43)
    at self.callback (/Users/me/Code/com10/node_modules/request/request.js:185:22)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at Request.onRequestError (/Users/me/Code/com10/node_modules/request/request.js:881:8)
    at emitOne (events.js:121:20)
    at ClientRequest.emit (events.js:211:7)
    at Socket.socketErrorListener (_http_client.js:387:9)
    at emitOne (events.js:116:13)

 ERROR  Command failed: /Users/me/Code/com10/node_modules/webdriverio/bin/wdio --spec test/specs/login.js --baseUrl http://localhost:8080 --port 55317 /Users/me/Code/com10/node_modules/vue-cli-plugin-e2e-webdriverio/wdio.conf.default.js
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

It's only happening on one of two projects using this plugin.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.