File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ if (dns.setDefaultResultOrder) {
2525jasmine . DEFAULT_TIMEOUT_INTERVAL = process . env . PARSE_SERVER_TEST_TIMEOUT || 10000 ;
2626jasmine . getEnv ( ) . addReporter ( new CurrentSpecReporter ( ) ) ;
2727jasmine . getEnv ( ) . addReporter ( new SpecReporter ( ) ) ;
28+ global . normalizeAsyncTests ( ) ;
2829global . on_db = ( db , callback , elseCallback ) => {
2930 if ( process . env . PARSE_SERVER_TEST_DB == db ) {
3031 return callback ( ) ;
Original file line number Diff line number Diff line change @@ -43,4 +43,27 @@ global.displayTestStats = function() {
4343 console . log ( '\n' ) ;
4444} ;
4545
46+ /**
47+ * Wraps test functions that use both `async` and a `done` callback, which Jasmine
48+ * does not support. This converts `async (done) => { ... }` to a promise-based
49+ * function so Jasmine does not throw:
50+ * "An asynchronous before/it/after function was defined with the async keyword
51+ * but also took a done callback."
52+ */
53+ global . normalizeAsyncTests = function ( ) {
54+ const originalSpecConstructor = jasmine . Spec ;
55+ jasmine . Spec = function ( attrs ) {
56+ const spec = new originalSpecConstructor ( attrs ) ;
57+ const originalTestFn = spec . queueableFn . fn ;
58+ if ( originalTestFn . length > 0 ) {
59+ spec . queueableFn . fn = function ( ) {
60+ return new Promise ( ( resolve ) => {
61+ originalTestFn ( resolve ) ;
62+ } ) ;
63+ } ;
64+ }
65+ return spec ;
66+ } ;
67+ } ;
68+
4669module . exports = CurrentSpecReporter ;
You can’t perform that action at this time.
0 commit comments