-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(remix-node): replace extended classes for
NodeRequest
& `NodeR…
…esponse` with interface type casts (#7109) Co-authored-by: Michaël De Boey <[email protected]> Co-authored-by: Michaël De Boey <[email protected]>
- Loading branch information
1 parent
b788f34
commit 9543712
Showing
5 changed files
with
82 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@remix-run/node": patch | ||
--- | ||
|
||
ensures fetch() return is instanceof global Response by removing extended classes for NodeRequest and NodeResponse in favor of custom interface type cast. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,6 +230,7 @@ | |
- jaydiablo | ||
- jca41 | ||
- jdeniau | ||
- jeeyoungk | ||
- JeffBeltran | ||
- jenseng | ||
- jeremyjfleming | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { test, expect } from "@playwright/test"; | ||
|
||
import type { Fixture, AppFixture } from "./helpers/create-fixture"; | ||
import { createAppFixture, createFixture, js } from "./helpers/create-fixture"; | ||
|
||
let fixture: Fixture; | ||
let appFixture: AppFixture; | ||
|
||
test.beforeAll(async () => { | ||
fixture = await createFixture({ | ||
files: { | ||
"app/routes/_index.tsx": js` | ||
import { json } from "@remix-run/node"; | ||
import { useLoaderData } from "@remix-run/react"; | ||
export async function loader() { | ||
const resp = await fetch('https://reqres.in/api/users?page=2'); | ||
return (resp instanceof Response) ? 'is an instance of global Response' : 'is not an instance of global Response'; | ||
} | ||
export default function Index() { | ||
let data = useLoaderData(); | ||
return ( | ||
<div> | ||
{data} | ||
</div> | ||
) | ||
} | ||
`, | ||
}, | ||
}); | ||
|
||
appFixture = await createAppFixture(fixture); | ||
}); | ||
|
||
test.afterAll(async () => appFixture.close()); | ||
|
||
test("returned variable from fetch() should be instance of global Response", async () => { | ||
let response = await fixture.requestDocument("/"); | ||
expect(await response.text()).toMatch("is an instance of global Response"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters