diff --git a/test/fixtures/lit-element/src/components/my-element.js b/test/fixtures/lit-element/src/components/my-element.js index b4a78037783d..d3137c0ba0b1 100644 --- a/test/fixtures/lit-element/src/components/my-element.js +++ b/test/fixtures/lit-element/src/components/my-element.js @@ -24,11 +24,13 @@ export class MyElement extends LitElement { this.reflectedStr = 'default reflected string'; } render() { + let typeofwindow = typeof window.Window; return html`
Testing...
${this.bool ? 'A' : 'B'}
${this.str}
data: ${this.obj.data}
+
${typeofwindow}
`; } } diff --git a/test/ssr-lit.test.js b/test/ssr-lit.test.js new file mode 100644 index 000000000000..c989e3559e71 --- /dev/null +++ b/test/ssr-lit.test.js @@ -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'); + }); +});