-
Notifications
You must be signed in to change notification settings - Fork 763
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 wrangler dev --(experimental-)local
E2E tests
#2365
Conversation
|
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/runs/3937933656/npm-package-wrangler-2365 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/prs/2365/npm-package-wrangler-2365 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/runs/3937933656/npm-package-wrangler-2365 dev path/to/script.js Additional artifacts:npm install https://prerelease-registry.devprod.cloudflare.dev/runs/3937933656/npm-package-cloudflare-pages-shared-2365 |
f6d23aa
to
41eeeb4
Compare
Codecov Report
@@ Coverage Diff @@
## main #2365 +/- ##
==========================================
- Coverage 72.99% 72.97% -0.02%
==========================================
Files 156 156
Lines 9745 9747 +2
Branches 2568 2568
==========================================
Hits 7113 7113
- Misses 2632 2634 +2
|
wrangler dev --(experimental-)local
E2E tests
41eeeb4
to
46fb1f5
Compare
46fb1f5
to
35df364
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.
Very excited for this! Couple small comments (mostly clarification questions)
exitPromise: Promise<number>; | ||
// Exit code of `process` or `undefined` if it hasn't terminated yet | ||
exitCode?: number; |
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.
Are both of these necessary?
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 need some way of knowing if the process has already exited in cleanupSpawnedProcesses
, and you can't inspect Promise
state without await
ing it. We could just have a boolean exited
flag, but this seemed like it could be useful in tests.
const newValue = files["src/value.ts"].replace("= 1", "= 2"); | ||
await fs.writeFile(path.resolve(cwd, "src/value.ts"), newValue); |
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.
I feel like there should be a seed
-like helper function for updating files
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.
Hmmm, seed
could return something like an instance of a RootedFileSystem<FileName extends string>
class, with read
/write
/delete
/replace
methods. But I don't think we'll be replacing files too often for this to be needed? 🤷
35df364
to
5bd46d2
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.
I have no major callouts on this PR. No nits either. Thededent()
is clever
My approval is tentative to @penalosa comments being resolved & checks fixed
[warn] e2e/package.json
[warn] Code style issues found in the above file. Forgot to run Prettier?
Edit: We should look into this framework to use it or if there is anything we can use from it https://github.com/node-modules/clet
5bd46d2
to
f6c55ce
Compare
LGTM! |
Would be awesome to see this merged 👀 |
Hoping this lands in v3 soon 👀 |
Closing in favour of #3344 |
What this PR solves / how to test:
Wrangler has lots of tests, but none that simulate the full user flow for common operations (
npm install
,wrangler dev
,wrangler publish
). This PR adds end-to-end testing forwrangler dev --(experimental-)local
.Importantly, these E2E tests:
wrangler
usingnpm
as a user would, meaning we don't have access towrangler
'sdevDependencies
in testswrangler
with a pseudo-TTY, meaning we can runwrangler
withstdin
in "raw" mode, and test interactive elements like hotkeyswrangler
is listening based onstdout
as a user wouldThe E2E tests in this PR (would) have caught the following issues:
wrangler dev --local
and its lazy imports of@miniflare/tre
#2339)wrangler dev --experimental-local
requires login #2383 (fixed in Remove login requirement from--experimental-local
#2393)wrangler dev --experimental-local
doesn't cleanly shut down the server #2387 (fixed in Allow--experimental-local
to cleanly exit onx
/CTRL-C
#2400)ReferenceError: fetch is not defined
when using--experimental-local
mode on Node 16, and correspondingtsconfg
issues (fixed as part of Untanglewrangler
types 🙈 #2377)--local
modeminiflare-cli
script throws outside of user code,wrangler
hangs onWaiting for the debugger to disconnect...
and doesn't log the error (not yet fixed)--port=0
is used with--local
mode, a new port will be used whenever the user updates their script (not yet fixed)lib
directory from itsnpm
distribution (fixed in@miniflare/tre@3.0.0-next.10
)events.once
leaks signal listener nodejs/node#43337 😅We'll add E2E tests for remote
wrangler dev
andwrangler publish
in the new year.To try out the E2E tests, run
npm build
in the repository root, then change into thee2e
directory, and runnpm test
.Associated docs issues/PR:
N/A
Author has included the following, where applicable:
Changeset(no user facing changes)Reviewer has performed the following, where applicable:
Ref #2351