Skip to content

Commit 2ff83ae

Browse files
jdforrestermvolz
authored andcommitted
tests: Replace use of preq with native fetch
1 parent be448d0 commit 2ff83ae

File tree

3 files changed

+32
-61
lines changed

3 files changed

+32
-61
lines changed

package-lock.json

Lines changed: 4 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
"eslint-config-wikimedia": "0.28.2",
5959
"mocha": "^10.2.0",
6060
"mocha-lcov-reporter": "^1.3.0",
61-
"nyc": "^15.1.0",
62-
"preq": "^0.5.14"
61+
"nyc": "^15.1.0"
6362
}
6463
}

test/features/tests.js

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
'use strict';
22

3-
const preq = require( 'preq' );
4-
53
const TestServer = require( '../TestServer' );
64
const cluster = require( 'cluster' );
75
const assert = require( 'assert' );
@@ -109,15 +107,18 @@ describe( 'service-runner tests', () => {
109107
const server = new TestServer( `${ __dirname }/../utils/simple_config_no_workers.yaml` );
110108
const response = { status: null, body: null };
111109
return server.start()
112-
.then( () => {
113-
preq.get( { uri: 'http://127.0.0.1:12345' } );
110+
.then( async () => {
111+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
112+
await fetch( 'http://127.0.0.1:12345' );
114113
} )
115114
.delay( 1000 )
116-
.then( () => {
117-
preq.get( { uri: 'http://127.0.0.1:9000' } )
118-
.then( ( res ) => {
115+
.then( async () => {
116+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
117+
await fetch( 'http://127.0.0.1:9000' )
118+
.then( async ( res ) => {
119119
response.status = res.status;
120-
response.body = res.body;
120+
// This is a ReadableStream of a Uint8Array, but we just want the string
121+
response.body = new TextDecoder().decode( await res.arrayBuffer() );
121122
} );
122123
} )
123124
.delay( 1000 )
@@ -135,15 +136,18 @@ describe( 'service-runner tests', () => {
135136
const server = new TestServer( `${ __dirname }/../utils/simple_config_one_worker.yaml` );
136137
const response = { status: null, body: null };
137138
return server.start()
138-
.then( () => {
139-
preq.get( { uri: 'http://127.0.0.1:12345' } );
139+
.then( async () => {
140+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
141+
await fetch( 'http://127.0.0.1:12345' );
140142
} )
141143
.delay( 1000 )
142-
.then( () => {
143-
preq.get( { uri: 'http://127.0.0.1:9000' } )
144-
.then( ( res ) => {
144+
.then( async () => {
145+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
146+
await fetch( 'http://127.0.0.1:9000' )
147+
.then( async ( res ) => {
145148
response.status = res.status;
146-
response.body = res.body;
149+
// This is a ReadableStream of a Uint8Array, but we just want the string
150+
response.body = new TextDecoder().decode( await res.arrayBuffer() );
147151
} );
148152
} )
149153
.delay( 1000 )
@@ -161,15 +165,18 @@ describe( 'service-runner tests', () => {
161165
const server = new TestServer( `${ __dirname }/../utils/simple_config_two_workers.yaml` );
162166
const response = { status: null, body: null };
163167
return server.start()
164-
.then( () => {
165-
preq.get( { uri: 'http://127.0.0.1:12345' } );
168+
.then( async () => {
169+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
170+
await fetch( 'http://127.0.0.1:12345' );
166171
} )
167172
.delay( 1000 )
168-
.then( () => {
169-
preq.get( { uri: 'http://127.0.0.1:9000' } )
170-
.then( ( res ) => {
173+
.then( async () => {
174+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
175+
await fetch( 'http://127.0.0.1:9000' )
176+
.then( async ( res ) => {
171177
response.status = res.status;
172-
response.body = res.body;
178+
// This is a ReadableStream of a Uint8Array, but we just want the string
179+
response.body = new TextDecoder().decode( await res.arrayBuffer() );
173180
} );
174181
} )
175182
.delay( 1000 )

0 commit comments

Comments
 (0)