Giter Site home page Giter Site logo

alexeyraspopov / jest-webdriver Goto Github PK

View Code? Open in Web Editor NEW
225.0 8.0 22.0 38 KB

Connect Jest tests to Selenium WebDriver

Home Page: https://alexeyraspopov.github.io/jest-webdriver

License: MIT License

JavaScript 99.26% Shell 0.74%
jest jest-environment jest-reporter selenium-webdriver

jest-webdriver's Introduction

Jest WebDriver Integration

Connect Jest tests to Selenium WebDriver.

Limitations

The project is in progress. It only supports running preinstalled WebDrivers (Chrome, Safari, Firefox, Edge, IE) without additional options. Capabilities configuration will be added soon. Pull requests welcomed.

Usage

The project includes next packages that are available via NPM:

Examples

In examples folder you can find complete demo projects with installed Jest WebDriver packages and a sample test case that does a thing.

  • Basic Test Case — a demo project that includes minimum configuration and runs a single test that is written with all the recommended design patterns

Documentation

Complete documentation and guidelines are in progress. You can find basic API reference in each package's folder.

As a complete "getting started" guide please read Testing javascript applications with Selenium, Async/Await, and Jest.

jest-webdriver's People

Contributors

alexeyraspopov avatar ineigo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jest-webdriver's Issues

Jest warns for unknown environment options: browser, browserOptions

Jest now checks for unknown fields in testEnvironmentOptions:

● Validation Warning:

  Unknown option "testEnvironmentOptions.browser" with value "firefox" was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration.html

● Validation Warning:

  Unknown option "testEnvironmentOptions.browserOptions" with value {"chrome": {"driver": "D:\\Code\\WebClient\\.drivers\\chromedriver.exe", "headless": false}, "edge": {"driver": "D:\\Code\\WebClient\\.drivers\\MicrosoftWebDriver.exe"}, "firefox": {"driver": "D:\\Code\\WebClient\\.drivers\\geckodriver.exe", "headless": false, "preferences": [["security.sandbox.content.level", 5]]}} was found.
  This is probably a typing mistake. Fixing it will remove this message.

  Configuration Documentation:
  https://jestjs.io/docs/configuration.html

Can we move this to a separate config location? Do you have some guidance here?

Set headless option when using firefox driver

Firefox supports running in headless mode as of version 56. This seems to be a desirable default compared to the current situation. MDN provides instructions here on how to enable headless mode when using Selenium: https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode . Right now, jest-webdriver calls build() directly on the webdriver builder, without passing any options. We could maybe:

  1. Detect when the browser string is "firefox" and append the headless option (maybe only if we detect a recent enough version ?)
  2. Or, if this is deemed to be too intrusive, allow the user to customize the builder options (the user could then add the "headless" switch for Firefox manually)

TypeError: Cannot read property 'quit' of undefined

Setup system test case based one examples.

Package.json:

{
  "name": "jestdriver",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "jest"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "jest": "^24.9.0",
    "jest-environment-webdriver": "^0.2.0"
  },
  "jest": {
    "testEnvironment": "jest-environment-webdriver",
    "testEnvironmentOptions": {
      "browser": "chrome"
    }
  }
}

When I run npm test, I get this:

● Test suite failed to run

    TypeError: Cannot read property 'quit' of undefined

      at WebDriverEnvironment.teardown (node_modules/jest-environment-webdriver/modules/WebDriverEnvironment.js:33:23)
          at Generator.throw (<anonymous>)

Looking into that specific file, I notice that the config object brought into the constructor does not have a seleniumAddress:

this.seleniumAddress = options.seleniumAddress || null;

Should this be pointing at something? It only points to:

testEnvironmentOptions: { browser: 'chrome' },

IE driver doesn't support the "Close" command

This is the nature of IE - it never dies...

 FAIL  test/end-to-end/dev/Tests/MyTests.test.ts
  ● Test suite failed to run

    UnsupportedOperationError: close: Error 404: Not Found
    Not Found

      at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:557:11)
      at Executor.execute (node_modules/selenium-webdriver/lib/http.js:468:26)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        40.098s
Ran all test suites matching /MyTests/i.

(error message enhanced with changes from SeleniumHQ/selenium#6321)

...however, it does support .quit().

Basic Testcase Example doesn't work

I followed the steps to get it working, and after npm test, I ran into:

> jest-webdriver@ test /Users/mac.mccarthy/Documents/workdesk/test/jest-webdriver
> jest --coverage

 FAIL  packages/jest-screenshot-reporter/modules/__tests__/JestScreenshotReporter-test.js
  ● Test suite failed to run

    SecurityError: localStorage is not available for opaque origins

      at Window.get localStorage [as localStorage] (../../node_modules/jsdom/lib/jsdom/browser/Window.js:257:15)
          at Array.forEach (<anonymous>)

 FAIL  packages/jest-environment-webdriver/modules/__tests__/WebDriverEnvironment-test.js
  ● Test suite failed to run

    SecurityError: localStorage is not available for opaque origins

      at Window.get localStorage [as localStorage] (../../node_modules/jsdom/lib/jsdom/browser/Window.js:257:15)
          at Array.forEach (<anonymous>)

----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |  Unknown |  Unknown |  Unknown |  Unknown |                   |
----------|----------|----------|----------|----------|-------------------|
Test Suites: 2 failed, 2 total
Tests:       0 total
Snapshots:   0 total
Time:        0.773s
Ran all test suites in 2 projects.
npm ERR! Test failed.  See above for more details.

Not sure what could be done here; let me know if you need more info. Thanks!

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.