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
bd9774e4
Commit
bd9774e4
authored
Jun 19, 2019
by
Paul Gascou-Vaillancourt
Committed by
Mike Greiling
Jun 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add watch option to test script
parent
ea1b24cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
scripts/frontend/test.js
scripts/frontend/test.js
+16
-7
No files found.
scripts/frontend/test.js
View file @
bd9774e4
...
...
@@ -5,19 +5,24 @@ const { EOL } = require('os');
const
program
=
require
(
'
commander
'
);
const
chalk
=
require
(
'
chalk
'
);
const
SUCCESS_CODE
=
0
;
const
JEST_ROUTE
=
'
spec/frontend
'
;
const
KARMA_ROUTE
=
'
spec/javascripts
'
;
const
COMMON_ARGS
=
[
'
--colors
'
];
const
JEST_ARGS
=
[
'
--passWithNoTests
'
];
const
KARMA_ARGS
=
[
'
--no-fail-on-empty-test-suite
'
];
const
SUCCESS_CODE
=
0
;
const
jestArgs
=
[...
COMMON_ARGS
,
'
--passWithNoTests
'
];
const
karmaArgs
=
[...
COMMON_ARGS
,
'
--no-fail-on-empty-test-suite
'
];
program
.
version
(
'
0.1.0
'
)
.
usage
(
'
[options] <file ...>
'
)
.
option
(
'
-p, --parallel
'
,
'
Run tests suites in parallel
'
)
.
option
(
'
-w, --watch
'
,
'
Rerun tests when files change (tests will be run in parallel if this enabled)
'
,
)
.
parse
(
process
.
argv
);
const
shouldParallelize
=
program
.
parallel
||
program
.
watch
;
const
isSuccess
=
code
=>
code
===
SUCCESS_CODE
;
const
combineExitCodes
=
codes
=>
{
...
...
@@ -31,7 +36,7 @@ const skipIfFail = fn => code => (isSuccess(code) ? fn() : code);
const
endWithEOL
=
str
=>
(
str
[
str
.
length
-
1
]
===
'
\n
'
?
str
:
`
${
str
}${
EOL
}
`
);
const
runTests
=
paths
=>
{
if
(
program
.
parallel
)
{
if
(
shouldParallelize
)
{
return
Promise
.
all
([
runJest
(
paths
),
runKarma
(
paths
)]).
then
(
combineExitCodes
);
}
else
{
return
runJest
(
paths
).
then
(
skipIfFail
(()
=>
runKarma
(
paths
)));
...
...
@@ -73,11 +78,11 @@ const spawnYarnScript = (cmd, args) => {
};
const
runJest
=
args
=>
{
return
spawnYarnScript
(
'
jest
'
,
[...
JEST_ARGS
,
...
COMMON_ARGS
,
...
toJestArgs
(
args
)]);
return
spawnYarnScript
(
'
jest
'
,
[...
jestArgs
,
...
toJestArgs
(
args
)]);
};
const
runKarma
=
args
=>
{
return
spawnYarnScript
(
'
karma
'
,
[...
KARMA_ARGS
,
...
COMMON_ARGS
,
...
toKarmaArgs
(
args
)]);
return
spawnYarnScript
(
'
karma
'
,
[...
karmaArgs
,
...
toKarmaArgs
(
args
)]);
};
const
replacePath
=
to
=>
path
=>
...
...
@@ -96,6 +101,10 @@ const toKarmaArgs = paths =>
paths
.
reduce
((
acc
,
path
)
=>
acc
.
concat
(
'
-f
'
,
replacePathForKarma
(
path
)),
[]);
const
main
=
paths
=>
{
if
(
program
.
watch
)
{
jestArgs
.
push
(
'
--watch
'
);
karmaArgs
.
push
(
'
--single-run
'
,
'
false
'
,
'
--auto-watch
'
);
}
runTests
(
paths
).
then
(
code
=>
{
console
.
log
(
'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'
);
if
(
isSuccess
(
code
))
{
...
...
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