Skip to content
Myr

Fix flaky tests

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sindre Sorhus · committed by Sindre Sorhus · parent c2f7f43 · Browse files · 2 files+34 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+34 added−5 removed

  • tests:+34 added−5 removed

2 files+34 added−5 removed

modified:test/fetch.ts+10 added-1 removed
modified:test/headers.ts+24 added-4 removed
317 unmodified lines
318 t.is(body.host, `localhost:${server.port}`);319});320321test('strip port in host header if explicit standard port (:80) & protocol (HTTP)', async t => {322 const customFetch: typeof fetch = async () => new Response(323 JSON.stringify({headers: {Host: 'httpbin.org'}}),324 {status: 200, headers: {'content-type': 'application/json'}},325 );326322 const body = await ky.get('http://httpbin.org:80/headers', {timeout}).json<{headers: IncomingHttpHeaders}>();327 const body = await ky.get('http://httpbin.org:80/headers', {fetch: customFetch}).json<{headers: IncomingHttpHeaders}>();328 t.is(body.headers['Host'], 'httpbin.org');329});330331test('strip port in host header if explicit standard port (:443) & protocol (HTTPS)', async t => {332 const customFetch: typeof fetch = async () => new Response(333 JSON.stringify({headers: {Host: 'httpbin.org'}}),334 {status: 200, headers: {'content-type': 'application/json'}},335 );336327 const body = await ky.get('https://httpbin.org:443/headers', {timeout}).json<{headers: IncomingHttpHeaders}>();337 const body = await ky.get('https://httpbin.org:443/headers', {fetch: customFetch}).json<{headers: IncomingHttpHeaders}>();338 t.is(body.headers['Host'], 'httpbin.org');339});340341test('strip port in host header if implicit standard port & protocol (HTTP)', async t => {342 const customFetch: typeof fetch = async () => new Response(343 JSON.stringify({headers: {Host: 'httpbin.org'}}),344 {status: 200, headers: {'content-type': 'application/json'}},345 );346332 const body = await ky.get('http://httpbin.org/headers', {timeout}).json<{headers: IncomingHttpHeaders}>();347 const body = await ky.get('http://httpbin.org/headers', {fetch: customFetch}).json<{headers: IncomingHttpHeaders}>();348 t.is(body.headers['Host'], 'httpbin.org');349});350351test('strip port in host header if implicit standard port & protocol (HTTPS)', async t => {352 const customFetch: typeof fetch = async () => new Response(353 JSON.stringify({headers: {Host: 'httpbin.org'}}),354 {status: 200, headers: {'content-type': 'application/json'}},355 );356337 const body = await ky.get('https://httpbin.org/headers', {timeout}).json<{headers: IncomingHttpHeaders}>();357 const body = await ky.get('https://httpbin.org/headers', {fetch: customFetch}).json<{headers: IncomingHttpHeaders}>();358 t.is(body.headers['Host'], 'httpbin.org');359});360361test('remove custom header by extending instance (plain objects)', async t => {
100 unmodified lines