Skip to content

Commit

Permalink
fix: vite.config for cloudflare adapter miss-configurations (#175)
Browse files Browse the repository at this point in the history
* fix: vite.config for cloudflare adapter missconfigurations

* chore: add e2e tests to the cloudflare generator

* fix: specify a unique port for cloudflare preview

* docs: adjust the comments to the describe group

* chore: temporarily skip serve cloudflare application
  • Loading branch information
NachoVazquez authored Jun 9, 2023
1 parent 3def657 commit d2dd8e0
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 4 deletions.
91 changes: 91 additions & 0 deletions e2e/qwik-nx-e2e/tests/qwik-nx-cloudflare.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import {
checkFilesExist,
ensureNxProject,
runNxCommandAsync,
uniq,
} from '@nx/plugin/testing';

import {
runCommandUntil,
promisifiedTreeKill,
killPort,
killPorts,
DEFAULT_E2E_TIMEOUT,
} from '@qwikifiers/e2e/utils';

const CLOUDFLARE_PREVIEW_PORT = 4300;

describe('qwik nx cloudflare generator', () => {
// Setting up individual workspaces per
// test can cause e2e runs to take a long time.
// For this reason, we recommend each suite only
// consumes 1 workspace. The tests should each operate
// on a unique project in the workspace, such that they
// are not dependant on one another.
beforeAll(async () => {
await killPorts(CLOUDFLARE_PREVIEW_PORT);
ensureNxProject('qwik-nx', 'dist/packages/qwik-nx');
}, 10000);

afterAll(async () => {
// `nx reset` kills the daemon, and performs
// some work which can help clean up e2e leftovers
await runNxCommandAsync('reset');
});

describe('should build and serve a project with the cloudflare adapter', () => {
let project: string;
beforeAll(async () => {
project = uniq('qwik-nx');
await runNxCommandAsync(
`generate qwik-nx:app ${project} --no-interactive`
);
await runNxCommandAsync(
`generate qwik-nx:cloudflare-pages-integration ${project} --no-interactive`
);

// move header component into the library
}, DEFAULT_E2E_TIMEOUT);

it(
'should be able to successfully build the application',
async () => {
const result = await runNxCommandAsync(`build-cloudflare ${project}`);
expect(result.stdout).toContain(
`Successfully ran target build for project ${project}`
);
expect(() =>
checkFilesExist(`dist/apps/${project}/client/q-manifest.json`)
).not.toThrow();
expect(() =>
checkFilesExist(
`dist/apps/${project}/server/entry.cloudflare-pages.js`
)
).not.toThrow();
},
DEFAULT_E2E_TIMEOUT
);

xit(
'should serve application in preview mode with custom port',
async () => {
const p = await runCommandUntil(
`run ${project}:preview-cloudflare --port=${CLOUDFLARE_PREVIEW_PORT}`,
(output) => {
return (
output.includes('Local:') &&
output.includes(`:${CLOUDFLARE_PREVIEW_PORT}`)
);
}
);
try {
await promisifiedTreeKill(p.pid!, 'SIGKILL');
await killPort(CLOUDFLARE_PREVIEW_PORT);
} catch {
// ignore
}
},
DEFAULT_E2E_TIMEOUT
);
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cloudflarePagesAdaptor } from '@builder.io/qwik-city/adapters/cloudflare-pages/vite';
import { cloudflarePagesAdapter } from '@builder.io/qwik-city/adapters/cloudflare-pages/vite';
import { extendConfig } from '@builder.io/qwik-city/vite';
import baseConfig from '../../vite.config';

Expand All @@ -11,9 +11,7 @@ export default extendConfig(baseConfig, () => {
},
},
plugins: [
cloudflarePagesAdaptor({
staticGenerate: true,
}),
cloudflarePagesAdapter(),
],
};
});

0 comments on commit d2dd8e0

Please sign in to comment.