-
Notifications
You must be signed in to change notification settings - Fork 758
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
Implement a testMode for running wrangler's dev function via API #1538
Conversation
🦋 Changeset detectedLatest commit: 1cf7983 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/2980556025/npm-package-wrangler-1538 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/1538/npm-package-wrangler-1538 Or you can use npx https://prerelease-registry.developers.workers.dev/runs/2980556025/npm-package-wrangler-1538 dev path/to/script.js |
Codecov Report
@@ Coverage Diff @@
## main #1538 +/- ##
==========================================
- Coverage 80.18% 74.13% -6.06%
==========================================
Files 92 97 +5
Lines 6224 7070 +846
Branches 1603 1850 +247
==========================================
+ Hits 4991 5241 +250
- Misses 1233 1829 +596
|
6c0b6d5
to
63b3781
Compare
16df463
to
d604c48
Compare
92a9f9e
to
28e2c4b
Compare
43267e1
to
d5eb1bb
Compare
d5eb1bb
to
cca6063
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tentatively approving. thanks for pair reviewing this with me!
logPrefix, | ||
enablePagesAssetsServiceBinding, | ||
}: LocalProps) { | ||
let local: ChildProcess | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this implementation should be shared with the react version as well, it's just so much code
@@ -0,0 +1,18 @@ | |||
import { unstable_dev } from "../api"; | |||
|
|||
jest.unmock("undici"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jest.unmock("undici"); | |
jest["unmock"]("undici"); |
. update imports fix-up this fixture make TS happy an idea make tests pass? fix Pages extract common logic make pages work? fix? remove ability to rebuild in tests remove watching from no-react extract common warnings split up logic common to both startDev and startApiDev remove watchMode from API's esbuild
7cf58cf
to
e3157d8
Compare
@@ -1,15 +1,19 @@ | |||
import { spawnWranglerDev } from "./helpers"; | |||
console.log(spawnWranglerDev); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to land this file in this TODO state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah i've removed this test and added a follow-up to reimplement it with unstable_dev: #1756
let worker: { | ||
fetch: (init?: RequestInit) => Promise<Response | undefined>; | ||
stop: () => Promise<void>; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should export a named type for this rather than requiring users to write out the type by hand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do export:
/**
* unstable_dev starts a wrangler dev server, and returns a promise that resolves with utility functions to interact with it.
* @param {string} script
* @param {DevOptions} options
*/
export declare function unstable_dev(script: string, options?: DevOptions, apiOptions?: DevApiOptions): Promise<{
stop: () => Promise<void>;
fetch: (init?: RequestInit | undefined) => Promise<Response | undefined>;
waitUntilExit: () => Promise<void>;
}>;
I just couldn't figure out how to make the types work within the mono repo 😕
eabec89
to
bbef05b
Compare
Prior to this change,
wrangler.unstable_dev()
would only support running one instance of wrangler at a time, as Ink only lets you render one instance of React. This resulted in test failures in CI.This change creates pure JS/TS versions of these React hooks:
As a side-effect of removing React, tests should run faster in CI.
What we're not supporting (in this PR, anyway):
Follow-up task:
Closes #1432
Closes #1419