* Start of work on astroConfig.mode === 'server' * Add tests and more * adapter -> deploy in some places * Add fallback for `adapter` config * Update more tests * Update image tests * Fix clientAddress test * Updates based on PR review * Add a changeset * Update integrations tests + readme * Oops * Remove old option * Rename `mode` to `output` * Update Node adapter test * Update test * fred pass * fred pass * fred pass * fix test Co-authored-by: Fred K. Schott <fkschott@gmail.com>
70 lines
1.9 KiB
JavaScript
70 lines
1.9 KiB
JavaScript
import { expect } from 'chai';
|
|
import { load as cheerioLoad } from 'cheerio';
|
|
import { loadFixture } from './test-utils.js';
|
|
import { viteID } from '../dist/core/util.js';
|
|
|
|
describe('Integration buildConfig hook', () => {
|
|
/** @type {import('./test-utils').Fixture} */
|
|
let fixture;
|
|
|
|
before(async () => {
|
|
let _config;
|
|
fixture = await loadFixture({
|
|
root: './fixtures/ssr-request/',
|
|
output: 'server',
|
|
adapter: {
|
|
name: 'my-ssr-adapter',
|
|
hooks: {
|
|
'astro:config:setup': ({ updateConfig }) => {
|
|
updateConfig({
|
|
vite: {
|
|
plugins: [
|
|
{
|
|
resolveId(id) {
|
|
if (id === '@my-ssr') {
|
|
return id;
|
|
} else if (id === 'astro/app') {
|
|
const viteId = viteID(
|
|
new URL('../dist/core/app/index.js', import.meta.url)
|
|
);
|
|
return viteId;
|
|
}
|
|
},
|
|
load(id) {
|
|
if (id === '@my-ssr') {
|
|
return `import { App } from 'astro/app';export function createExports(manifest) { return { manifest, createApp: () => new App(manifest) }; }`;
|
|
}
|
|
},
|
|
},
|
|
],
|
|
},
|
|
});
|
|
},
|
|
'astro:build:start': ({ buildConfig }) => {
|
|
buildConfig.server = new URL('./dist/.root/server/', _config.root);
|
|
buildConfig.client = new URL('./dist/.root/client/', _config.root);
|
|
},
|
|
'astro:config:done': ({ config, setAdapter }) => {
|
|
_config = config;
|
|
setAdapter({
|
|
name: 'my-ssr-adapter',
|
|
serverEntrypoint: '@my-ssr',
|
|
exports: ['manifest', 'createApp'],
|
|
});
|
|
},
|
|
},
|
|
},
|
|
});
|
|
await fixture.build();
|
|
});
|
|
|
|
it('Puts client files in the client folder', async () => {
|
|
let data = await fixture.readFile('/.root/client/cars.json');
|
|
expect(data).to.not.be.undefined;
|
|
});
|
|
|
|
it('Puts the server entry into the server folder', async () => {
|
|
let data = await fixture.readFile('/.root/server/entry.mjs');
|
|
expect(data).to.not.be.undefined;
|
|
});
|
|
});
|