Skip to content

Commit b62c055

Browse files
committed
chore: replace jasmine-maven-plugin by Jest
The existing JS unit tests are now being run on CI. Part of #1484
1 parent a468d78 commit b62c055

File tree

7 files changed

+18
-60
lines changed

7 files changed

+18
-60
lines changed

.gitignore

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ target/
99
.idea
1010
*.iml
1111

12-
# jasmine-maven-plugin uses phantomjs-maven-plugin.
13-
# phantomjs-maven-plugin creates this log file.
14-
phantomjsdriver.log
15-
1612
# minified resources
1713
src/main/webapp/WEB-INF/static/styles/*.min.css
1814
src/main/javascript/*.min.js

Dangerfile

+1-26
Original file line numberDiff line numberDiff line change
@@ -353,32 +353,6 @@ if File.file?(enforcer_output)
353353
end
354354
end
355355

356-
# Handle `mvn jasmine:test` report
357-
#
358-
# Example:
359-
# <testsuite errors="0" name="jasmine.specs" tests="22" failures="3" skipped="0" hostname="localhost" time="0.0" timestamp="2017-03-09T19:52:06">
360-
# <testcase classname="jasmine" name="CatalogUtils.expandNumbers() should return string without hyphen as it" time="0.0" failure="true">
361-
# <error type="expect.toEqual" message="Expected 'test' to equal '2test'.">Expected 'test' to equal '2test'.</error>
362-
# </testcase>
363-
# </testsuite>
364-
#
365-
jasmine_report = 'target/jasmine/TEST-jasmine.xml'
366-
if File.file?(jasmine_report)
367-
doc = Nokogiri::XML(File.open(jasmine_report))
368-
testsuite = doc.xpath('/testsuite').first
369-
failures = testsuite['failures'].to_i
370-
if failures > 0
371-
testsuite.xpath('.//testcase[@failure="true"]').each do |tc|
372-
# NOTE: unfortunately jasmine report doesn't contain file name
373-
msg = tc.xpath('./error').first.text.sub(/\.$/, '')
374-
testcase = tc['name']
375-
fail("jasmine-maven-plugin error:\nTest case `#{testcase}` fails with message:\n`#{msg}`\n")
376-
end
377-
378-
print_errors_summary 'jasmine-maven-plugin', failures, 'https://github.com/php-coder/mystamps/wiki/unit-tests-js'
379-
end
380-
end
381-
382356
# Handle `html5validator` output
383357
#
384358
# Example:
@@ -406,6 +380,7 @@ if File.file?(validator_output)
406380
end
407381

408382
# @todo #1060 Danger: handle Babel errors from frontend-maven-plugin
383+
# @todo #1484 Danger: handle errors from Jest
409384

410385
# Handle `mvn org.apache.maven.plugins:maven-compiler-plugin:compile` output
411386
# Handle `mvn org.apache.maven.plugins:maven-compiler-plugin:testCompile` output

NEWS.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
0.x (upcoming release)
22

3+
- (infrastructure) port JavaScript unit tests from Jasmine to Jest
34

45
0.4.6
56
- (feature) users can add a comment to a series

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ If you want to run it locally, follow the instructions:
4545
* *Database migrations*: Liquibase
4646
* *Validation*: Hibernate Validator
4747
* *Logging*: Slf4j (Logback)
48-
* *Unit tests*: Groovy with Spock Framework or JUnit (for Java code), jasmine (for JavaScript code)
48+
* *Unit tests*: Groovy with Spock Framework or JUnit (for Java code), Jest (for JavaScript code)
4949
* *Integration tests*: Selenium3, RobotFramework, WireMock
5050
* *Deployment*: bash, Ansible, Terraform
5151
* *Others*: Lombok, Togglz, WebJars, AssertJ

pom.xml

-16
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,6 @@
596596
<htmlunit.version>2.46.0</htmlunit.version>
597597

598598
<jacoco.plugin.version>0.8.6</jacoco.plugin.version>
599-
<jasmine.plugin.version>2.2</jasmine.plugin.version>
600599

601600
<!--
602601
Redefine default value from spring-boot-starter-parent:
@@ -757,21 +756,6 @@
757756
</configuration>
758757
</plugin>
759758

760-
<plugin>
761-
<groupId>com.github.searls</groupId>
762-
<artifactId>jasmine-maven-plugin</artifactId>
763-
<version>${jasmine.plugin.version}</version>
764-
<configuration>
765-
<!--
766-
Remove explicit specifying of version when phantomjs will be available for Linux
767-
https://github.com/searls/jasmine-maven-plugin/issues/278
768-
-->
769-
<phantomjs>
770-
<version>1.9.8</version>
771-
</phantomjs>
772-
</configuration>
773-
</plugin>
774-
775759
<!--
776760
Usage:
777761
./mvnw spotbugs:check (checks the sources and produces report to the console)

src/main/scripts/ci/check-build-and-verify.sh

+10-10
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ POM_STATUS=
6565
BOOTLINT_STATUS=
6666
RFLINT_STATUS=
6767
SHELLCHECK_STATUS=
68-
JASMINE_STATUS=
68+
JEST_STATUS=
6969
HTML_STATUS=
7070
ENFORCER_STATUS=
7171
TEST_STATUS=
@@ -86,7 +86,7 @@ POM_TIME=0
8686
BOOTLINT_TIME=0
8787
RFLINT_TIME=0
8888
SHELLCHECK_TIME=0
89-
JASMINE_TIME=0
89+
JEST_TIME=0
9090
HTML_TIME=0
9191
ENFORCER_TIME=0
9292
TEST_TIME=0
@@ -149,7 +149,7 @@ if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
149149
fi
150150

151151
[ "$AFFECTS_GROOVY_FILES" != 'no' ] || CODENARC_STATUS=skip
152-
[ "$AFFECTS_JS_FILES" != 'no' ] || JASMINE_STATUS=skip
152+
[ "$AFFECTS_JS_FILES" != 'no' ] || JEST_STATUS=skip
153153
fi
154154

155155
if [ "$AFFECTS_TRAVIS_CFG" = 'no' ]; then
@@ -226,12 +226,12 @@ if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
226226
fi
227227
print_status "$SHELLCHECK_STATUS" "$SHELLCHECK_TIME" 'Run shellcheck'
228228

229-
if [ "$JASMINE_STATUS" != 'skip' ]; then
229+
if [ "$JEST_STATUS" != 'skip' ]; then
230230
START_TIME=$SECONDS
231-
"$EXEC_CMD" jasmine >jasmine.log 2>&1 || JASMINE_STATUS=fail
232-
JASMINE_TIME=$((SECONDS - START_TIME))
231+
"$EXEC_CMD" jest >jest.log 2>&1 || JEST_STATUS=fail
232+
JEST_TIME=$((SECONDS - START_TIME))
233233
fi
234-
print_status "$JASMINE_STATUS" "$JASMINE_TIME" 'Run JavaScript unit tests'
234+
print_status "$JEST_STATUS" "$JEST_TIME" 'Run JavaScript unit tests'
235235

236236
if [ "$HTML_STATUS" != 'skip' ]; then
237237
"$EXEC_CMD" html5validator >validator.log 2>&1 || HTML_STATUS=fail
@@ -299,7 +299,7 @@ if [ "$RUN_ONLY_INTEGRATION_TESTS" = 'no' ]; then
299299
[ "$BOOTLINT_STATUS" = 'skip' ] || print_log bootlint.log 'Run bootlint'
300300
[ "$RFLINT_STATUS" = 'skip' ] || print_log rflint.log 'Run robot framework lint'
301301
[ "$SHELLCHECK_STATUS" = 'skip' ] || print_log shellcheck.log 'Run shellcheck'
302-
[ "$JASMINE_STATUS" = 'skip' ] || print_log jasmine.log 'Run JavaScript unit tests'
302+
[ "$JEST_STATUS" = 'skip' ] || print_log jest.log 'Run JavaScript unit tests'
303303
[ "$HTML_STATUS" = 'skip' ] || print_log validator.log 'Run html5validator'
304304
[ "$ENFORCER_STATUS" = 'skip' ] || print_log enforcer.log 'Run maven-enforcer-plugin'
305305
[ "$TEST_STATUS" = 'skip' ] || print_log test.log 'Run unit tests'
@@ -314,8 +314,8 @@ if [ "$DANGER_STATUS" != 'skip' ]; then
314314
print_log danger.log 'Run danger'
315315
fi
316316

317-
rm -f cs.log pmd.log license.log pom.log bootlint.log rflint.log shellcheck.log jasmine.log validator.log enforcer.log test.log codenarc.log spotbugs.log verify.log danger.log ansible_lint.log
317+
rm -f cs.log pmd.log license.log pom.log bootlint.log rflint.log shellcheck.log jest.log validator.log enforcer.log test.log codenarc.log spotbugs.log verify.log danger.log ansible_lint.log
318318

319-
if echo "$CS_STATUS$PMD_STATUS$LICENSE_STATUS$POM_STATUS$BOOTLINT_STATUS$RFLINT_STATUS$SHELLCHECK_STATUS$JASMINE_STATUS$HTML_STATUS$ENFORCER_STATUS$TEST_STATUS$CODENARC_STATUS$SPOTBUGS_STATUS$VERIFY_STATUS$DANGER_STATUS$ANSIBLE_LINT_STATUS" | grep -Fqs 'fail'; then
319+
if echo "$CS_STATUS$PMD_STATUS$LICENSE_STATUS$POM_STATUS$BOOTLINT_STATUS$RFLINT_STATUS$SHELLCHECK_STATUS$JEST_STATUS$HTML_STATUS$ENFORCER_STATUS$TEST_STATUS$CODENARC_STATUS$SPOTBUGS_STATUS$VERIFY_STATUS$DANGER_STATUS$ANSIBLE_LINT_STATUS" | grep -Fqs 'fail'; then
320320
exit 1
321321
fi

src/main/scripts/execute-command.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,12 @@ case ${1:-} in
8888
-Denforcer.skip=true \
8989
-DskipUnitTests=true
9090
;;
91-
'jasmine')
91+
'jest')
9292
exec "$MVN" \
9393
--batch-mode \
94-
jasmine:test
94+
--activate-profiles frontend \
95+
frontend:npm \
96+
-Dfrontend.npm.arguments='test'
9597
;;
9698
'pmd')
9799
exec "$MVN" \
@@ -144,7 +146,7 @@ case ${1:-} in
144146
echo >&2 '- enforcer'
145147
echo >&2 '- html5validator'
146148
echo >&2 '- integration-tests'
147-
echo >&2 '- jasmine'
149+
echo >&2 '- jest'
148150
echo >&2 '- pmd'
149151
echo >&2 '- rflint'
150152
echo >&2 '- shellcheck'

0 commit comments

Comments
 (0)