astro/packages/astro/test/svelte-component.test.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

61 lines
1.4 KiB
JavaScript
Raw Normal View History

import { expect } from 'chai';
import * as cheerio from 'cheerio';
import { isWindows, loadFixture } from './test-utils.js';
describe('Svelte component', () => {
let fixture;
2021-12-22 21:11:05 +00:00
before(async () => {
fixture = await loadFixture({
Migrate to new config (#2962) * wip: config migration * fix: formatting * refactor: projectRoot -> root * refactor: pageUrlFormat -> format * refactor: buildOptions.site -> site * refactor: public -> publicDir * refactor: dist -> outDir * refactor: styleOptions -> style * fix: some dist tests -> outDir * refactor: remove legacyBuild (with TODOs) * refactor: more legacyBuild cleanup * refactor: server host and port * fix: remove experimentalStaticBuild CLI flag * refactor: src -> srcDir * refactor: devOptions.trailing -> trailing * refactor: remove sitemap + related flags * refactor: experimentalSSR -> experimental.ssr * fix: last devOptions * refactor: drafts -> markdown.drafts * fix: TS error on port as const * refactor: remove pages * refactor: more --project-root updates * refactor: markdownOptions -> markdown * fix: remaining type errors * feat: update AstroUserConfig * refactor: update CLI flag mapper + server mapper * fix: loadFixture projectRoot * fix: merge CLI flags before validating / transforming * wip: attempt to fix bad createRouteManifest config * refactor: combine config.base and config.site * fix: skip route manifest test for now * fix: site and base handling * refactor: update failing config testes * fix: build failure * feat: update config types with migration help * chore: update types * fix(deno): update deno fixture * chore: remove config migration logic * chore: remove logLevel * chore: clean-up config types * chore: update config warning * chore: add changeset * Sitemap Integration (#2965) * feat: add sitemap filter config option * feat: add canonicalURL sitemap config option * docs: update sitemap README * fix: update for new config * fix: filter not being applied * chore: changeset Co-authored-by: bholmesdev <hey@bholmes.dev> * fred pass * fix: Astro.resolve typo * fix: public => publicDir Co-authored-by: bholmesdev <hey@bholmes.dev> Co-authored-by: Fred K. Schott <fkschott@gmail.com>
2022-04-02 18:29:59 +00:00
root: './fixtures/svelte-component/',
});
});
2021-12-22 21:11:05 +00:00
describe('build', () => {
before(async () => {
await fixture.build();
});
2021-12-22 21:11:05 +00:00
it('Works with TypeScript', async () => {
const html = await fixture.readFile('/typescript/index.html');
const $ = cheerio.load(html);
2021-12-22 21:11:05 +00:00
expect($('#svelte-ts').text()).to.equal('Hello, TypeScript');
});
it('Works with custom Svelte config', async () => {
const html = await fixture.readFile('/typescript/index.html');
const $ = cheerio.load(html);
expect($('#svelte-custom-ext').text()).to.equal('Hello, Custom Extensions');
});
});
2021-12-22 21:11:05 +00:00
if (isWindows) return;
describe('dev', () => {
let devServer;
2021-12-22 21:11:05 +00:00
before(async () => {
devServer = await fixture.startDevServer();
});
2021-12-22 21:11:05 +00:00
after(async () => {
2022-03-15 12:38:13 +00:00
await devServer.stop();
});
2021-12-22 21:11:05 +00:00
it('scripts proxy correctly', async () => {
const html = await fixture.fetch('/').then((res) => res.text());
const $ = cheerio.load(html);
2021-12-22 21:11:05 +00:00
for (const script of $('script').toArray()) {
const { src } = script.attribs;
2021-12-22 21:11:05 +00:00
if (!src) continue;
2021-12-22 21:11:05 +00:00
expect((await fixture.fetch(src)).status, `404: ${src}`).to.equal(200);
}
});
});
});