alexeyraspopov / jest-webdriver Goto Github PK
View Code? Open in Web Editor NEWConnect Jest tests to Selenium WebDriver
Home Page: https://alexeyraspopov.github.io/jest-webdriver
License: MIT License
Connect Jest tests to Selenium WebDriver
Home Page: https://alexeyraspopov.github.io/jest-webdriver
License: MIT License
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!
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:
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' },
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?
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()
.
It would be very helpful to see an example test in the readme.
I've added one here https://blog.evantahler.com/testing-javascript-applications-with-selenium-async-await-and-jest-7580ed074f2b
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.