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
1
Merge Requests
1
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
gitlab-ce
Commits
28bdf020
Commit
28bdf020
authored
May 16, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
f2644063
04794fb4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
10 deletions
+17
-10
spec/frontend/helpers/timeout.js
spec/frontend/helpers/timeout.js
+17
-10
No files found.
spec/frontend/helpers/timeout.js
View file @
28bdf020
let
testTimeoutInMs
;
const
NS_PER_SEC
=
1
e9
;
const
NS_PER_MS
=
1
e6
;
export
const
setTestTimeout
=
newTimeoutInMs
=>
{
testTimeoutInMs
=
newTimeoutInMs
;
jest
.
setTimeout
(
newTimeoutInMs
);
let
testTimeoutNS
;
export
const
setTestTimeout
=
newTimeoutMS
=>
{
testTimeoutNS
=
newTimeoutMS
*
NS_PER_MS
;
jest
.
setTimeout
(
newTimeoutMS
);
};
export
const
initializeTestTimeout
=
defaultTimeout
InMs
=>
{
setTestTimeout
(
defaultTimeout
InMs
);
export
const
initializeTestTimeout
=
defaultTimeout
MS
=>
{
setTestTimeout
(
defaultTimeout
MS
);
let
testStartTime
;
// https://github.com/facebook/jest/issues/6947
beforeEach
(()
=>
{
testStartTime
=
Date
.
now
();
testStartTime
=
process
.
hrtime
();
});
afterEach
(()
=>
{
const
elapsedTimeInMs
=
Date
.
now
()
-
testStartTime
;
if
(
elapsedTimeInMs
>
testTimeoutInMs
)
{
throw
new
Error
(
`Test took too long (
${
elapsedTimeInMs
}
ms >
${
testTimeoutInMs
}
ms)!`
);
const
[
seconds
,
remainingNs
]
=
process
.
hrtime
(
testStartTime
);
const
elapsedNS
=
seconds
*
NS_PER_SEC
+
remainingNs
;
if
(
elapsedNS
>
testTimeoutNS
)
{
throw
new
Error
(
`Test took too long (
${
elapsedNS
/
NS_PER_MS
}
ms >
${
testTimeoutNS
/
NS_PER_MS
}
ms)!`
,
);
}
});
};
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