chore: cleanup wtr config, add pkg script for running w/o polyfill
This commit is contained in:
parent
6da73f7a36
commit
faca1916fc
3 changed files with 23 additions and 35 deletions
5
.changeset/empty-students-grow.md
Normal file
5
.changeset/empty-students-grow.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@lion/ui': patch
|
||||
---
|
||||
|
||||
no registration of same class twice w/o scoped-registries polyfill
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
"custom-elements-manifest": "npm run custom-elements-manifest --workspaces --if-present && node ./scripts/create-api-tables.mjs",
|
||||
"debug": "web-test-runner --watch --config web-test-runner-chrome.config.mjs",
|
||||
"debug:firefox": "web-test-runner --watch --config web-test-runner-firefox.config.mjs",
|
||||
"debug:no-scoped-registries-polyfill": "npm run debug -- --no-scoped-registries-polyfill",
|
||||
"debug:webkit": "web-test-runner --watch --config web-test-runner-webkit.config.mjs",
|
||||
"format": "npm run format:eslint && npm run format:prettier",
|
||||
"format:eslint": "eslint --ext .js,.html . --fix",
|
||||
|
|
|
|||
|
|
@ -1,30 +1,22 @@
|
|||
import fs from 'fs';
|
||||
import { playwrightLauncher } from '@web/test-runner-playwright';
|
||||
import { litSsrPlugin } from '@lit-labs/testing/web-test-runner-ssr-plugin.js';
|
||||
import { playwrightLauncher } from '@web/test-runner-playwright';
|
||||
import { optimisedGlob } from 'providence-analytics/utils.js';
|
||||
|
||||
const devMode = process.argv.includes('--dev-mode');
|
||||
const config = {
|
||||
shouldLoadPolyfill: !process.argv.includes('--no-scoped-registries-polyfill'),
|
||||
shouldRunDevMode: process.argv.includes('--dev-mode'),
|
||||
};
|
||||
|
||||
const packages = fs
|
||||
.readdirSync('packages')
|
||||
.filter(
|
||||
dir => fs.statSync(`packages/${dir}`).isDirectory() && fs.existsSync(`packages/${dir}/test`),
|
||||
)
|
||||
.map(dir => ({ name: dir, path: `packages/${dir}/test` }))
|
||||
.concat(
|
||||
fs
|
||||
.readdirSync('packages/ui/components')
|
||||
.filter(
|
||||
dir =>
|
||||
fs.statSync(`packages/ui/components/${dir}`).isDirectory() &&
|
||||
fs.existsSync(`packages/ui/components/${dir}/test`),
|
||||
)
|
||||
.map(dir => ({ name: dir, path: `packages/ui/components/${dir}/test` })),
|
||||
);
|
||||
const groups = (
|
||||
await optimisedGlob(['packages/*/test', 'packages/ui/components/**/test'], {
|
||||
onlyDirectories: true,
|
||||
})
|
||||
).map(dir => ({ name: dir.split('/').at(-2), files: `${dir}/**/*.test.js` }));
|
||||
|
||||
/**
|
||||
* @type {import('@web/test-runner').TestRunnerConfig['testRunnerHtml']}
|
||||
*/
|
||||
const testRunnerHtml = testRunnerImport =>
|
||||
const testRunnerHtmlWithPolyfill = testRunnerImport =>
|
||||
`
|
||||
<html>
|
||||
<head>
|
||||
|
|
@ -35,31 +27,21 @@ const testRunnerHtml = testRunnerImport =>
|
|||
`;
|
||||
|
||||
export default {
|
||||
nodeResolve: { exportConditions: [devMode && 'development'] },
|
||||
nodeResolve: config.shouldRunDevMode ? { exportConditions: ['development'] } : true,
|
||||
coverageConfig: {
|
||||
report: true,
|
||||
reportDir: 'coverage',
|
||||
threshold: {
|
||||
statements: 95,
|
||||
functions: 95,
|
||||
branches: 95,
|
||||
lines: 95,
|
||||
},
|
||||
threshold: { statements: 95, functions: 95, branches: 95, lines: 95 },
|
||||
},
|
||||
testFramework: {
|
||||
config: {
|
||||
timeout: '5000',
|
||||
config: { timeout: '5000' },
|
||||
},
|
||||
},
|
||||
testRunnerHtml,
|
||||
testRunnerHtml: config.shouldLoadPolyfill ? testRunnerHtmlWithPolyfill : undefined,
|
||||
browsers: [
|
||||
playwrightLauncher({ product: 'firefox', concurrency: 1 }),
|
||||
playwrightLauncher({ product: 'chromium' }),
|
||||
playwrightLauncher({ product: 'webkit' }),
|
||||
],
|
||||
groups: packages.map(pkg => ({
|
||||
name: pkg.name,
|
||||
files: `${pkg.path}/**/*.test.js`,
|
||||
})),
|
||||
groups,
|
||||
plugins: [litSsrPlugin()],
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue