Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
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
nexedi
converse.js
Commits
3866ab7b
Commit
3866ab7b
authored
Jun 13, 2017
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
No need for run-jasmine2.js with chrome headless
parent
e907bec4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
97 deletions
+0
-97
tests/run-jasmine2.js
tests/run-jasmine2.js
+0
-97
No files found.
tests/run-jasmine2.js
deleted
100644 → 0
View file @
e907bec4
/*global document, require, setInterval, clearInterval, eval, phantom, console */
var
system
=
require
(
'
system
'
);
function
waitFor
(
testFx
,
onReady
,
timeOutMillis
)
{
/**
* Wait until the test condition is true or a timeout occurs. Useful for waiting
* on a server response or for a ui change (fadeIn, etc.) to occur.
*
* @param testFx javascript condition that evaluates to a boolean,
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
* as a callback function.
* @param onReady what to do when testFx condition is fulfilled,
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or
* as a callback function.
* @param timeOutMillis the max amount of time to wait. If not specified, 3 sec is used.
*/
"
use strict
"
;
var
maxtimeOutMillis
=
timeOutMillis
?
timeOutMillis
:
40001
,
//< Default Max Timeout is 10s
start
=
new
Date
().
getTime
(),
condition
=
false
,
interval
=
setInterval
(
function
()
{
if
(
(
new
Date
().
getTime
()
-
start
<
maxtimeOutMillis
)
&&
!
condition
)
{
// If not time-out yet and condition not yet fulfilled
condition
=
(
typeof
(
testFx
)
===
"
string
"
?
eval
(
testFx
)
:
testFx
());
// eslint-disable-line no-eval
}
else
{
if
(
!
condition
)
{
// If condition still not fulfilled (timeout but condition is 'false')
console
.
log
(
"
'waitFor()' timeout
"
);
phantom
.
exit
(
1
);
}
else
{
// Condition fulfilled (timeout and/or condition is 'true')
console
.
log
(
"
'waitFor()' finished in
"
+
(
new
Date
().
getTime
()
-
start
)
+
"
ms.
"
);
// Do what it's supposed to do once the condition is fulfilled
typeof
(
onReady
)
===
"
string
"
?
eval
(
onReady
)
:
onReady
();
// eslint-disable-line no-eval
clearInterval
(
interval
);
//< Stop this interval
}
}
},
100
);
//< repeat check every 100ms
}
if
(
system
.
args
.
length
!==
2
)
{
console
.
log
(
'
Usage: run-jasmine2.js URL
'
);
phantom
.
exit
(
1
);
}
var
page
=
require
(
'
webpage
'
).
create
();
page
.
onConsoleMessage
=
function
(
msg
)
{
// Route "console.log()" calls from within the Page context to the main
// Phantom context (i.e. current "this")
console
.
log
(
msg
);
};
page
.
open
(
system
.
args
[
1
],
function
(
status
){
"
use strict
"
;
if
(
status
!==
"
success
"
)
{
console
.
log
(
"
Unable to access network
"
);
phantom
.
exit
();
}
else
{
waitFor
(
function
(){
return
page
.
evaluate
(
function
(){
return
(
document
.
body
.
querySelector
(
'
.jasmine-symbol-summary .pending
'
)
===
null
&&
document
.
body
.
querySelector
(
'
.jasmine-duration
'
)
!==
null
);
});
},
function
(){
var
exitCode
=
page
.
evaluate
(
function
(){
console
.
log
(
''
);
var
title
=
'
Jasmine
'
;
var
version
=
document
.
body
.
querySelector
(
'
.jasmine-version
'
).
innerText
;
var
duration
=
document
.
body
.
querySelector
(
'
.jasmine-duration
'
).
innerText
;
var
banner
=
title
+
'
'
+
version
+
'
'
+
duration
;
console
.
log
(
banner
);
var
list
=
document
.
body
.
querySelectorAll
(
'
.jasmine-results > .jasmine-failures > .jasmine-spec-detail.jasmine-failed
'
);
if
(
list
&&
list
.
length
>
0
)
{
console
.
log
(
''
);
console
.
log
(
list
.
length
+
'
test(s) FAILED:
'
);
for
(
var
i
=
0
;
i
<
list
.
length
;
++
i
)
{
var
el
=
list
[
i
],
desc
=
el
.
querySelector
(
'
.jasmine-description
'
),
msg
=
el
.
querySelector
(
'
.jasmine-messages > .jasmine-result-message
'
);
console
.
log
(
''
);
console
.
log
(
desc
.
innerText
);
console
.
log
(
msg
.
innerText
);
console
.
log
(
''
);
}
return
1
;
}
else
{
console
.
log
(
document
.
body
.
querySelector
(
'
.jasmine-alert > .jasmine-bar.jasmine-passed, .jasmine-alert > .jasmine-bar.skipped
'
).
innerText
);
return
0
;
}
});
phantom
.
exit
(
exitCode
);
});
}
});
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