Skip to content

Commit 1c021a2

Browse files
committed
adjust for test environments
1 parent ada54bc commit 1c021a2

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

.github/workflows/nodejs.yml

+15-14
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,26 @@ on: [push, pull_request]
44

55
jobs:
66
build:
7-
87
runs-on: ubuntu-latest
98

109
strategy:
1110
matrix:
1211
# 8.x and lower not supported due to lack of URL object
1312
# 10.x not supported with the current version of EJS. If you need it, it will probably run fine
14-
node-version: [14.x, 16.x, 18.x, 19.x]
13+
# 14.x and 15.x are not supported by vitest
14+
# 19.x and up the request UA is `undici` and affected the tests
15+
node-version: [18.x, 19.x, 20.x, 21.x, 22.x]
1516

1617
steps:
17-
- uses: actions/checkout@v1
18-
- name: Use Node.js ${{ matrix.node-version }}
19-
uses: actions/setup-node@v1
20-
with:
21-
node-version: ${{ matrix.node-version }}
22-
- name: npm install, build, and test
23-
run: |
24-
npm install
25-
npm run build --if-present
26-
npm test
27-
env:
28-
CI: true
18+
- uses: actions/checkout@v1
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v1
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
- name: npm install, build, and test
24+
run: |
25+
npm install
26+
npm run build --if-present
27+
npm test
28+
env:
29+
CI: true

test/__tests__/client/request.test.ts

+16-6
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,18 @@ describe('request', () => {
3939
one : 'two'
4040
}).then(function (response: Response) {
4141
expect(response.status).toEqual(200);
42-
expect(JSON.parse(response.body as string)).toEqual({
42+
43+
const body = JSON.parse(response.body as string);
44+
// as of node 19 this became uncidi, I don't want to reject old versions for just this one test issue
45+
delete body.headers['user-agent'];
46+
47+
expect(body).toEqual({
4348
url: '/',
4449
method: 'GET',
4550
body: '',
4651
headers: {
4752
one: 'two',
4853
accept: '*/*',
49-
'user-agent': 'node',
5054
'accept-encoding': 'gzip, deflate',
5155
'accept-language': '*',
5256
'sec-fetch-mode': 'cors',
@@ -69,15 +73,19 @@ describe('request', () => {
6973
one : ['two', 'three']
7074
}).then(function (response: Response) {
7175
expect(response.status).toEqual(200);
72-
expect(JSON.parse(response.body as string)).toEqual({
76+
77+
const body = JSON.parse(response.body as string);
78+
// as of node 19 this became uncidi, I don't want to reject old versions for just this one test issue
79+
delete body.headers['user-agent'];
80+
81+
expect(body).toEqual({
7382
url: '/',
7483
method: 'GET',
7584
body: '',
7685
headers: {
7786
// node fetch doesn't seem to retain dupe arrays, this is what we get.
7887
one: 'two, three',
7988
accept: '*/*',
80-
'user-agent': 'node',
8189
'accept-encoding': 'gzip, deflate',
8290
'accept-language': '*',
8391
connection: 'keep-alive',
@@ -107,7 +115,10 @@ describe('request', () => {
107115
}).then(function (response: Response) {
108116
expect(response.status).toEqual(200);
109117

110-
expect(JSON.parse(response.body as string)).toMatchObject({
118+
const body = JSON.parse(response.body as string);
119+
// as of node 19 this became uncidi, I don't want to reject old versions for just this one test issue
120+
delete body.headers['user-agent'];
121+
expect(body).toMatchObject({
111122
url: '/',
112123
method: 'POST',
113124
body: '{"yeah": "what"}',
@@ -116,7 +127,6 @@ describe('request', () => {
116127
'content-type': 'text/plain;charset=UTF-8',
117128
accept: '*/*',
118129
'content-length': '16',
119-
'user-agent': 'node',
120130
'accept-encoding': 'gzip, deflate',
121131
connection: 'keep-alive',
122132
host: `127.0.0.1:${port}`,

0 commit comments

Comments
 (0)