Open
Description
Hi, we're trying to upgrade from the following:
"@web/test-runner": "^0.14.0",
"@web/test-runner-playwright": "^0.9.0",
"@web/test-runner-visual-regression": "^0.7.1",
to
"@web/test-runner": "^0.20.1",
"@web/test-runner-playwright": "^0.11.0",
"@web/test-runner-visual-regression": "^0.10.0",
and our config is:
import path from 'path';
import { esbuildPlugin } from '@web/dev-server-esbuild';
import { defaultReporter, summaryReporter } from '@web/test-runner';
import { visualRegressionPlugin } from '@web/test-runner-visual-regression/plugin';
function testRunnerHtmlFactory() {
return (testFramework) => `
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="polygerrit-ui/app/styles/main.css">
<link rel="stylesheet" href="polygerrit-ui/app/styles/fonts.css">
<link rel="stylesheet" href="polygerrit-ui/app/styles/material-icons.css">
</head>
<body>
<script type="module" src="${testFramework}"></script>
</body>
</html>
`;
}
const runUnderBazel = !!process.env['RUNFILES_DIR'];
function getModulesDir() {
return runUnderBazel
? [
path.join(process.cwd(), 'external/plugins_npm/node_modules'),
path.join(process.cwd(), 'external/ui_npm/node_modules'),
path.join(process.cwd(), 'external/ui_dev_npm/node_modules'),
]
: [
path.join(process.cwd(), 'plugins/node_modules'),
path.join(process.cwd(), 'app/node_modules'),
path.join(process.cwd(), 'node_modules'),
];
}
function getArgValue(flag) {
const withEquals = process.argv.find((arg) => arg.startsWith(`${flag}=`));
if (withEquals) return withEquals.split('=')[1];
const index = process.argv.indexOf(flag);
if (index !== -1 && process.argv[index + 1] && !process.argv[index + 1].startsWith('--')) {
return process.argv[index + 1];
}
return undefined;
}
const pathPrefix = runUnderBazel ? 'polygerrit-ui/' : '';
const testFiles = getArgValue('--test-files') ?? `${pathPrefix}app/**/*_test.{ts,js}`;
const rootDir = getArgValue('--root-dir') ?? `${path.resolve(process.cwd())}/`;
const tsConfig = getArgValue('--ts-config') ?? `${pathPrefix}app/tsconfig.json`;
/** @type {import('@web/test-runner').TestRunnerConfig} */
const config = {
// TODO: https://g-issues.gerritcodereview.com/issues/365565157 - undo the
// change once the underlying issue is fixed.
concurrency: 1,
files: [
testFiles,
`!${pathPrefix}**/node_modules/**/*`,
...(process.argv.includes('--run-screenshots')
? []
: [`!${pathPrefix}app/**/*_screenshot_test.{ts,js}`]),
],
port: 9876,
nodeResolve: {
modulePaths: getModulesDir(),
},
testFramework: {
config: {
ui: 'tdd',
timeout: 5000,
},
},
plugins: [
esbuildPlugin({
ts: true,
target: 'es2020',
tsconfig: tsConfig,
}),
visualRegressionPlugin({
diffOptions: { threshold: 0.8 },
update: process.argv.includes('--update-screenshots'),
}),
],
// serve from gerrit root directory so that we can serve fonts from
// /lib/fonts/, see middleware.
rootDir,
reporters: [defaultReporter(), summaryReporter()],
middleware: [
// Fonts are in /lib/fonts/, but css tries to load from
// /polygerrit-ui/app/fonts/. In production this works because our build
// copies them over, see /polygerrit-ui/BUILD
async (context, next) => {
if (context.url.startsWith('/polygerrit-ui/app/fonts/')) {
context.url = context.url.replace('/polygerrit-ui/app/', '/lib/');
}
await next();
},
],
testRunnerHtml: testRunnerHtmlFactory(),
};
export default config;
My problem is the test failures are not shown at the bottom. It took me a while to find where the test failure was
�[2K�[1A�[2K�[Gpolygerrit-ui/app/elements/gr-app_test.ts:
🚧 Browser logs:
Lit is in dev mode. Not recommended for production! See https://lit.dev/msg/dev-mode for more information.
initResin
initResin
Multiple versions of Lit loaded. Loading multiple versions is not recommended. See https://lit.dev/msg/multiple-versions for more information.
❌ gr-app callback tests > requestUpdate in reactive-element is called after dispatching 'location-change' event in gr-router
AssertionError: expected false to be true
+ expected - actual
-false
+true
at n4.<anonymous> (polygerrit-ui/app/elements/gr-app_test.ts:40:11)
In the older versions it was shown at the bottom, made easier to discover. How do I get this behaviour back?
Metadata
Metadata
Assignees
Labels
No labels