Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Mynij-unit-tests
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
Alexandra Rogova
Mynij-unit-tests
Commits
feaa3ebe
Commit
feaa3ebe
authored
Oct 08, 2019
by
Alexandra Rogova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replaced process usage with puppeteer usage
parent
02450efe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
28 deletions
+34
-28
load_index.js
load_index.js
+34
-28
No files found.
load_index.js
View file @
feaa3ebe
const
puppeteer
=
require
(
'
puppeteer
'
);
var
args
=
require
(
"
yargs
"
)
var
args
=
require
(
"
yargs
"
)
.
usage
(
"
Usage : load_index.js -saveAs metadata/attachment -file file_path
"
)
.
usage
(
"
Usage : load_index.js -saveAs metadata/attachment -file file_path
"
)
.
demandOption
([
'
file
'
])
.
demandOption
([
'
file
'
])
.
demandOption
([
'
saveAs
'
])
.
demandOption
([
'
saveAs
'
])
.
alias
(
"
f
"
,
"
file
"
)
.
alias
(
"
f
"
,
"
file
"
)
.
alias
(
"
s
"
,
"
saveAs
"
)
.
alias
(
"
s
"
,
"
saveAs
"
)
.
describe
(
"
file
"
,
"
file containing content to put in the index, data must follow the CSV standard
"
)
.
describe
(
"
file
"
,
"
file containing content to put in the index, data must follow the CSV standard
"
)
.
describe
(
"
saveAs
"
,
"
choose whether to save the index as metadata or attachments in the indexeddb
"
)
.
describe
(
"
saveAs
"
,
"
choose whether to save the index as metadata or attachments in the indexeddb
"
)
.
nargs
(
"
file
"
,
1
)
.
nargs
(
"
file
"
,
1
)
.
nargs
(
"
saveAs
"
,
1
)
.
nargs
(
"
saveAs
"
,
1
)
.
argv
;
.
argv
;
if
(
!
(
args
.
saveAs
===
"
metadata
"
||
args
.
saveAs
===
"
attachment
"
)){
if
(
!
(
args
.
saveAs
===
"
metadata
"
||
args
.
saveAs
===
"
attachment
"
)){
throw
'
Unrecognized save as argument
'
;
throw
'
Unrecognized save as argument
'
;
}
}
var
saveAs
=
args
.
saveAs
;
var
saveAs
=
args
.
saveAs
;
var
browser
;
const
puppeteer
=
require
(
'
puppeteer
'
);
var
browser
,
page
;
const
si
=
require
(
"
systeminformation
"
);
var
Server
=
require
(
'
ws
'
).
Server
;
var
Server
=
require
(
'
ws
'
).
Server
;
var
port
=
9030
;
var
port
=
9030
;
var
ws
=
new
Server
({
port
:
port
});
var
ws
=
new
Server
({
port
:
port
});
ws
.
on
(
'
connection
'
,
function
(
w
){
ws
.
on
(
'
connection
'
,
function
(
w
){
w
.
on
(
'
message
'
,
function
(
msg
){
w
.
on
(
'
message
'
,
function
(
msg
){
console
.
log
(
msg
);
console
.
log
(
msg
);
const
used
=
process
.
memoryUsage
();
page
.
metrics
()
for
(
let
key
in
used
)
{
.
then
(
function
(
values
){
console
.
log
(
`
${
key
}
${
Math
.
round
(
used
[
key
]
/
1024
/
1024
*
100
)
/
100
}
MB`
);
console
.
log
(
values
.
JSHeapUsedSize
/
1024
/
1024
);
}
si
.
mem
(
function
(
data
){
console
.
log
(
data
.
used
/
1024
/
1024
);
});
browser
.
close
();
browser
.
close
();
});
});
w
.
on
(
'
close
'
,
function
()
{
});
ws
.
close
();
w
.
on
(
'
close
'
,
function
()
{
});
ws
.
close
();
});
});
});
(
async
()
=>
{
(
async
()
=>
{
const
used
=
process
.
memoryUsage
();
for
(
let
key
in
used
)
{
console
.
log
(
`
${
key
}
${
Math
.
round
(
used
[
key
]
/
1024
/
1024
*
100
)
/
100
}
MB`
);
}
browser
=
await
puppeteer
.
launch
();
browser
=
await
puppeteer
.
launch
();
const
page
=
await
browser
.
newPage
();
page
=
await
browser
.
newPage
();
var
metrics
=
await
page
.
metrics
();
console
.
log
(
metrics
.
JSHeapUsedSize
/
1024
/
1024
);
si
.
mem
(
function
(
data
){
console
.
log
(
data
.
used
/
1024
/
1024
);
});
await
page
.
goto
(
'
https://softinst115787.host.vifib.net/public/unit_tests/index_load.html?saveAs=
'
+
saveAs
);
await
page
.
goto
(
'
https://softinst115787.host.vifib.net/public/unit_tests/index_load.html?saveAs=
'
+
saveAs
);
const
[
fileChooser
]
=
await
Promise
.
all
([
const
[
fileChooser
]
=
await
Promise
.
all
([
page
.
waitForFileChooser
(),
page
.
waitForFileChooser
(),
...
...
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