| 73 | } |
| 74 | |
| 75 | export async function assertWatchesForChanges() { |
| 76 | const entry = './test/fixtures/worker.js'; |
| 77 | let code = `console.log('hello world')`; |
| 78 | await fs.outputFile(entry, code); |
| 79 | const command = new RunCommand({ |
| 80 | entry, |
| 81 | port, |
| 82 | inspect: false, |
| 83 | watch: true, |
| 84 | check: true, |
| 85 | kv: [] |
| 86 | }); |
| 87 | await command.execute(); |
| 88 | let response = await fetch('http://localhost:7000'); |
| 89 | assert.equal(response.status, 503); |
| 90 | |
| 91 | const updated = new Promise(resolve => |
| 92 | command.host.on('worker-updated', resolve) |
| 93 | ); |
| 94 | code = ` |
| 95 | // @ts-ignore |
| 96 | addEventListener('fetch', e => e.respondWith(new Response('', { status: 200 })))`; |
| 97 | await fs.outputFile(entry, code); |
| 98 | await updated; |
| 99 | response = await fetch('http://localhost:7000'); |
| 100 | assert.equal(response.status, 200); |
| 101 | |
| 102 | command.dispose(); |
| 103 | } |
| 104 | |
| 105 | export async function assertCanReadRequestCookieHeader() { |
| 106 | const cookie = 'test cookie'; |