Skip to content

Commit

Permalink
Fix lit-element tests
Browse files Browse the repository at this point in the history
  • Loading branch information
drwpow committed Oct 22, 2021
1 parent dcd4da8 commit 841fe83
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/astro/test/lit-element.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import { loadFixture } from './test-utils.js';

let fixture;

const NODE_VERSION = parseFloat(process.versions.node);

before(async () => {
// @lit-labs/ssr/ requires Node 13.9 or higher
if (NODE_VERSION < 13.9) {
return;
}
fixture = await loadFixture({
projectRoot: './fixtures/lit-element/',
renderers: ['@astrojs/renderer-lit'],
Expand All @@ -14,8 +20,8 @@ before(async () => {

describe('LitElement test', () => {
it('Renders a custom element by tag name', async () => {
// lit SSR is not currently supported on Node.js < 13
if (process.versions.node <= '13') {
// @lit-labs/ssr/ requires Node 13.9 or higher
if (NODE_VERSION < 13.9) {
return;
}
const html = await fixture.readFile('/index.html');
Expand Down
8 changes: 8 additions & 0 deletions packages/renderers/renderer-lit/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
// NOTE: @lit-labs/ssr uses syntax incompatible with anything < Node v13.9.0.
// Throw an error if using that Node version.

const NODE_VERSION = parseFloat(process.versions.node);
if (NODE_VERSION < 13.9) {
throw new Error(`Package @lit-labs/ssr requires Node version v13.9 or higher. Please update Node to use @astrojs/renderer-lit`);
}

export default {
name: '@astrojs/renderer-lit',
server: './server.js',
Expand Down

0 comments on commit 841fe83

Please sign in to comment.