-
Notifications
You must be signed in to change notification settings - Fork 786
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41fcbd9
commit 9a873ab
Showing
2 changed files
with
35 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 |
---|---|---|
|
@@ -96,29 +96,43 @@ describe("types", () => { | |
"FAKE RUNTIME", | ||
].join("\n") | ||
); | ||
console.log( | ||
[ | ||
file[0], | ||
file[1], | ||
"FAKE ENV", | ||
"// Begin runtime types", | ||
"FAKE RUNTIME", | ||
].join("\n") | ||
); | ||
|
||
await helper.run(`wrangler types`); | ||
|
||
const file2 = (await readFile(typesPath)).toString(); | ||
|
||
expect(file2).toMatchInlineSnapshot(` | ||
"// Generated by Wrangler by running \`wrangler types\` (hash: e82ba4d7b995dd9ca6fb0332d81f889b) | ||
// Runtime types generated with [email protected] 2023-01-01 no_global_navigator,nodejs_compat | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface,@typescript-eslint/no-empty-object-type | ||
interface Env { | ||
} | ||
// regenerates env types | ||
expect(file2).toContain("interface Env {"); | ||
// uses cached runtime types | ||
expect(file2).toContain("// Begin runtime types"); | ||
expect(file2).toContain("FAKE RUNTIME"); | ||
}); | ||
|
||
// Begin runtime types | ||
FAKE RUNTIME" | ||
`); | ||
it("should prompt you to update types if they've been changed", async () => { | ||
const helper = new WranglerE2ETestHelper(); | ||
await helper.seed(seed); | ||
await helper.run(`wrangler types`); | ||
seed["wrangler.toml"] = dedent` | ||
name = "test-worker" | ||
main = "src/index.ts" | ||
compatibility_date = "2023-01-01" | ||
compatibility_flags = ["nodejs_compat", "no_global_navigator"] | ||
[vars] | ||
BEEP = "BOOP" | ||
`; | ||
await helper.seed(seed); | ||
const worker = helper.runLongLived("wrangler dev"); | ||
await worker.readUntil(/❓ It looks like your types might be out of date./); | ||
seed["wrangler.toml"] = dedent` | ||
name = "test-worker" | ||
main = "src/index.ts" | ||
compatibility_date = "2023-01-01" | ||
compatibility_flags = ["nodejs_compat"] | ||
[vars] | ||
BEEP = "BOOP" | ||
ASDf = "ADSfadsf" | ||
`; | ||
await helper.seed(seed); | ||
await worker.readUntil(/❓ It looks like your types might be out of date./); | ||
}); | ||
}); |
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