Update wrangler (#8081)
* chore: update wrangler * chore(cloudflare): update tests to support wrangler@3 * chore(cloudflare): update debug message * chore: force ci
This commit is contained in:
parent
087270c61f
commit
74df833708
8 changed files with 431 additions and 534 deletions
|
@ -52,7 +52,8 @@
|
|||
"astro-scripts": "workspace:*",
|
||||
"chai": "^4.3.7",
|
||||
"cheerio": "1.0.0-rc.12",
|
||||
"kill-port": "^2.0.1",
|
||||
"mocha": "^9.2.2",
|
||||
"wrangler": "^2.0.23"
|
||||
"wrangler": "^3.5.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ describe('Basic app', () => {
|
|||
});
|
||||
await fixture.build();
|
||||
|
||||
cli = runCLI('./fixtures/basics/', { silent: true, port: 8789 });
|
||||
cli = await runCLI('./fixtures/basics/', { silent: true, port: 8789 });
|
||||
await cli.ready;
|
||||
});
|
||||
|
||||
|
@ -23,7 +23,7 @@ describe('Basic app', () => {
|
|||
});
|
||||
|
||||
it('can render', async () => {
|
||||
let res = await fetch(`http://localhost:8789/`);
|
||||
let res = await fetch(`http://127.0.0.1:8789/`);
|
||||
expect(res.status).to.equal(200);
|
||||
let html = await res.text();
|
||||
let $ = cheerio.load(html);
|
||||
|
|
|
@ -17,7 +17,7 @@ describe('Cf metadata and caches', () => {
|
|||
});
|
||||
await fixture.build();
|
||||
|
||||
cli = runCLI('./fixtures/cf/', { silent: false, port: 8788 });
|
||||
cli = await runCLI('./fixtures/cf/', { silent: false, port: 8788 });
|
||||
await cli.ready;
|
||||
});
|
||||
|
||||
|
@ -26,12 +26,12 @@ describe('Cf metadata and caches', () => {
|
|||
});
|
||||
|
||||
it('Load cf and caches API', async () => {
|
||||
let res = await fetch(`http://localhost:8788/`);
|
||||
let res = await fetch(`http://127.0.0.1:8788/`);
|
||||
expect(res.status).to.equal(200);
|
||||
let html = await res.text();
|
||||
let $ = cheerio.load(html);
|
||||
// console.log($('#cf').text(), html);
|
||||
expect($('#cf').text()).to.contain('city');
|
||||
|
||||
expect($('#cf').text()).to.contain('city', `Expected "city" to exist in runtime, but got ${$('#cf').text()}`);
|
||||
expect($('#hasCache').text()).to.equal('true');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -17,7 +17,7 @@ describe('Runtime Locals', () => {
|
|||
});
|
||||
await fixture.build();
|
||||
|
||||
cli = runCLI('./fixtures/runtime/', { silent: true, port: 8793 });
|
||||
cli = await runCLI('./fixtures/runtime/', { silent: true, port: 8793 });
|
||||
await cli.ready;
|
||||
});
|
||||
|
||||
|
@ -26,7 +26,7 @@ describe('Runtime Locals', () => {
|
|||
});
|
||||
|
||||
it('has CF and Caches', async () => {
|
||||
let res = await fetch(`http://localhost:8793/`);
|
||||
let res = await fetch(`http://127.0.0.1:8793/`);
|
||||
expect(res.status).to.equal(200);
|
||||
let html = await res.text();
|
||||
let $ = cheerio.load(html);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { spawn } from 'node:child_process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import kill from 'kill-port';
|
||||
import { loadFixture as baseLoadFixture } from '../../../astro/test/test-utils.js';
|
||||
|
||||
export { fixLineEndings } from '../../../astro/test/test-utils.js';
|
||||
|
@ -21,20 +22,30 @@ const wranglerPath = fileURLToPath(
|
|||
);
|
||||
|
||||
/**
|
||||
* @returns {WranglerCLI}
|
||||
* @returns {Promise<WranglerCLI>}
|
||||
*/
|
||||
export function runCLI(basePath, { silent, port = 8787 }) {
|
||||
export async function runCLI(basePath, { silent, port }) {
|
||||
// Hack: force existing process on port to be killed
|
||||
try {
|
||||
await kill(port, 'tcp');
|
||||
} catch {
|
||||
// Will throw if port is not in use, but that's fine
|
||||
}
|
||||
|
||||
const script = fileURLToPath(new URL(`${basePath}/dist/_worker.js`, import.meta.url));
|
||||
const p = spawn('node', [wranglerPath, 'dev', '-l', script, '--port', port]);
|
||||
const p = spawn('node', [wranglerPath, 'dev', script, '--port', port, '--log-level', 'info', '--persist-to', `${basePath}/.wrangler/state`]);
|
||||
|
||||
p.stderr.setEncoding('utf-8');
|
||||
p.stdout.setEncoding('utf-8');
|
||||
|
||||
const timeout = 10000;
|
||||
const timeout = 10_000;
|
||||
|
||||
const ready = new Promise(async (resolve, reject) => {
|
||||
const failed = setTimeout(
|
||||
() => reject(new Error(`Timed out starting the wrangler CLI`)),
|
||||
() => {
|
||||
p.kill();
|
||||
reject(new Error(`Timed out starting the wrangler CLI`));
|
||||
},
|
||||
timeout
|
||||
);
|
||||
|
||||
|
@ -50,7 +61,7 @@ export function runCLI(basePath, { silent, port = 8787 }) {
|
|||
if (!silent) {
|
||||
console.log(msg);
|
||||
}
|
||||
if (msg.includes(`Listening on`)) {
|
||||
if (msg.includes(`[mf:inf] Ready on`)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ describe('With SolidJS', () => {
|
|||
});
|
||||
await fixture.build();
|
||||
|
||||
cli = runCLI('./fixtures/with-solid-js/', { silent: true, port: 8790 });
|
||||
cli = await runCLI('./fixtures/with-solid-js/', { silent: true, port: 8790 });
|
||||
await cli.ready;
|
||||
});
|
||||
|
||||
|
@ -23,7 +23,7 @@ describe('With SolidJS', () => {
|
|||
});
|
||||
|
||||
it('renders the solid component', async () => {
|
||||
let res = await fetch(`http://localhost:8790/`);
|
||||
let res = await fetch(`http://127.0.0.1:8790/`);
|
||||
expect(res.status).to.equal(200);
|
||||
let html = await res.text();
|
||||
let $ = cheerio.load(html);
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
# for tests only
|
||||
|
||||
send_metrics = false
|
||||
|
||||
[vars]
|
||||
SECRET_STUFF = "secret"
|
||||
|
|
917
pnpm-lock.yaml
917
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue