From d6053b92697cf9382bc9a972e7be05e629939270 Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Sat, 30 Oct 2021 18:55:11 +0200 Subject: [PATCH 1/5] reduce timeout --- spec/ParseLiveQuery.spec.js | 2 +- spec/ParseUser.spec.js | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/spec/ParseLiveQuery.spec.js b/spec/ParseLiveQuery.spec.js index e5858c98982..1ba1cacbcca 100644 --- a/spec/ParseLiveQuery.spec.js +++ b/spec/ParseLiveQuery.spec.js @@ -970,7 +970,7 @@ describe('ParseLiveQuery', function () { user.set('foo', 'bar'); await user.save(); await user.destroy(); - await new Promise(resolve => setTimeout(resolve, 500)); + await new Promise(resolve => setTimeout(resolve, 10)); for (const key of events) { expect(calls[key]).toHaveBeenCalled(); } diff --git a/spec/ParseUser.spec.js b/spec/ParseUser.spec.js index bcfbd07e2c8..18d2f302623 100644 --- a/spec/ParseUser.spec.js +++ b/spec/ParseUser.spec.js @@ -3968,16 +3968,15 @@ describe('Parse.User testing', () => { user.set('yolo', 'bar'); await user.save(); user.unset('foo'); - await user.save(); await user.destroy(); - await new Promise(resolve => setTimeout(resolve, 500)); + await new Promise(resolve => setTimeout(resolve, 10)); for (const key of events) { expect(calls[key]).toHaveBeenCalled(); } subscription.unsubscribe(); const client = await Parse.CoreManager.getLiveQueryController().getDefaultLiveQueryClient(); client.close(); - await new Promise(resolve => setTimeout(resolve, 500)); + await new Promise(resolve => setTimeout(resolve, 10)); }); describe('issue #4897', () => { From ef055eb495dc74e6d462615f8458095ab431f6f9 Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Sat, 30 Oct 2021 18:55:55 +0200 Subject: [PATCH 2/5] remove unnecessary code --- spec/ParseLiveQuery.spec.js | 2 -- spec/ParseUser.spec.js | 1 - 2 files changed, 3 deletions(-) diff --git a/spec/ParseLiveQuery.spec.js b/spec/ParseLiveQuery.spec.js index 1ba1cacbcca..906d5daf029 100644 --- a/spec/ParseLiveQuery.spec.js +++ b/spec/ParseLiveQuery.spec.js @@ -967,8 +967,6 @@ describe('ParseLiveQuery', function () { await user.save(); user.set('yolo', 'bar'); await user.save(); - user.set('foo', 'bar'); - await user.save(); await user.destroy(); await new Promise(resolve => setTimeout(resolve, 10)); for (const key of events) { diff --git a/spec/ParseUser.spec.js b/spec/ParseUser.spec.js index 18d2f302623..49456d2ea79 100644 --- a/spec/ParseUser.spec.js +++ b/spec/ParseUser.spec.js @@ -3967,7 +3967,6 @@ describe('Parse.User testing', () => { await user.save(); user.set('yolo', 'bar'); await user.save(); - user.unset('foo'); await user.destroy(); await new Promise(resolve => setTimeout(resolve, 10)); for (const key of events) { From 3c3f42d84b71bc3eb1e5fbfc6ae7cedfc7ff44ee Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Sat, 30 Oct 2021 18:57:43 +0200 Subject: [PATCH 3/5] remove dependency range --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4a0cd9928a2..83e9fd46511 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "form-data": "3.0.0", "husky": "4.2.5", "jasmine": "3.5.0", - "jasmine-spec-reporter": "^7.0.0", + "jasmine-spec-reporter": "7.0.0", "jsdoc": "3.6.7", "jsdoc-babel": "0.5.0", "lint-staged": "10.2.3", From 30451e2c1c633f01f3aa67fe5b7b558f50b7ab9d Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Sat, 30 Oct 2021 18:59:31 +0200 Subject: [PATCH 4/5] remove empty line --- spec/ParseUser.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/ParseUser.spec.js b/spec/ParseUser.spec.js index 49456d2ea79..6c02cae7cf3 100644 --- a/spec/ParseUser.spec.js +++ b/spec/ParseUser.spec.js @@ -3960,7 +3960,6 @@ describe('Parse.User testing', () => { subscription.on(key, calls[key]); } const user = await Parse.User._logInWith('facebook'); - user.set('foo', 'bar'); await user.save(); user.unset('foo'); From 703dbd45909af041b003ce58169878908137b529 Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Sat, 30 Oct 2021 19:07:41 +0200 Subject: [PATCH 5/5] refactor spec reporter according to alpha --- spec/helper.js | 17 +++++------------ spec/support/CurrentSpecReporter.js | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 spec/support/CurrentSpecReporter.js diff --git a/spec/helper.js b/spec/helper.js index af59a321826..d9e9b77797c 100644 --- a/spec/helper.js +++ b/spec/helper.js @@ -1,18 +1,11 @@ 'use strict'; +const CurrentSpecReporter = require('./support/CurrentSpecReporter.js'); +const { SpecReporter } = require('jasmine-spec-reporter'); + // Sets up a Parse API server for testing. jasmine.DEFAULT_TIMEOUT_INTERVAL = process.env.PARSE_SERVER_TEST_TIMEOUT || 5000; - -const SpecReporter = require('jasmine-spec-reporter').SpecReporter; - -jasmine.getEnv().clearReporters(); // remove default reporter logs -jasmine.getEnv().addReporter( - new SpecReporter({ - // add jasmine-spec-reporter - spec: { - displayPending: true, - }, - }) -); +jasmine.getEnv().addReporter(new CurrentSpecReporter()); +jasmine.getEnv().addReporter(new SpecReporter()); global.on_db = (db, callback, elseCallback) => { if (process.env.PARSE_SERVER_TEST_DB == db) { diff --git a/spec/support/CurrentSpecReporter.js b/spec/support/CurrentSpecReporter.js new file mode 100644 index 00000000000..3158e21eae2 --- /dev/null +++ b/spec/support/CurrentSpecReporter.js @@ -0,0 +1,15 @@ +// Sets a global variable to the current test spec +// ex: global.currentSpec.description + +global.currentSpec = null; + +class CurrentSpecReporter { + specStarted(spec) { + global.currentSpec = spec; + } + specDone() { + global.currentSpec = null; + } +} + +module.exports = CurrentSpecReporter;