[cli] Convert DevServer "Unit" suite tests to "Dev" suite tests (#7845)

The `DevServer` class as it's currently implement is not really suitable for unit testing, since it calls `process.exit()` when shutting down the server. This causes Jest to exit prematurely, and prevents tests after these one from running. This was in fact hiding some failing tests. So these tests were ported over to be "Dev" suite tests which spawn a child process of `vc dev` rather than running them in-process, so that the `process.exit()` doesn't exit Jest.
This commit is contained in:
Nathan Rajlich
2022-05-23 16:38:02 -07:00
committed by GitHub
parent a5a990995c
commit 75ea68d445
42 changed files with 388 additions and 444 deletions

View File

@@ -96,10 +96,16 @@ function shouldSkip(name, versions) {
return false;
}
function validateResponseHeaders(res) {
function validateResponseHeaders(res, podId) {
if (res.status < 500) {
expect(res.headers.get('server')).toEqual('Vercel');
expect(res.headers.get('cache-control').length > 0).toBeTruthy();
expect(res.headers.get('x-vercel-id')).toBeTruthy();
expect(res.headers.get('cache-control').length > 0).toBeTruthy;
if (podId) {
expect(
res.headers.get('x-vercel-id').includes(`::${podId}-`)
).toBeTruthy();
}
}
}