chore: unify two copies of monotonicTime (#15473)

This commit is contained in:
Dmitry Gozman 2022-07-07 15:59:49 -07:00 committed by GitHub
parent 799d4703bc
commit 738d71ebc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 8 deletions

View File

@ -17,7 +17,7 @@
import fs from 'fs';
import path from 'path';
import type { FullConfig, FullResult, Reporter, Suite, TestCase } from '../../types/testReporter';
import { monotonicTime } from '../util';
import { monotonicTime } from 'playwright-core/lib/utils';
import { formatFailure, formatTestTitle, stripAnsiEscapes } from './base';
class JUnitReporter implements Reporter {

View File

@ -23,7 +23,8 @@ import type { Loader } from './loader';
import type { TestCase } from './test';
import { TimeoutManager } from './timeoutManager';
import type { Annotation, TestStepInternal } from './types';
import { addSuffixToFilePath, getContainedPath, monotonicTime, normalizeAndSaveAttachment, sanitizeForFilePath, serializeError, trimLongString } from './util';
import { addSuffixToFilePath, getContainedPath, normalizeAndSaveAttachment, sanitizeForFilePath, serializeError, trimLongString } from './util';
import { monotonicTime } from 'playwright-core/lib/utils';
export class TestInfoImpl implements TestInfo {
private _addStepImpl: (data: Omit<TestStepInternal, 'complete'>) => TestStepInternal;
@ -177,7 +178,7 @@ export class TestInfoImpl implements TestInfo {
this.status = 'timedOut';
this.errors.push(timeoutError);
}
this.duration = monotonicTime() - this._startTime;
this.duration = (monotonicTime() - this._startTime) | 0;
}
async _runFn(fn: Function, skips?: 'allowSkips'): Promise<TestError | undefined> {

View File

@ -96,11 +96,6 @@ export function serializeError(error: Error | any): TestError {
};
}
export function monotonicTime(): number {
const [seconds, nanoseconds] = process.hrtime();
return seconds * 1000 + (nanoseconds / 1000000 | 0);
}
export type Matcher = (value: string) => boolean;
export type FilePatternFilter = {