@@ -55,7 +55,7 @@ it("can import URL from 'url' in node_compat mode", async () => {
5555describe . each ( [ { cmd : "wrangler dev" } , { cmd : "wrangler dev --remote" } ] ) (
5656 "basic js dev: $cmd" ,
5757 ( { cmd } ) => {
58- it ( `can modify worker during ${ cmd } ` , async ( ) => {
58+ it ( `can modify Worker during ${ cmd } ` , async ( ) => {
5959 const helper = new WranglerE2ETestHelper ( ) ;
6060 await helper . seed ( {
6161 "wrangler.toml" : dedent `
@@ -207,6 +207,104 @@ describe.each([{ cmd: "wrangler dev" }, { cmd: "wrangler dev --remote" }])(
207207 await worker . readUntil ( / E v e n t t r i g g e r e d / ) ;
208208 } ) ;
209209 } ) ;
210+
211+ describe ( "Workers + Assets" , ( ) => {
212+ it ( `can modify User Worker during ${ cmd } ` , async ( ) => {
213+ const helper = new WranglerE2ETestHelper ( ) ;
214+ await helper . seed ( {
215+ "wrangler.toml" : dedent `
216+ name = "${ workerName } "
217+ main = "src/index.ts"
218+ compatibility_date = "2023-01-01"
219+ compatibility_flags = ["nodejs_compat"]
220+
221+ [assets]
222+ directory = "public"
223+ ` ,
224+ "src/index.ts" : dedent `
225+ export default {
226+ fetch(request) {
227+ return new Response("Hello World!")
228+ }
229+ }` ,
230+ "public/readme.md" : dedent `
231+ Welcome to Workers + Assets readme!` ,
232+ "package.json" : dedent `
233+ {
234+ "name": "worker",
235+ "version": "0.0.0",
236+ "private": true
237+ }
238+ ` ,
239+ } ) ;
240+ const worker = helper . runLongLived ( cmd ) ;
241+
242+ const { url } = await worker . waitForReady ( ) ;
243+
244+ await expect (
245+ fetch ( url ) . then ( ( r ) => r . text ( ) )
246+ ) . resolves . toMatchSnapshot ( ) ;
247+
248+ await helper . seed ( {
249+ "src/index.ts" : dedent `
250+ export default {
251+ fetch(request, env) {
252+ return new Response("Updated Worker!")
253+ }
254+ }` ,
255+ } ) ;
256+
257+ await worker . waitForReload ( ) ;
258+
259+ await expect ( fetchText ( url ) ) . resolves . toMatchSnapshot ( ) ;
260+ } ) ;
261+
262+ it ( `can modify assets during ${ cmd } ` , async ( ) => {
263+ const helper = new WranglerE2ETestHelper ( ) ;
264+ await helper . seed ( {
265+ "wrangler.toml" : dedent `
266+ name = "${ workerName } "
267+ main = "src/index.ts"
268+ compatibility_date = "2023-01-01"
269+ compatibility_flags = ["nodejs_compat"]
270+
271+ [assets]
272+ directory = "public"
273+ ` ,
274+ "src/index.ts" : dedent `
275+ export default {
276+ fetch(request) {
277+ return new Response("Hello World!")
278+ }
279+ }` ,
280+ "public/readme.md" : dedent `
281+ Welcome to Workers + Assets readme!` ,
282+ "package.json" : dedent `
283+ {
284+ "name": "worker",
285+ "version": "0.0.0",
286+ "private": true
287+ }
288+ ` ,
289+ } ) ;
290+ const worker = helper . runLongLived ( cmd ) ;
291+
292+ const { url } = await worker . waitForReady ( ) ;
293+
294+ await expect (
295+ fetch ( url ) . then ( ( r ) => r . text ( ) )
296+ ) . resolves . toMatchSnapshot ( ) ;
297+
298+ await helper . seed ( {
299+ "public/readme.md" : dedent `
300+ Welcome to updated Workers + Assets readme!` ,
301+ } ) ;
302+
303+ await worker . waitForReload ( ) ;
304+
305+ await expect ( fetchText ( url ) ) . resolves . toMatchSnapshot ( ) ;
306+ } ) ;
307+ } ) ;
210308 }
211309) ;
212310
0 commit comments