Skip to content

Commit 2c79a31

Browse files
authored
feat: Add Node 16 and 18 support (#1598)
2 parents 5c14029 + 21f6e30 commit 2c79a31

File tree

4 files changed

+40
-12
lines changed

4 files changed

+40
-12
lines changed

.github/workflows/ci.yml

+12-4
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,26 @@ jobs:
1717
with:
1818
version: 1
1919
build:
20-
runs-on: ubuntu-18.04
20+
runs-on: ubuntu-latest
2121
timeout-minutes: 30
22-
env:
23-
MONGODB_VERSION: 3.6.9
22+
strategy:
23+
matrix:
24+
include:
25+
- name: Node 14
26+
NODE_VERSION: 14.21.1
27+
- name: Node 16
28+
NODE_VERSION: 16.18.1
29+
- name: Node 18
30+
NODE_VERSION: 18.12.1
31+
fail-fast: false
2432
steps:
2533
- name: Fix usage of insecure GitHub protocol
2634
run: sudo git config --system url."https://github".insteadOf "git://github"
2735
- uses: actions/checkout@v2
2836
- name: Use Node.js
2937
uses: actions/setup-node@v1
3038
with:
31-
node-version: 14
39+
node-version: ${{ matrix.NODE_VERSION }}
3240
- name: Cache Node.js modules
3341
uses: actions/cache@v2
3442
with:

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[![Snyk Badge](https://snyk.io/test/github/parse-community/Parse-SDK-JS/badge.svg)](https://snyk.io/test/github/parse-community/Parse-SDK-JS)
99
[![Coverage](http://codecov.io/github/parse-community/Parse-SDK-JS/coverage.svg?branch=alpha)](http://codecov.io/github/parse-community/Parse-SDK-JS?branch=alpha)
1010

11-
[![Node Version](https://img.shields.io/badge/nodejs-14-green.svg?logo=node.js&style=flat)](https://nodejs.org/)
11+
[![Node Version](https://img.shields.io/badge/nodejs-14,_16,_18-green.svg?logo=node.js&style=flat)](https://nodejs.org/)
1212
[![auto-release](https://img.shields.io/badge/%F0%9F%9A%80-auto--release-9e34eb.svg)](https://github.com/parse-community/parse-dashboard/releases)
1313

1414
[![npm latest version](https://img.shields.io/npm/v/parse/latest.svg)](https://www.npmjs.com/package/parse)

integration/test/helper.js

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ const { TestUtils } = require('parse-server');
1010
const Parse = require('../../node');
1111
const fs = require('fs');
1212
const path = require('path');
13+
const dns = require('dns');
14+
15+
// Ensure localhost resolves to ipv4 address first on node v17+
16+
if (dns.setDefaultResultOrder) {
17+
dns.setDefaultResultOrder('ipv4first');
18+
}
1319

1420
const port = 1337;
1521
const mountPath = '/parse';

src/__tests__/LiveQueryClient-test.js

+21-7
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ describe('LiveQueryClient', () => {
307307
expect(liveQueryClient.subscriptions.size).toBe(1);
308308
});
309309

310-
it('can handle WebSocket error response message', () => {
310+
it('can handle WebSocket error response message', async () => {
311311
const liveQueryClient = new LiveQueryClient({
312312
applicationId: 'applicationId',
313313
serverURL: 'ws://test',
@@ -329,13 +329,17 @@ describe('LiveQueryClient', () => {
329329
isChecked = true;
330330
expect(error).toEqual('error');
331331
});
332-
333-
liveQueryClient._handleWebSocketMessage(event);
332+
try {
333+
liveQueryClient._handleWebSocketMessage(event);
334+
await liveQueryClient.connectPromise;
335+
} catch (error) {
336+
expect(error.message).toEqual('error');
337+
}
334338

335339
expect(isChecked).toBe(true);
336340
});
337341

338-
it('can handle WebSocket error while subscribing', () => {
342+
it('can handle WebSocket error while subscribing', async () => {
339343
const liveQueryClient = new LiveQueryClient({
340344
applicationId: 'applicationId',
341345
serverURL: 'ws://test',
@@ -363,7 +367,12 @@ describe('LiveQueryClient', () => {
363367
expect(error).toEqual('error thrown');
364368
});
365369

366-
liveQueryClient._handleWebSocketMessage(event);
370+
try {
371+
liveQueryClient._handleWebSocketMessage(event);
372+
await Promise.all([subscription.connectPromise, subscription.subscribePromise, liveQueryClient.connectPromise, liveQueryClient.subscribePromise]);
373+
} catch (e) {
374+
expect(e.message).toEqual('error thrown');
375+
}
367376

368377
jest.runOnlyPendingTimers();
369378
expect(isChecked).toBe(true);
@@ -740,7 +749,7 @@ describe('LiveQueryClient', () => {
740749
liveQueryClient._handleWebSocketError(error);
741750
});
742751

743-
it('can handle WebSocket reconnect on error event', () => {
752+
it('can handle WebSocket reconnect on error event', async () => {
744753
const liveQueryClient = new LiveQueryClient({
745754
applicationId: 'applicationId',
746755
serverURL: 'ws://test',
@@ -764,7 +773,12 @@ describe('LiveQueryClient', () => {
764773
expect(error).toEqual(data.error);
765774
});
766775
const spy = jest.spyOn(liveQueryClient, '_handleReconnect');
767-
liveQueryClient._handleWebSocketMessage(event);
776+
try {
777+
liveQueryClient._handleWebSocketMessage(event);
778+
await liveQueryClient.connectPromise;
779+
} catch (e) {
780+
expect(e.message).toBe('Additional properties not allowed');
781+
}
768782

769783
expect(isChecked).toBe(true);
770784
expect(liveQueryClient._handleReconnect).toHaveBeenCalledTimes(1);

0 commit comments

Comments
 (0)