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",
|
"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": "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: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",
|
"debug:webkit": "web-test-runner --watch --config web-test-runner-webkit.config.mjs",
|
||||||
"format": "npm run format:eslint && npm run format:prettier",
|
"format": "npm run format:eslint && npm run format:prettier",
|
||||||
"format:eslint": "eslint --ext .js,.html . --fix",
|
"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 { 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
|
const groups = (
|
||||||
.readdirSync('packages')
|
await optimisedGlob(['packages/*/test', 'packages/ui/components/**/test'], {
|
||||||
.filter(
|
onlyDirectories: true,
|
||||||
dir => fs.statSync(`packages/${dir}`).isDirectory() && fs.existsSync(`packages/${dir}/test`),
|
})
|
||||||
)
|
).map(dir => ({ name: dir.split('/').at(-2), files: `${dir}/**/*.test.js` }));
|
||||||
.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` })),
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {import('@web/test-runner').TestRunnerConfig['testRunnerHtml']}
|
* @type {import('@web/test-runner').TestRunnerConfig['testRunnerHtml']}
|
||||||
*/
|
*/
|
||||||
const testRunnerHtml = testRunnerImport =>
|
const testRunnerHtmlWithPolyfill = testRunnerImport =>
|
||||||
`
|
`
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|
@ -35,31 +27,21 @@ const testRunnerHtml = testRunnerImport =>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
nodeResolve: { exportConditions: [devMode && 'development'] },
|
nodeResolve: config.shouldRunDevMode ? { exportConditions: ['development'] } : true,
|
||||||
coverageConfig: {
|
coverageConfig: {
|
||||||
report: true,
|
report: true,
|
||||||
reportDir: 'coverage',
|
reportDir: 'coverage',
|
||||||
threshold: {
|
threshold: { statements: 95, functions: 95, branches: 95, lines: 95 },
|
||||||
statements: 95,
|
|
||||||
functions: 95,
|
|
||||||
branches: 95,
|
|
||||||
lines: 95,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
testFramework: {
|
testFramework: {
|
||||||
config: {
|
config: { timeout: '5000' },
|
||||||
timeout: '5000',
|
|
||||||
},
|
},
|
||||||
},
|
testRunnerHtml: config.shouldLoadPolyfill ? testRunnerHtmlWithPolyfill : undefined,
|
||||||
testRunnerHtml,
|
|
||||||
browsers: [
|
browsers: [
|
||||||
playwrightLauncher({ product: 'firefox', concurrency: 1 }),
|
playwrightLauncher({ product: 'firefox', concurrency: 1 }),
|
||||||
playwrightLauncher({ product: 'chromium' }),
|
playwrightLauncher({ product: 'chromium' }),
|
||||||
playwrightLauncher({ product: 'webkit' }),
|
playwrightLauncher({ product: 'webkit' }),
|
||||||
],
|
],
|
||||||
groups: packages.map(pkg => ({
|
groups,
|
||||||
name: pkg.name,
|
|
||||||
files: `${pkg.path}/**/*.test.js`,
|
|
||||||
})),
|
|
||||||
plugins: [litSsrPlugin()],
|
plugins: [litSsrPlugin()],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue