Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
36373af3
Commit
36373af3
authored
Apr 12, 2018
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display relevant browser console output whenever an integration test fails
parent
2a7d011a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
spec/support/capybara.rb
spec/support/capybara.rb
+19
-0
No files found.
spec/support/capybara.rb
View file @
36373af3
...
@@ -7,6 +7,16 @@ require 'selenium-webdriver'
...
@@ -7,6 +7,16 @@ require 'selenium-webdriver'
# Give CI some extra time
# Give CI some extra time
timeout
=
(
ENV
[
'CI'
]
||
ENV
[
'CI_SERVER'
])
?
60
:
30
timeout
=
(
ENV
[
'CI'
]
||
ENV
[
'CI_SERVER'
])
?
60
:
30
# Define an error class for JS console messages
JSConsoleError
=
Class
.
new
(
StandardError
)
# Filter out innocuous JS console messages
JS_CONSOLE_FILTER
=
Regexp
.
union
([
'"[HMR] Waiting for update signal from WDS..."'
,
'"[WDS] Hot Module Replacement enabled."'
,
"Download the Vue Devtools extension"
])
Capybara
.
register_driver
:chrome
do
|
app
|
Capybara
.
register_driver
:chrome
do
|
app
|
capabilities
=
Selenium
::
WebDriver
::
Remote
::
Capabilities
.
chrome
(
capabilities
=
Selenium
::
WebDriver
::
Remote
::
Capabilities
.
chrome
(
# This enables access to logs with `page.driver.manage.get_log(:browser)`
# This enables access to logs with `page.driver.manage.get_log(:browser)`
...
@@ -78,6 +88,15 @@ RSpec.configure do |config|
...
@@ -78,6 +88,15 @@ RSpec.configure do |config|
end
end
config
.
after
(
:example
,
:js
)
do
|
example
|
config
.
after
(
:example
,
:js
)
do
|
example
|
# when a test fails, display any messages in the browser's console
if
example
.
exception
console
=
page
.
driver
.
browser
.
manage
.
logs
.
get
(
:browser
).
try
(
:reject
)
{
|
log
|
log
.
message
=~
JS_CONSOLE_FILTER
}
if
console
.
present?
message
=
"Unexpected browser console output:
\n
"
+
console
.
map
(
&
:message
).
join
(
"
\n
"
)
raise
JSConsoleError
,
message
end
end
# prevent localStorage from introducing side effects based on test order
# prevent localStorage from introducing side effects based on test order
unless
[
''
,
'about:blank'
,
'data:,'
].
include?
Capybara
.
current_session
.
driver
.
browser
.
current_url
unless
[
''
,
'about:blank'
,
'data:,'
].
include?
Capybara
.
current_session
.
driver
.
browser
.
current_url
execute_script
(
"localStorage.clear();"
)
execute_script
(
"localStorage.clear();"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment