Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions web-dev-server.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import { esbuildPlugin } from '@web/dev-server-esbuild';
import fs from 'node:fs';
import path from 'node:path';

const hasLitParam = process.argv.includes('--lit');
const hasBaseParam = process.argv.includes('--base');

/** @return {import('@web/test-runner').TestRunnerPlugin} */
function generatedLitTestsPlugin() {
export function enforceLitVersionsPlugin(predicate) {
return {
name: 'generated-lit-tests',
name: 'enforce-lit-versions',
transformImport({ source, context }) {
if (context.url.includes('-lit.generated.test.')) {
if (!predicate || predicate(context)) {
const dependencyPath = path.resolve(path.dirname(context.url), source);

const litDependencyPath = dependencyPath
Expand All @@ -23,7 +24,6 @@ function generatedLitTestsPlugin() {
return litDependencyPath;
}
}
return source;
},
};
}
Expand Down Expand Up @@ -92,9 +92,9 @@ export default {
}
},
},
hasLitParam && enforceLitVersionsPlugin(),
// When passing --base flag to `yarn start` command, load base styles and not Lumo
hasBaseParam && enforceBaseStylesPlugin(),
esbuildPlugin({ ts: true }),
generatedLitTestsPlugin(),
].filter(Boolean),
};
6 changes: 5 additions & 1 deletion wtr-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import minimist from 'minimist';
import { execSync } from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import { enforceBaseStylesPlugin } from './web-dev-server.config.js';
import { enforceBaseStylesPlugin, enforceLitVersionsPlugin } from './web-dev-server.config.js';

dotenv.config();

Expand Down Expand Up @@ -269,6 +269,10 @@ const createUnitTestsConfig = (config) => {
},
coverage: hasCoverageParam,
groups,
plugins: [
esbuildPlugin({ ts: true }),
enforceLitVersionsPlugin((context) => context.url.includes('-lit.generated.test.')),
],
testRunnerHtml: getTestRunnerHtml(),
filterBrowserLogs,
};
Expand Down