Skip to content

Commit

Permalink
feat: Add Node 16 and 18 support (#1598)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrezza authored Dec 21, 2022
2 parents 5c14029 + 21f6e30 commit 2c79a31
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 12 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,26 @@ jobs:
with:
version: 1
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
timeout-minutes: 30
env:
MONGODB_VERSION: 3.6.9
strategy:
matrix:
include:
- name: Node 14
NODE_VERSION: 14.21.1
- name: Node 16
NODE_VERSION: 16.18.1
- name: Node 18
NODE_VERSION: 18.12.1
fail-fast: false
steps:
- name: Fix usage of insecure GitHub protocol
run: sudo git config --system url."https://github".insteadOf "git://github"
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 14
node-version: ${{ matrix.NODE_VERSION }}
- name: Cache Node.js modules
uses: actions/cache@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![Snyk Badge](https://snyk.io/test/github/parse-community/Parse-SDK-JS/badge.svg)](https://snyk.io/test/github/parse-community/Parse-SDK-JS)
[![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)

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

[![npm latest version](https://img.shields.io/npm/v/parse/latest.svg)](https://www.npmjs.com/package/parse)
Expand Down
6 changes: 6 additions & 0 deletions integration/test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ const { TestUtils } = require('parse-server');
const Parse = require('../../node');
const fs = require('fs');
const path = require('path');
const dns = require('dns');

// Ensure localhost resolves to ipv4 address first on node v17+
if (dns.setDefaultResultOrder) {
dns.setDefaultResultOrder('ipv4first');
}

const port = 1337;
const mountPath = '/parse';
Expand Down
28 changes: 21 additions & 7 deletions src/__tests__/LiveQueryClient-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ describe('LiveQueryClient', () => {
expect(liveQueryClient.subscriptions.size).toBe(1);
});

it('can handle WebSocket error response message', () => {
it('can handle WebSocket error response message', async () => {
const liveQueryClient = new LiveQueryClient({
applicationId: 'applicationId',
serverURL: 'ws://test',
Expand All @@ -329,13 +329,17 @@ describe('LiveQueryClient', () => {
isChecked = true;
expect(error).toEqual('error');
});

liveQueryClient._handleWebSocketMessage(event);
try {
liveQueryClient._handleWebSocketMessage(event);
await liveQueryClient.connectPromise;
} catch (error) {
expect(error.message).toEqual('error');
}

expect(isChecked).toBe(true);
});

it('can handle WebSocket error while subscribing', () => {
it('can handle WebSocket error while subscribing', async () => {
const liveQueryClient = new LiveQueryClient({
applicationId: 'applicationId',
serverURL: 'ws://test',
Expand Down Expand Up @@ -363,7 +367,12 @@ describe('LiveQueryClient', () => {
expect(error).toEqual('error thrown');
});

liveQueryClient._handleWebSocketMessage(event);
try {
liveQueryClient._handleWebSocketMessage(event);
await Promise.all([subscription.connectPromise, subscription.subscribePromise, liveQueryClient.connectPromise, liveQueryClient.subscribePromise]);
} catch (e) {
expect(e.message).toEqual('error thrown');
}

jest.runOnlyPendingTimers();
expect(isChecked).toBe(true);
Expand Down Expand Up @@ -740,7 +749,7 @@ describe('LiveQueryClient', () => {
liveQueryClient._handleWebSocketError(error);
});

it('can handle WebSocket reconnect on error event', () => {
it('can handle WebSocket reconnect on error event', async () => {
const liveQueryClient = new LiveQueryClient({
applicationId: 'applicationId',
serverURL: 'ws://test',
Expand All @@ -764,7 +773,12 @@ describe('LiveQueryClient', () => {
expect(error).toEqual(data.error);
});
const spy = jest.spyOn(liveQueryClient, '_handleReconnect');
liveQueryClient._handleWebSocketMessage(event);
try {
liveQueryClient._handleWebSocketMessage(event);
await liveQueryClient.connectPromise;
} catch (e) {
expect(e.message).toBe('Additional properties not allowed');
}

expect(isChecked).toBe(true);
expect(liveQueryClient._handleReconnect).toHaveBeenCalledTimes(1);
Expand Down

0 comments on commit 2c79a31

Please sign in to comment.