-
Notifications
You must be signed in to change notification settings - Fork 773
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
14b9044
commit b2a1791
Showing
8 changed files
with
69 additions
and
73 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
fixtures/vitest-pool-workers-examples/workers-assets-only/README.md
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 @@ | ||
# ✅ workers-with-assets-only | ||
|
||
This example contains assets without a Worker script. | ||
|
||
An asset-only project can only be tested integration-style using the SELF binding, as there is no Worker to import and unit test. |
11 changes: 11 additions & 0 deletions
11
fixtures/vitest-pool-workers-examples/workers-assets-only/public/index.html
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,11 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Hello, World!</title> | ||
</head> | ||
<body> | ||
<h1>Asset index.html</h1> | ||
</body> | ||
</html> |
13 changes: 13 additions & 0 deletions
13
fixtures/vitest-pool-workers-examples/workers-assets-only/test/assets-only.test.ts
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,13 @@ | ||
import { env, SELF } from "cloudflare:test"; | ||
import { describe, expect, it } from "vitest"; | ||
|
||
// There is no Worker so we can't import one and unit test | ||
it("can test asset serving (integration style)", async () => { | ||
let response = await SELF.fetch("http://example.com/index.html"); | ||
expect(await response.text()).toContain("Asset index.html"); | ||
|
||
// no such asset | ||
response = await SELF.fetch("http://example.com/message"); | ||
expect(await response.text()).toBeFalsy(); | ||
expect(response.status).toBe(404); | ||
}); |
4 changes: 4 additions & 0 deletions
4
fixtures/vitest-pool-workers-examples/workers-assets-only/test/tsconfig.json
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,4 @@ | ||
{ | ||
"extends": "../../tsconfig.workerd-test.json", | ||
"include": ["./**/*.ts"] | ||
} |
4 changes: 4 additions & 0 deletions
4
fixtures/vitest-pool-workers-examples/workers-assets-only/tsconfig.json
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,4 @@ | ||
{ | ||
"extends": "../tsconfig.node.json", | ||
"include": ["./*.ts"] | ||
} |
19 changes: 19 additions & 0 deletions
19
fixtures/vitest-pool-workers-examples/workers-assets-only/vitest.config.ts
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,19 @@ | ||
import { defineWorkersProject } from "@cloudflare/vitest-pool-workers/config"; | ||
|
||
export default defineWorkersProject({ | ||
test: { | ||
poolOptions: { | ||
workers: { | ||
wrangler: { configPath: "./wrangler.toml" }, | ||
miniflare: { | ||
assets: { | ||
directory: "./public", | ||
assetConfig: { | ||
html_handling: "none", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); |
8 changes: 8 additions & 0 deletions
8
fixtures/vitest-pool-workers-examples/workers-assets-only/wrangler.toml
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,8 @@ | ||
#:schema node_modules/wrangler/config-schema.json | ||
name = "workers-static-assets-only" | ||
compatibility_date = "2024-09-19" | ||
compatibility_flags = ["nodejs_compat"] | ||
|
||
[assets] | ||
directory = "./public" | ||
html_handling = "none" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.