From 2a5a9b0c5bcce7ceed4de8609ae0d0f05908909e Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Sun, 16 Feb 2020 13:42:36 -0500 Subject: [PATCH 1/4] test: use verbose reporter in unit & e2e tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Christopher J. Brody Co-authored-by: Raphael von der Grün --- package.json | 3 ++- tests/spec/component.json | 3 +++ tests/spec/coverage.json | 3 +++ tests/spec/e2e-tests.json | 11 +++++++++++ tests/spec/helper.js | 31 +++++++++++++++++++++++++++++++ tests/spec/unit.json | 3 +++ 6 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tests/spec/e2e-tests.json create mode 100644 tests/spec/helper.js diff --git a/package.json b/package.json index 46410b252..61b8fdfe3 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "test:component": "jasmine --config=tests/spec/component.json", "posttest": "npm run lint", "cover": "nyc jasmine --config=tests/spec/coverage.json", - "e2e-tests": "jasmine tests/spec/create.spec.js", + "e2e-tests": "jasmine --config=tests/spec/e2e-tests.json tests/spec/create.spec.js", "objc-tests": "npm run objc-tests-lib && npm run objc-tests-framework", "objc-tests-lib": "npm run xcodebuild -- -scheme CordovaLibTests", "objc-tests-framework": "npm run xcodebuild -- -scheme CordovaFrameworkApp", @@ -36,6 +36,7 @@ "devDependencies": { "@cordova/eslint-config": "^2.0.0", "jasmine": "^3.4.0", + "jasmine-spec-reporter": "^4.2.1", "nyc": "^14.0.0", "rewire": "^4.0.1", "tmp": "^0.1.0" diff --git a/tests/spec/component.json b/tests/spec/component.json index d8a708abe..81b9feeb9 100644 --- a/tests/spec/component.json +++ b/tests/spec/component.json @@ -3,6 +3,9 @@ "spec_files": [ "component/**/*[sS]pec.js" ], + "helpers": [ + "helper.js" + ], "stopSpecOnExpectationFailure": false, "random": false } diff --git a/tests/spec/coverage.json b/tests/spec/coverage.json index 2ec72bbfc..1aaeb1635 100644 --- a/tests/spec/coverage.json +++ b/tests/spec/coverage.json @@ -4,6 +4,9 @@ "unit/**/*[sS]pec.js", "component/**/*[sS]pec.js" ], + "helpers": [ + "helper.js" + ], "stopSpecOnExpectationFailure": false, "random": false } diff --git a/tests/spec/e2e-tests.json b/tests/spec/e2e-tests.json new file mode 100644 index 000000000..2a6f16add --- /dev/null +++ b/tests/spec/e2e-tests.json @@ -0,0 +1,11 @@ +{ + "spec_dir": "tests/spec", + "spec_files": [ + "create*[sS]pec.js" + ], + "helpers": [ + "helper.js" + ], + "stopSpecOnExpectationFailure": false, + "random": false +} diff --git a/tests/spec/helper.js b/tests/spec/helper.js new file mode 100644 index 000000000..a4a58865f --- /dev/null +++ b/tests/spec/helper.js @@ -0,0 +1,31 @@ +/** + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ +const SpecReporter = require('jasmine-spec-reporter').SpecReporter; + +jasmine.getEnv().clearReporters(); +jasmine.getEnv().addReporter(new SpecReporter({ + spec: { + displayPending: true, + displayDuration: true + }, + summary: { + displayDuration: true, + displayStacktrace: true + } +})); diff --git a/tests/spec/unit.json b/tests/spec/unit.json index b95d161a5..11038fe4e 100644 --- a/tests/spec/unit.json +++ b/tests/spec/unit.json @@ -3,6 +3,9 @@ "spec_files": [ "unit/**/*[sS]pec.js" ], + "helpers": [ + "helper.js" + ], "stopSpecOnExpectationFailure": false, "random": false } From 7d6f9acdab421adbc49dc120a56e01f482484ba9 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Mon, 17 Feb 2020 09:45:11 -0500 Subject: [PATCH 2/4] `npm run objc-tests` last in `npm test` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 61b8fdfe3..b750a456c 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "cordova:platform" ], "scripts": { - "test": "npm run unit-tests && npm run test:component && npm run objc-tests && npm run e2e-tests", + "test": "npm run unit-tests && npm run test:component && npm run e2e-tests && npm run objc-tests", "test:component": "jasmine --config=tests/spec/component.json", "posttest": "npm run lint", "cover": "nyc jasmine --config=tests/spec/coverage.json", From bf8f5a36aaf929921b329c40f20524e992a3431e Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Mon, 17 Feb 2020 09:45:51 -0500 Subject: [PATCH 3/4] adjust spec reporter settings to minimize extra printouts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: エリス Co-authored-by: Christopher J. Brody --- tests/spec/helper.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/spec/helper.js b/tests/spec/helper.js index a4a58865f..7fd8520e1 100644 --- a/tests/spec/helper.js +++ b/tests/spec/helper.js @@ -20,12 +20,23 @@ const SpecReporter = require('jasmine-spec-reporter').SpecReporter; jasmine.getEnv().clearReporters(); jasmine.getEnv().addReporter(new SpecReporter({ + suite: { + displayNumber: true + }, spec: { + displayErrorMessages: true, + displayStacktrace: true, + displaySuccessful: false, + displayFailed: true, displayPending: true, displayDuration: true }, summary: { - displayDuration: true, - displayStacktrace: true + displayErrorMessages: false, + displayStacktrace: false, + displaySuccessful: false, + displayFailed: false, + displayPending: false, + displayDuration: true } })); From 49cf18b8e81b82a9095be761e34d862b4859c39a Mon Sep 17 00:00:00 2001 From: Chris Brody Date: Tue, 18 Feb 2020 07:26:39 -0500 Subject: [PATCH 4/4] Update tests/spec/helper.js - use modern destructuring for import MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: エリス --- tests/spec/helper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/spec/helper.js b/tests/spec/helper.js index 7fd8520e1..2fe4f545f 100644 --- a/tests/spec/helper.js +++ b/tests/spec/helper.js @@ -16,7 +16,7 @@ specific language governing permissions and limitations under the License. */ -const SpecReporter = require('jasmine-spec-reporter').SpecReporter; +const { SpecReporter } = require('jasmine-spec-reporter'); jasmine.getEnv().clearReporters(); jasmine.getEnv().addReporter(new SpecReporter({