Skip to content

Commit

Permalink
add basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
wuls committed Apr 9, 2024
1 parent 2eef3d1 commit 646ba54
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 46 deletions.
42 changes: 1 addition & 41 deletions packages/qwik/src/test-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,47 +30,7 @@ export async function loadFixture(inlineConfig: InlineConfig) {
const qwikDistOptimizerPath = join(qwikDistDir, 'optimizer.mjs');
const qwikCityDistVite = join(qwikCityDistDir, 'vite', 'index.mjs');

const qwikCityVirtualEntry = '@city-ssr-entry';
const entrySsrFileName = 'entry.ssr.tsx';
const qwikCityNotFoundPaths = '@qwik-city-not-found-paths';
const qwikCityStaticPaths = '@qwik-city-static-paths';
const plugins: PluginOption[] = [];
plugins.push({
name: 'devPlugin',
resolveId(id) {
if (id.endsWith(qwikCityVirtualEntry)) {
return qwikCityVirtualEntry;
}
if (id === qwikCityStaticPaths || id === qwikCityNotFoundPaths) {
return './' + id;
}
},
load(id) {
if (id.endsWith(qwikCityVirtualEntry)) {
return `
import { createQwikCity } from '@builder.io/qwik-city/middleware/node';
import qwikCityPlan from '@qwik-city-plan';
import render from '${escapeChars(resolve(appSrcDir, 'entry.ssr'))}';
const { router, notFound } = createQwikCity({
render,
qwikCityPlan,
base:'${basePath}build/',
});
export {
router,
notFound
}
`;
}
if (id.endsWith(qwikCityStaticPaths)) {
return `export function isStaticPath(){ return false; };`;
}
if (id.endsWith(qwikCityNotFoundPaths)) {
const notFoundHtml = getErrorHtml(404, 'Resource Not Found');
return `export function getNotFound(){ return ${JSON.stringify(notFoundHtml)}; };`;
}
},
});

const qwikCityVite: typeof import('@builder.io/qwik-city/vite') = await import(
file(qwikCityDistVite)
Expand Down Expand Up @@ -140,4 +100,4 @@ const isWindows = process.platform === 'win32';

const file = (filePath: string) => {
return isWindows ? pathToFileURL(filePath).toString() : filePath;
};
};
10 changes: 5 additions & 5 deletions packages/qwik/src/vite-basetest.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
// devServer.close();
// });

test('basic', async () => {
// const m = await fixture.fetch('/');
// const html = load(m);
expect(1).toBe(1);
});
// test('basic', async () => {
// const m = await fixture.fetch('/');
// const html = load(m);
// expect(1).toBe(1);
// });

0 comments on commit 646ba54

Please sign in to comment.