Skip to content

Commit

Permalink
fix: fetch for node < 18 in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kitop committed Nov 23, 2023
1 parent 337815c commit 7cd8d94
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/build/tests/blobs_upload/tests.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { version as nodeVersion } from 'node:process'

import { BlobsServer, getDeployStore } from '@netlify/blobs'
import { Fixture, normalizeOutput } from '@netlify/testing'
import test from 'ava'
import getPort from 'get-port'
import semver from 'semver'
import tmp from 'tmp-promise'

const TOKEN = 'test'
Expand Down Expand Up @@ -63,7 +66,13 @@ test.serial('blobs upload, uploads files to deploy store', async (t) => {

t.is(t.context.blobRequestCount.set, 3)

const store = getDeployStore({ deployID: 'abc123', siteID: 'test', token: TOKEN })
const storeOpts = { deployID: 'abc123', siteID: 'test', token: TOKEN }
if (semver.lt(nodeVersion, '18.0.0')) {
const nodeFetch = await import('node-fetch')
storeOpts.fetch = nodeFetch.default
}

const store = getDeployStore(storeOpts)

const blob1 = await store.getWithMetadata('something.txt')
t.is(blob1.data, 'some value')
Expand Down

0 comments on commit 7cd8d94

Please sign in to comment.