mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-12 11:50:22 +03:00
chore: move html report to package (#10898)
This commit is contained in:
parent
d8abb18c57
commit
a82a3f1128
@ -1,2 +0,0 @@
|
||||
// write something to playwright-core/lib/web/ with webpack
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import type { HTMLReport, TestFileSummary } from '@playwright/test/src/reporters/html';
|
||||
import * as React from 'react';
|
||||
import { msToString } from '../uiUtils';
|
||||
import { msToString } from './uiUtils';
|
||||
import { Chip } from './chip';
|
||||
import { Filter } from './filter';
|
||||
import { Link, ProjectLink } from './links';
|
@ -19,7 +19,7 @@ import ansi2html from 'ansi-to-html';
|
||||
import * as React from 'react';
|
||||
import { TreeItem } from './treeItem';
|
||||
import { TabbedPane } from './tabbedPane';
|
||||
import { msToString } from '../uiUtils';
|
||||
import { msToString } from './uiUtils';
|
||||
import { Chip } from './chip';
|
||||
import { traceImage } from './images';
|
||||
import { AttachmentLink } from './links';
|
41
packages/html-reporter/src/uiUtils.ts
Normal file
41
packages/html-reporter/src/uiUtils.ts
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
export function msToString(ms: number): string {
|
||||
if (!isFinite(ms))
|
||||
return '-';
|
||||
|
||||
if (ms === 0)
|
||||
return '0';
|
||||
|
||||
if (ms < 1000)
|
||||
return ms.toFixed(0) + 'ms';
|
||||
|
||||
const seconds = ms / 1000;
|
||||
if (seconds < 60)
|
||||
return seconds.toFixed(1) + 's';
|
||||
|
||||
const minutes = seconds / 60;
|
||||
if (minutes < 60)
|
||||
return minutes.toFixed(1) + 'm';
|
||||
|
||||
const hours = minutes / 60;
|
||||
if (hours < 24)
|
||||
return hours.toFixed(1) + 'h';
|
||||
|
||||
const days = hours / 24;
|
||||
return days.toFixed(1) + 'd';
|
||||
}
|
@ -23,8 +23,8 @@ const mode = process.env.NODE_ENV === 'production' ? 'production' : 'development
|
||||
module.exports = {
|
||||
mode,
|
||||
entry: {
|
||||
zip: path.resolve(__dirname, '../../../../../node_modules/@zip.js/zip.js/dist/zip-no-worker-inflate.min.js'),
|
||||
app: path.join(__dirname, 'index.tsx'),
|
||||
zip: require.resolve('@zip.js/zip.js/dist/zip-no-worker-inflate.min.js'),
|
||||
app: path.join(__dirname, 'src', 'index.tsx'),
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.ts', '.js', '.tsx', '.jsx']
|
||||
@ -33,7 +33,7 @@ module.exports = {
|
||||
output: {
|
||||
globalObject: 'self',
|
||||
filename: '[name].bundle.js',
|
||||
path: path.resolve(__dirname, '../../../lib/webpack/htmlReport')
|
||||
path: path.resolve(__dirname, '..', 'playwright-core', 'lib', 'webpack', 'htmlReport')
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
@ -57,7 +57,7 @@ module.exports = {
|
||||
plugins: [
|
||||
new HtmlWebPackPlugin({
|
||||
title: 'Playwright Test Report',
|
||||
template: path.join(__dirname, 'index.html'),
|
||||
template: path.join(__dirname, 'src', 'index.html'),
|
||||
inject: true,
|
||||
}),
|
||||
new BundleJsPlugin(),
|
@ -159,7 +159,7 @@ const webPackFiles = [
|
||||
'packages/playwright-core/src/web/traceViewer/webpack.config.js',
|
||||
'packages/playwright-core/src/web/traceViewer/webpack-sw.config.js',
|
||||
'packages/playwright-core/src/web/recorder/webpack.config.js',
|
||||
'packages/playwright-core/src/web/htmlReport/webpack.config.js',
|
||||
'packages/html-reporter/webpack.config.js',
|
||||
];
|
||||
for (const file of webPackFiles) {
|
||||
steps.push({
|
||||
|
@ -238,12 +238,6 @@ DEPS['src/server/trace/viewer/'] = ['src/server/trace/common/', 'src/server/trac
|
||||
// DEPS['src/test/'] = ['src/test/**', 'src/utils/utils.ts', 'src/utils/**', 'src/protocol/channels.ts'];
|
||||
// DEPS['src/test/index.ts'] = [... DEPS['src/test/'], 'src/grid/gridClient.ts' ];
|
||||
|
||||
// HTML report
|
||||
DEPS['src/web/htmlReport/'] = [
|
||||
// 'src/test/**',
|
||||
'src/web/'
|
||||
];
|
||||
|
||||
// Grid
|
||||
DEPS['src/grid/'] = ['src/utils/**', 'src/dispatchers/**', 'src/server/', 'src/client/'];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user