forked from laptou/astro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test to verify Lit works in SSR (withastro#3158)
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('Lit integration in SSR', () => { | ||
/** @type {import('./test-utils').Fixture} */ | ||
let fixture; | ||
|
||
before(async () => { | ||
fixture = await loadFixture({ | ||
root: './fixtures/lit-element/', | ||
experimental: { | ||
ssr: true, | ||
}, | ||
adapter: testAdapter(), | ||
}); | ||
await fixture.build(); | ||
}); | ||
|
||
async function fetchHTML(path) { | ||
const app = await fixture.loadTestAdapterApp(); | ||
const request = new Request('http://example.com' + path); | ||
const response = await app.render(request); | ||
const html = await response.text(); | ||
return html; | ||
} | ||
|
||
it('Is able to load', async () => { | ||
const html = await fetchHTML('/'); | ||
const $ = cheerioLoad(html); | ||
expect($('#win').text()).to.equal('function'); | ||
}); | ||
}); |