Skip to content

fix: node 18 native fetch support #344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"types": "lib/index.d.ts",
"dependencies": {
"@pollyjs/adapter-node-http": "6.0.5",
"@pollyjs/adapter-fetch": "6.0.5",
"@pollyjs/core": "6.0.5",
"@pollyjs/persister-fs": "6.0.5",
"@types/pollyjs__adapter-node-http": "2.0.1",
Expand Down
3 changes: 2 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import FetchAdapter from '@pollyjs/adapter-fetch'
import NodeHttpAdapter from '@pollyjs/adapter-node-http'
import { PollyConfig } from '@pollyjs/core'
import FSPersister from '@pollyjs/persister-fs'
Expand Down Expand Up @@ -38,7 +39,7 @@ export class JestPollyConfigService {
const recordingsDirectory = path.join(recordingsRoot, '__recordings__')

return {
adapters: [NodeHttpAdapter],
adapters: [FetchAdapter],
persister: FSPersister,
persisterOptions: {
keepUnusedRequests: false,
Expand Down
5 changes: 4 additions & 1 deletion src/jest-polly.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
import './jest-polly'

import http from 'node:http'
import fetch from 'node-fetch'

import { jestPollyConfigService } from './config'
import { APPLICATION_JSON_MIME } from './constants'
// import fetch from 'node-fetch'

// @ts-ignore
const { fetch } = global

const SECRET_VALUE = 'foobarbaz'
const SECRET_REPLACER = 'x'
Expand Down
1 change: 1 addition & 0 deletions src/jest-polly.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import FetchAdapter from '@pollyjs/adapter-fetch'
import NodeHttpAdapter from '@pollyjs/adapter-node-http'
import { Polly } from '@pollyjs/core'
import FSPersister from '@pollyjs/persister-fs'
Expand Down