Skip to content

Commit

Permalink
Include partytown scripts in SSR manifest (withastro#3686)
Browse files Browse the repository at this point in the history
* Include partytown scripts in SSR manifst

* Adds a changeset
  • Loading branch information
matthewp authored Jun 23, 2022
1 parent 3b9b3b6 commit c99c8be
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/fixtures/ssr-partytown/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'astro/config';
import partytown from '@astrojs/partytown';

// https://astro.build/config
export default defineConfig({
integrations: [partytown()],
});
9 changes: 9 additions & 0 deletions test/fixtures/ssr-partytown/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@test/ssr-partytown",
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "workspace:*",
"@astrojs/partytown": "workspace:*"
}
}
6 changes: 6 additions & 0 deletions test/fixtures/ssr-partytown/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html>
<head><title>testing</title></head>
<body>
<h1>testing</h1>
</body>
</html>
34 changes: 34 additions & 0 deletions test/ssr-partytown.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { expect } from 'chai';
import { load as cheerioLoad } from 'cheerio';
import { loadFixture } from './test-utils.js';
import testAdapter from './test-adapter.js';

describe('Using the Partytown integration in SSR', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;

before(async () => {
fixture = await loadFixture({
root: './fixtures/ssr-partytown/',
adapter: testAdapter(),
experimental: {
ssr: true,
},
});
await fixture.build();
});

it('Has the scripts in the page', async () => {
const app = await fixture.loadTestAdapterApp();
const request = new Request('http://example.com/');
const response = await app.render(request);
const html = await response.text();
const $ = cheerioLoad(html);
expect($('script')).to.have.a.lengthOf(1);
});

it('The partytown scripts are in the manifest', async () => {
const app = await fixture.loadTestAdapterApp();
expect(app.manifest.assets).to.contain('/~partytown/partytown-sw.js');
});
});

0 comments on commit c99c8be

Please sign in to comment.