chore: enforce file extensions on imports (#6202)

* chore: enforce file extensions on imports

To make our output agnostic it should include file extensions in the
output, as per the ESM spec. It's a bit odd for Node packages but makes
it easier to publish a browser build.
This commit is contained in:
Jack Franklin 2020-07-13 10:22:26 +01:00 committed by GitHub
parent 8d6e0d8a79
commit ffec2475d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
79 changed files with 356 additions and 306 deletions

View File

@ -10,7 +10,8 @@ module.exports = {
"plugins": [ "plugins": [
"mocha", "mocha",
"@typescript-eslint", "@typescript-eslint",
"unicorn" "unicorn",
"import"
], ],
"extends": [ "extends": [
@ -88,7 +89,8 @@ module.exports = {
"no-restricted-imports": ["error", { "no-restricted-imports": ["error", {
patterns: ["*Events"], patterns: ["*Events"],
}] }],
"import/extensions": ["error", "ignorePackages"]
}, },
"overrides": [ "overrides": [
{ {

View File

@ -18,9 +18,9 @@ const base = require('./base');
module.exports = { module.exports = {
...base, ...base,
require: ['ts-node/register', './test/mocha-utils.ts'], require: ['./test/mocha-ts-require', './test/mocha-utils.ts'],
spec: 'test/*.spec.ts', spec: 'test/*.spec.ts',
extension: ['ts'], extension: ['js', 'ts'],
parallel: process.env.CI && !process.env.COVERAGE, parallel: process.env.CI && !process.env.COVERAGE,
// retry twice more, so we run each test up to 3 times if needed. // retry twice more, so we run each test up to 3 times if needed.
retries: process.env.CI ? 2 : 0, retries: process.env.CI ? 2 : 0,

View File

@ -8,7 +8,7 @@
"node": ">=10.18.1" "node": ">=10.18.1"
}, },
"scripts": { "scripts": {
"unit": "tsc --version && mocha --config mocha-config/puppeteer-unit-tests.js", "unit": "npm run tsc-cjs && mocha --config mocha-config/puppeteer-unit-tests.js",
"unit-with-coverage": "cross-env COVERAGE=1 npm run unit", "unit-with-coverage": "cross-env COVERAGE=1 npm run unit",
"assert-unit-coverage": "cross-env COVERAGE=1 mocha --config mocha-config/coverage-tests.js", "assert-unit-coverage": "cross-env COVERAGE=1 mocha --config mocha-config/coverage-tests.js",
"funit": "PUPPETEER_PRODUCT=firefox npm run unit", "funit": "PUPPETEER_PRODUCT=firefox npm run unit",
@ -76,6 +76,7 @@
"dependency-cruiser": "^9.7.0", "dependency-cruiser": "^9.7.0",
"eslint": "^6.8.0", "eslint": "^6.8.0",
"eslint-config-prettier": "^6.11.0", "eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-mocha": "^6.3.0", "eslint-plugin-mocha": "^6.3.0",
"eslint-plugin-prettier": "^3.1.3", "eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-unicorn": "^19.0.1", "eslint-plugin-unicorn": "^19.0.1",

View File

@ -33,6 +33,7 @@
* find the one closest to our Chromium revision. * find the one closest to our Chromium revision.
*/ */
// eslint-disable-next-line import/extensions
import { PUPPETEER_REVISIONS } from '../src/revisions'; import { PUPPETEER_REVISIONS } from '../src/revisions';
import { execSync } from 'child_process'; import { execSync } from 'child_process';

View File

@ -25,34 +25,34 @@
* Once we have migrated to API Extractor and removed DocLint we can remove the * Once we have migrated to API Extractor and removed DocLint we can remove the
* duplication and use this file. * duplication and use this file.
*/ */
export * from './common/Accessibility'; export * from './common/Accessibility.js';
export * from './common/Browser'; export * from './common/Browser.js';
export * from './node/BrowserFetcher'; export * from './node/BrowserFetcher.js';
export * from './common/Connection'; export * from './common/Connection.js';
export * from './common/ConsoleMessage'; export * from './common/ConsoleMessage.js';
export * from './common/Coverage'; export * from './common/Coverage.js';
export * from './common/DeviceDescriptors'; export * from './common/DeviceDescriptors.js';
export * from './common/Dialog'; export * from './common/Dialog.js';
export * from './common/DOMWorld'; export * from './common/DOMWorld.js';
export * from './common/JSHandle'; export * from './common/JSHandle.js';
export * from './common/ExecutionContext'; export * from './common/ExecutionContext.js';
export * from './common/EventEmitter'; export * from './common/EventEmitter.js';
export * from './common/FileChooser'; export * from './common/FileChooser.js';
export * from './common/FrameManager'; export * from './common/FrameManager.js';
export * from './common/Input'; export * from './common/Input.js';
export * from './common/Page'; export * from './common/Page.js';
export * from './common/Puppeteer'; export * from './common/Puppeteer.js';
export * from './node/LaunchOptions'; export * from './node/LaunchOptions.js';
export * from './node/Launcher'; export * from './node/Launcher.js';
export * from './common/HTTPRequest'; export * from './common/HTTPRequest.js';
export * from './common/HTTPResponse'; export * from './common/HTTPResponse.js';
export * from './common/SecurityDetails'; export * from './common/SecurityDetails.js';
export * from './common/Target'; export * from './common/Target.js';
export * from './common/Errors'; export * from './common/Errors.js';
export * from './common/Tracing'; export * from './common/Tracing.js';
export * from './common/NetworkManager'; export * from './common/NetworkManager.js';
export * from './common/WebWorker'; export * from './common/WebWorker.js';
export * from './common/USKeyboardLayout'; export * from './common/USKeyboardLayout.js';
export * from './common/EvalTypes'; export * from './common/EvalTypes.js';
export * from './common/TimeoutSettings'; export * from './common/TimeoutSettings.js';
export * from './common/LifecycleWatcher'; export * from './common/LifecycleWatcher.js';

View File

@ -14,8 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
import { CDPSession } from './Connection'; import { CDPSession } from './Connection.js';
import { ElementHandle } from './JSHandle'; import { ElementHandle } from './JSHandle.js';
import { Protocol } from 'devtools-protocol'; import { Protocol } from 'devtools-protocol';
/** /**

View File

@ -14,15 +14,15 @@
* limitations under the License. * limitations under the License.
*/ */
import { assert } from './assert'; import { assert } from './assert.js';
import { helper } from './helper'; import { helper } from './helper.js';
import { Target } from './Target'; import { Target } from './Target.js';
import { EventEmitter } from './EventEmitter'; import { EventEmitter } from './EventEmitter.js';
import { Connection, ConnectionEmittedEvents } from './Connection'; import { Connection, ConnectionEmittedEvents } from './Connection.js';
import { Protocol } from 'devtools-protocol'; import { Protocol } from 'devtools-protocol';
import { Page } from './Page'; import { Page } from './Page.js';
import { ChildProcess } from 'child_process'; import { ChildProcess } from 'child_process';
import { Viewport } from './PuppeteerViewport'; import { Viewport } from './PuppeteerViewport.js';
type BrowserCloseCallback = () => Promise<void> | void; type BrowserCloseCallback = () => Promise<void> | void;

View File

@ -13,15 +13,15 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { assert } from './assert'; import { assert } from './assert.js';
import { debug } from './Debug'; import { debug } from './Debug.js';
const debugProtocolSend = debug('puppeteer:protocol:SEND ►'); const debugProtocolSend = debug('puppeteer:protocol:SEND ►');
const debugProtocolReceive = debug('puppeteer:protocol:RECV ◀'); const debugProtocolReceive = debug('puppeteer:protocol:RECV ◀');
import { Protocol } from 'devtools-protocol'; import { Protocol } from 'devtools-protocol';
import { ProtocolMapping } from 'devtools-protocol/types/protocol-mapping'; import { ProtocolMapping } from 'devtools-protocol/types/protocol-mapping.js';
import { ConnectionTransport } from './ConnectionTransport'; import { ConnectionTransport } from './ConnectionTransport.js';
import { EventEmitter } from './EventEmitter'; import { EventEmitter } from './EventEmitter.js';
interface ConnectionCallback { interface ConnectionCallback {
resolve: Function; resolve: Function;

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { JSHandle } from './JSHandle'; import { JSHandle } from './JSHandle.js';
/** /**
* @public * @public

View File

@ -14,12 +14,12 @@
* limitations under the License. * limitations under the License.
*/ */
import { assert } from './assert'; import { assert } from './assert.js';
import { helper, debugError, PuppeteerEventListener } from './helper'; import { helper, debugError, PuppeteerEventListener } from './helper.js';
import { Protocol } from 'devtools-protocol'; import { Protocol } from 'devtools-protocol';
import { CDPSession } from './Connection'; import { CDPSession } from './Connection.js';
import { EVALUATION_SCRIPT_URL } from './ExecutionContext'; import { EVALUATION_SCRIPT_URL } from './ExecutionContext.js';
/** /**
* The CoverageEntry class represents one entry of the coverage report. * The CoverageEntry class represents one entry of the coverage report.

View File

@ -14,16 +14,19 @@
* limitations under the License. * limitations under the License.
*/ */
import { assert } from './assert'; import { assert } from './assert.js';
import { helper } from './helper'; import { helper } from './helper.js';
import { LifecycleWatcher, PuppeteerLifeCycleEvent } from './LifecycleWatcher'; import {
import { TimeoutError } from './Errors'; LifecycleWatcher,
import { JSHandle, ElementHandle } from './JSHandle'; PuppeteerLifeCycleEvent,
import { ExecutionContext } from './ExecutionContext'; } from './LifecycleWatcher.js';
import { TimeoutSettings } from './TimeoutSettings'; import { TimeoutError } from './Errors.js';
import { MouseButton } from './Input'; import { JSHandle, ElementHandle } from './JSHandle.js';
import { FrameManager, Frame } from './FrameManager'; import { ExecutionContext } from './ExecutionContext.js';
import { getQueryHandlerAndSelector, QueryHandler } from './QueryHandler'; import { TimeoutSettings } from './TimeoutSettings.js';
import { MouseButton } from './Input.js';
import { FrameManager, Frame } from './FrameManager.js';
import { getQueryHandlerAndSelector, QueryHandler } from './QueryHandler.js';
import { import {
SerializableOrJSHandle, SerializableOrJSHandle,
EvaluateHandleFn, EvaluateHandleFn,
@ -31,8 +34,8 @@ import {
EvaluateFn, EvaluateFn,
EvaluateFnReturnType, EvaluateFnReturnType,
UnwrapPromiseLike, UnwrapPromiseLike,
} from './EvalTypes'; } from './EvalTypes.js';
import { isNode } from '../environment'; import { isNode } from '../environment.js';
// This predicateQueryHandler is declared here so that TypeScript knows about it // This predicateQueryHandler is declared here so that TypeScript knows about it
// when it is used in the predicate function below. // when it is used in the predicate function below.

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { isNode } from '../environment'; import { isNode } from '../environment.js';
/** /**
* A debug function that can be used in any environment. * A debug function that can be used in any environment.

View File

@ -14,8 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
import { assert } from './assert'; import { assert } from './assert.js';
import { CDPSession } from './Connection'; import { CDPSession } from './Connection.js';
import { Protocol } from 'devtools-protocol'; import { Protocol } from 'devtools-protocol';
/** /**

View File

@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { CDPSession } from './Connection'; import { CDPSession } from './Connection.js';
import { Viewport } from './PuppeteerViewport'; import { Viewport } from './PuppeteerViewport.js';
import { Protocol } from 'devtools-protocol'; import { Protocol } from 'devtools-protocol';
export class EmulationManager { export class EmulationManager {

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { JSHandle, ElementHandle } from './JSHandle'; import { JSHandle, ElementHandle } from './JSHandle.js';
/** /**
* @public * @public

View File

@ -14,14 +14,14 @@
* limitations under the License. * limitations under the License.
*/ */
import { assert } from './assert'; import { assert } from './assert.js';
import { helper } from './helper'; import { helper } from './helper.js';
import { createJSHandle, JSHandle, ElementHandle } from './JSHandle'; import { createJSHandle, JSHandle, ElementHandle } from './JSHandle.js';
import { CDPSession } from './Connection'; import { CDPSession } from './Connection.js';
import { DOMWorld } from './DOMWorld'; import { DOMWorld } from './DOMWorld.js';
import { Frame } from './FrameManager'; import { Frame } from './FrameManager.js';
import { Protocol } from 'devtools-protocol'; import { Protocol } from 'devtools-protocol';
import { EvaluateHandleFn, SerializableOrJSHandle } from './EvalTypes'; import { EvaluateHandleFn, SerializableOrJSHandle } from './EvalTypes.js';
export const EVALUATION_SCRIPT_URL = '__puppeteer_evaluation_script__'; export const EVALUATION_SCRIPT_URL = '__puppeteer_evaluation_script__';
const SOURCE_URL_REGEX = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m; const SOURCE_URL_REGEX = /^[\040\t]*\/\/[@#] sourceURL=\s*(\S*?)\s*$/m;

View File

@ -14,9 +14,9 @@
* limitations under the License. * limitations under the License.
*/ */
import { ElementHandle } from './JSHandle'; import { ElementHandle } from './JSHandle.js';
import { Protocol } from 'devtools-protocol'; import { Protocol } from 'devtools-protocol';
import { assert } from './assert'; import { assert } from './assert.js';
/** /**
* File choosers let you react to the page requesting for a file. * File choosers let you react to the page requesting for a file.

View File

@ -14,19 +14,22 @@
* limitations under the License. * limitations under the License.
*/ */
import { EventEmitter } from './EventEmitter'; import { EventEmitter } from './EventEmitter.js';
import { assert } from './assert'; import { assert } from './assert.js';
import { helper, debugError } from './helper'; import { helper, debugError } from './helper.js';
import { ExecutionContext, EVALUATION_SCRIPT_URL } from './ExecutionContext'; import { ExecutionContext, EVALUATION_SCRIPT_URL } from './ExecutionContext.js';
import { LifecycleWatcher, PuppeteerLifeCycleEvent } from './LifecycleWatcher'; import {
import { DOMWorld, WaitForSelectorOptions } from './DOMWorld'; LifecycleWatcher,
import { NetworkManager } from './NetworkManager'; PuppeteerLifeCycleEvent,
import { TimeoutSettings } from './TimeoutSettings'; } from './LifecycleWatcher.js';
import { CDPSession } from './Connection'; import { DOMWorld, WaitForSelectorOptions } from './DOMWorld.js';
import { JSHandle, ElementHandle } from './JSHandle'; import { NetworkManager } from './NetworkManager.js';
import { MouseButton } from './Input'; import { TimeoutSettings } from './TimeoutSettings.js';
import { Page } from './Page'; import { CDPSession } from './Connection.js';
import { HTTPResponse } from './HTTPResponse'; import { JSHandle, ElementHandle } from './JSHandle.js';
import { MouseButton } from './Input.js';
import { Page } from './Page.js';
import { HTTPResponse } from './HTTPResponse.js';
import { Protocol } from 'devtools-protocol'; import { Protocol } from 'devtools-protocol';
import { import {
SerializableOrJSHandle, SerializableOrJSHandle,
@ -35,7 +38,7 @@ import {
EvaluateFn, EvaluateFn,
EvaluateFnReturnType, EvaluateFnReturnType,
UnwrapPromiseLike, UnwrapPromiseLike,
} from './EvalTypes'; } from './EvalTypes.js';
const UTILITY_WORLD_NAME = '__puppeteer_utility_world__'; const UTILITY_WORLD_NAME = '__puppeteer_utility_world__';

View File

@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { CDPSession } from './Connection'; import { CDPSession } from './Connection.js';
import { Frame } from './FrameManager'; import { Frame } from './FrameManager.js';
import { HTTPResponse } from './HTTPResponse'; import { HTTPResponse } from './HTTPResponse.js';
import { assert } from './assert'; import { assert } from './assert.js';
import { helper, debugError } from './helper'; import { helper, debugError } from './helper.js';
import { Protocol } from 'devtools-protocol'; import { Protocol } from 'devtools-protocol';
/** /**

View File

@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { CDPSession } from './Connection'; import { CDPSession } from './Connection.js';
import { Frame } from './FrameManager'; import { Frame } from './FrameManager.js';
import { HTTPRequest } from './HTTPRequest'; import { HTTPRequest } from './HTTPRequest.js';
import { SecurityDetails } from './SecurityDetails'; import { SecurityDetails } from './SecurityDetails.js';
import { Protocol } from 'devtools-protocol'; import { Protocol } from 'devtools-protocol';
/** /**

View File

@ -14,9 +14,9 @@
* limitations under the License. * limitations under the License.
*/ */
import { assert } from './assert'; import { assert } from './assert.js';
import { CDPSession } from './Connection'; import { CDPSession } from './Connection.js';
import { keyDefinitions, KeyDefinition, KeyInput } from './USKeyboardLayout'; import { keyDefinitions, KeyDefinition, KeyInput } from './USKeyboardLayout.js';
type KeyDescription = Required< type KeyDescription = Required<
Pick<KeyDefinition, 'keyCode' | 'key' | 'text' | 'code' | 'location'> Pick<KeyDefinition, 'keyCode' | 'key' | 'text' | 'code' | 'location'>

View File

@ -14,14 +14,14 @@
* limitations under the License. * limitations under the License.
*/ */
import { assert } from './assert'; import { assert } from './assert.js';
import { helper, debugError } from './helper'; import { helper, debugError } from './helper.js';
import { ExecutionContext } from './ExecutionContext'; import { ExecutionContext } from './ExecutionContext.js';
import { Page } from './Page'; import { Page } from './Page.js';
import { CDPSession } from './Connection'; import { CDPSession } from './Connection.js';
import { KeyInput } from './USKeyboardLayout'; import { KeyInput } from './USKeyboardLayout.js';
import { FrameManager, Frame } from './FrameManager'; import { FrameManager, Frame } from './FrameManager.js';
import { getQueryHandlerAndSelector } from './QueryHandler'; import { getQueryHandlerAndSelector } from './QueryHandler.js';
import { Protocol } from 'devtools-protocol'; import { Protocol } from 'devtools-protocol';
import { import {
EvaluateFn, EvaluateFn,
@ -30,7 +30,7 @@ import {
EvaluateHandleFn, EvaluateHandleFn,
WrapElementHandle, WrapElementHandle,
UnwrapPromiseLike, UnwrapPromiseLike,
} from './EvalTypes'; } from './EvalTypes.js';
export interface BoxModel { export interface BoxModel {
content: Array<{ x: number; y: number }>; content: Array<{ x: number; y: number }>;

View File

@ -14,14 +14,18 @@
* limitations under the License. * limitations under the License.
*/ */
import { assert } from './assert'; import { assert } from './assert.js';
import { helper, PuppeteerEventListener } from './helper'; import { helper, PuppeteerEventListener } from './helper.js';
import { TimeoutError } from './Errors'; import { TimeoutError } from './Errors.js';
import { FrameManager, Frame, FrameManagerEmittedEvents } from './FrameManager'; import {
import { HTTPRequest } from './HTTPRequest'; FrameManager,
import { HTTPResponse } from './HTTPResponse'; Frame,
import { NetworkManagerEmittedEvents } from './NetworkManager'; FrameManagerEmittedEvents,
import { CDPSessionEmittedEvents } from './Connection'; } from './FrameManager.js';
import { HTTPRequest } from './HTTPRequest.js';
import { HTTPResponse } from './HTTPResponse.js';
import { NetworkManagerEmittedEvents } from './NetworkManager.js';
import { CDPSessionEmittedEvents } from './Connection.js';
export type PuppeteerLifeCycleEvent = export type PuppeteerLifeCycleEvent =
| 'load' | 'load'

View File

@ -13,14 +13,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { EventEmitter } from './EventEmitter'; import { EventEmitter } from './EventEmitter.js';
import { assert } from './assert'; import { assert } from './assert.js';
import { helper, debugError } from './helper'; import { helper, debugError } from './helper.js';
import { Protocol } from 'devtools-protocol'; import { Protocol } from 'devtools-protocol';
import { CDPSession } from './Connection'; import { CDPSession } from './Connection.js';
import { FrameManager } from './FrameManager'; import { FrameManager } from './FrameManager.js';
import { HTTPRequest } from './HTTPRequest'; import { HTTPRequest } from './HTTPRequest.js';
import { HTTPResponse } from './HTTPResponse'; import { HTTPResponse } from './HTTPResponse.js';
/** /**
* @public * @public

View File

@ -16,30 +16,38 @@
import * as fs from 'fs'; import * as fs from 'fs';
import { promisify } from 'util'; import { promisify } from 'util';
import { EventEmitter } from './EventEmitter'; import { EventEmitter } from './EventEmitter.js';
import * as mime from 'mime'; import * as mime from 'mime';
import { Connection, CDPSession, CDPSessionEmittedEvents } from './Connection'; import {
import { Dialog } from './Dialog'; Connection,
import { EmulationManager } from './EmulationManager'; CDPSession,
import { Frame, FrameManager, FrameManagerEmittedEvents } from './FrameManager'; CDPSessionEmittedEvents,
import { Keyboard, Mouse, Touchscreen, MouseButton } from './Input'; } from './Connection.js';
import { Tracing } from './Tracing'; import { Dialog } from './Dialog.js';
import { assert } from './assert'; import { EmulationManager } from './EmulationManager.js';
import { helper, debugError } from './helper'; import {
import { Coverage } from './Coverage'; Frame,
import { WebWorker } from './WebWorker'; FrameManager,
import { Browser, BrowserContext } from './Browser'; FrameManagerEmittedEvents,
import { Target } from './Target'; } from './FrameManager.js';
import { createJSHandle, JSHandle, ElementHandle } from './JSHandle'; import { Keyboard, Mouse, Touchscreen, MouseButton } from './Input.js';
import { Viewport } from './PuppeteerViewport'; import { Tracing } from './Tracing.js';
import { Credentials, NetworkManagerEmittedEvents } from './NetworkManager'; import { assert } from './assert.js';
import { HTTPRequest } from './HTTPRequest'; import { helper, debugError } from './helper.js';
import { HTTPResponse } from './HTTPResponse'; import { Coverage } from './Coverage.js';
import { Accessibility } from './Accessibility'; import { WebWorker } from './WebWorker.js';
import { TimeoutSettings } from './TimeoutSettings'; import { Browser, BrowserContext } from './Browser.js';
import { FileChooser } from './FileChooser'; import { Target } from './Target.js';
import { ConsoleMessage, ConsoleMessageType } from './ConsoleMessage'; import { createJSHandle, JSHandle, ElementHandle } from './JSHandle.js';
import { PuppeteerLifeCycleEvent } from './LifecycleWatcher'; import { Viewport } from './PuppeteerViewport.js';
import { Credentials, NetworkManagerEmittedEvents } from './NetworkManager.js';
import { HTTPRequest } from './HTTPRequest.js';
import { HTTPResponse } from './HTTPResponse.js';
import { Accessibility } from './Accessibility.js';
import { TimeoutSettings } from './TimeoutSettings.js';
import { FileChooser } from './FileChooser.js';
import { ConsoleMessage, ConsoleMessageType } from './ConsoleMessage.js';
import { PuppeteerLifeCycleEvent } from './LifecycleWatcher.js';
import { Protocol } from 'devtools-protocol'; import { Protocol } from 'devtools-protocol';
import { import {
SerializableOrJSHandle, SerializableOrJSHandle,
@ -48,7 +56,7 @@ import {
EvaluateFn, EvaluateFn,
EvaluateFnReturnType, EvaluateFnReturnType,
UnwrapPromiseLike, UnwrapPromiseLike,
} from './EvalTypes'; } from './EvalTypes.js';
const writeFileAsync = promisify(fs.writeFile); const writeFileAsync = promisify(fs.writeFile);

View File

@ -13,26 +13,29 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import Launcher from '../node/Launcher'; import Launcher from '../node/Launcher.js';
import { import {
LaunchOptions, LaunchOptions,
ChromeArgOptions, ChromeArgOptions,
BrowserOptions, BrowserOptions,
} from '../node/LaunchOptions'; } from '../node/LaunchOptions.js';
import { ProductLauncher } from '../node/Launcher'; import { ProductLauncher } from '../node/Launcher.js';
import { BrowserFetcher, BrowserFetcherOptions } from '../node/BrowserFetcher'; import {
import { puppeteerErrors, PuppeteerErrors } from './Errors'; BrowserFetcher,
import { ConnectionTransport } from './ConnectionTransport'; BrowserFetcherOptions,
import { devicesMap, DevicesMap } from './DeviceDescriptors'; } from '../node/BrowserFetcher.js';
import { Browser } from './Browser'; import { puppeteerErrors, PuppeteerErrors } from './Errors.js';
import { ConnectionTransport } from './ConnectionTransport.js';
import { devicesMap, DevicesMap } from './DeviceDescriptors.js';
import { Browser } from './Browser.js';
import { import {
registerCustomQueryHandler, registerCustomQueryHandler,
unregisterCustomQueryHandler, unregisterCustomQueryHandler,
customQueryHandlers, customQueryHandlers,
clearQueryHandlers, clearQueryHandlers,
QueryHandler, QueryHandler,
} from './QueryHandler'; } from './QueryHandler.js';
import { PUPPETEER_REVISIONS } from '../revisions'; import { PUPPETEER_REVISIONS } from '../revisions.js';
/** /**
* The main Puppeteer class. Provides the {@link Puppeteer.launch | launch} * The main Puppeteer class. Provides the {@link Puppeteer.launch | launch}

View File

@ -14,11 +14,11 @@
* limitations under the License. * limitations under the License.
*/ */
import { Page, PageEmittedEvents } from './Page'; import { Page, PageEmittedEvents } from './Page.js';
import { WebWorker } from './WebWorker'; import { WebWorker } from './WebWorker.js';
import { CDPSession } from './Connection'; import { CDPSession } from './Connection.js';
import { Browser, BrowserContext } from './Browser'; import { Browser, BrowserContext } from './Browser.js';
import { Viewport } from './PuppeteerViewport'; import { Viewport } from './PuppeteerViewport.js';
import { Protocol } from 'devtools-protocol'; import { Protocol } from 'devtools-protocol';
/** /**

View File

@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { assert } from './assert'; import { assert } from './assert.js';
import { helper } from './helper'; import { helper } from './helper.js';
import { CDPSession } from './Connection'; import { CDPSession } from './Connection.js';
/** /**
* @public * @public

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { ConnectionTransport } from './ConnectionTransport'; import { ConnectionTransport } from './ConnectionTransport.js';
import NodeWebSocket from 'ws'; import NodeWebSocket from 'ws';
export class WebSocketTransport implements ConnectionTransport { export class WebSocketTransport implements ConnectionTransport {

View File

@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { EventEmitter } from './EventEmitter'; import { EventEmitter } from './EventEmitter.js';
import { debugError } from './helper'; import { debugError } from './helper.js';
import { ExecutionContext } from './ExecutionContext'; import { ExecutionContext } from './ExecutionContext.js';
import { JSHandle } from './JSHandle'; import { JSHandle } from './JSHandle.js';
import { CDPSession } from './Connection'; import { CDPSession } from './Connection.js';
import { Protocol } from 'devtools-protocol'; import { Protocol } from 'devtools-protocol';
import { EvaluateHandleFn, SerializableOrJSHandle } from './EvalTypes'; import { EvaluateHandleFn, SerializableOrJSHandle } from './EvalTypes.js';
/** /**
* @internal * @internal

View File

@ -13,14 +13,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { TimeoutError } from './Errors'; import { TimeoutError } from './Errors.js';
import { debug } from './Debug'; import { debug } from './Debug.js';
import * as fs from 'fs'; import * as fs from 'fs';
import { CDPSession } from './Connection'; import { CDPSession } from './Connection.js';
import { promisify } from 'util'; import { promisify } from 'util';
import { Protocol } from 'devtools-protocol'; import { Protocol } from 'devtools-protocol';
import { CommonEventEmitter } from './EventEmitter'; import { CommonEventEmitter } from './EventEmitter.js';
import { assert } from './assert'; import { assert } from './assert.js';
const openAsync = promisify(fs.open); const openAsync = promisify(fs.open);
const writeAsync = promisify(fs.write); const writeAsync = promisify(fs.write);

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { initializePuppeteer } from './initialize'; import { initializePuppeteer } from './initialize.js';
const puppeteer = initializePuppeteer('puppeteer-core'); const puppeteer = initializePuppeteer('puppeteer-core');
export default puppeteer; export default puppeteer;

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { initializePuppeteer } from './initialize'; import { initializePuppeteer } from './initialize.js';
const puppeteer = initializePuppeteer('puppeteer'); const puppeteer = initializePuppeteer('puppeteer');
export default puppeteer; export default puppeteer;

View File

@ -14,8 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
import { Puppeteer } from './common/Puppeteer'; import { Puppeteer } from './common/Puppeteer.js';
import { PUPPETEER_REVISIONS } from './revisions'; import { PUPPETEER_REVISIONS } from './revisions.js';
import pkgDir from 'pkg-dir'; import pkgDir from 'pkg-dir';
export const initializePuppeteer = (packageName: string): Puppeteer => { export const initializePuppeteer = (packageName: string): Puppeteer => {

View File

@ -17,8 +17,8 @@
import os from 'os'; import os from 'os';
import https from 'https'; import https from 'https';
import ProgressBar from 'progress'; import ProgressBar from 'progress';
import puppeteer from './index'; import puppeteer from './index.js';
import { PUPPETEER_REVISIONS } from './revisions'; import { PUPPETEER_REVISIONS } from './revisions.js';
const firefoxVersions = const firefoxVersions =
'https://product-details.mozilla.org/1.0/firefox_versions.json'; 'https://product-details.mozilla.org/1.0/firefox_versions.json';

View File

@ -23,13 +23,13 @@ import * as https from 'https';
import * as http from 'http'; import * as http from 'http';
import extractZip from 'extract-zip'; import extractZip from 'extract-zip';
import { debug } from '../common/Debug'; import { debug } from '../common/Debug.js';
import { promisify } from 'util'; import { promisify } from 'util';
import removeRecursive from 'rimraf'; import removeRecursive from 'rimraf';
import * as URL from 'url'; import * as URL from 'url';
import ProxyAgent from 'https-proxy-agent'; import ProxyAgent from 'https-proxy-agent';
import { getProxyForUrl } from 'proxy-from-env'; import { getProxyForUrl } from 'proxy-from-env';
import { assert } from '../common/assert'; import { assert } from '../common/assert.js';
const debugFetcher = debug(`puppeteer:fetcher`); const debugFetcher = debug(`puppeteer:fetcher`);

View File

@ -14,18 +14,18 @@
* limitations under the License. * limitations under the License.
*/ */
import { debug } from '../common/Debug'; import { debug } from '../common/Debug.js';
import removeFolder from 'rimraf'; import removeFolder from 'rimraf';
import * as childProcess from 'child_process'; import * as childProcess from 'child_process';
import { assert } from '../common/assert'; import { assert } from '../common/assert.js';
import { helper, debugError } from '../common/helper'; import { helper, debugError } from '../common/helper.js';
import { LaunchOptions } from './LaunchOptions'; import { LaunchOptions } from './LaunchOptions.js';
import { Connection } from '../common/Connection'; import { Connection } from '../common/Connection.js';
import { WebSocketTransport } from '../common/WebSocketTransport'; import { WebSocketTransport } from '../common/WebSocketTransport.js';
import { PipeTransport } from './PipeTransport'; import { PipeTransport } from './PipeTransport.js';
import * as readline from 'readline'; import * as readline from 'readline';
import { TimeoutError } from '../common/Errors'; import { TimeoutError } from '../common/Errors.js';
import { promisify } from 'util'; import { promisify } from 'util';
const removeFolderAsync = promisify(removeFolder); const removeFolderAsync = promisify(removeFolder);

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { Viewport } from '../common/PuppeteerViewport'; import { Viewport } from '../common/PuppeteerViewport.js';
/** /**
* Launcher options that only apply to Chrome. * Launcher options that only apply to Chrome.

View File

@ -20,14 +20,14 @@ import * as https from 'https';
import * as URL from 'url'; import * as URL from 'url';
import * as fs from 'fs'; import * as fs from 'fs';
import { BrowserFetcher } from './BrowserFetcher'; import { BrowserFetcher } from './BrowserFetcher.js';
import { Connection } from '../common/Connection'; import { Connection } from '../common/Connection.js';
import { Browser } from '../common/Browser'; import { Browser } from '../common/Browser.js';
import { assert } from '../common/assert'; import { assert } from '../common/assert.js';
import { debugError } from '../common/helper'; import { debugError } from '../common/helper.js';
import { ConnectionTransport } from '../common/ConnectionTransport'; import { ConnectionTransport } from '../common/ConnectionTransport.js';
import { WebSocketTransport } from '../common/WebSocketTransport'; import { WebSocketTransport } from '../common/WebSocketTransport.js';
import { BrowserRunner } from './BrowserRunner'; import { BrowserRunner } from './BrowserRunner.js';
import { promisify } from 'util'; import { promisify } from 'util';
const mkdtempAsync = promisify(fs.mkdtemp); const mkdtempAsync = promisify(fs.mkdtemp);
@ -37,7 +37,7 @@ import {
ChromeArgOptions, ChromeArgOptions,
LaunchOptions, LaunchOptions,
BrowserOptions, BrowserOptions,
} from './LaunchOptions'; } from './LaunchOptions.js';
/** /**
* Describes a launcher - a class that is able to create and launch a browser instance. * Describes a launcher - a class that is able to create and launch a browser instance.

View File

@ -13,8 +13,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { helper, debugError, PuppeteerEventListener } from '../common/helper'; import {
import { ConnectionTransport } from '../common/ConnectionTransport'; helper,
debugError,
PuppeteerEventListener,
} from '../common/helper.js';
import { ConnectionTransport } from '../common/ConnectionTransport.js';
export class PipeTransport implements ConnectionTransport { export class PipeTransport implements ConnectionTransport {
_pipeWrite: NodeJS.WritableStream; _pipeWrite: NodeJS.WritableStream;

13
test/.eslintrc.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = {
rules: {
'no-restricted-imports': [
'error',
{
/** The mocha tests run on the compiled output in the /lib directory
* so we should avoid importing from src.
*/
patterns: ['*src*'],
},
],
},
};

View File

@ -14,14 +14,14 @@
* limitations under the License. * limitations under the License.
*/ */
import { waitEvent } from './utils'; import { waitEvent } from './utils.js';
import expect from 'expect'; import expect from 'expect';
import { import {
getTestState, getTestState,
setupTestBrowserHooks, setupTestBrowserHooks,
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
describeChromeOnly, describeChromeOnly,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
describeChromeOnly('Target.createCDPSession', function () { describeChromeOnly('Target.createCDPSession', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { EventEmitter } from '../src/common/EventEmitter'; import { EventEmitter } from '../lib/cjs/common/EventEmitter.js';
import sinon from 'sinon'; import sinon from 'sinon';
import expect from 'expect'; import expect from 'expect';

View File

@ -20,7 +20,7 @@ import {
setupTestBrowserHooks, setupTestBrowserHooks,
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
describeFailsFirefox, describeFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
describeFailsFirefox('Accessibility', function () { describeFailsFirefox('Accessibility', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -15,7 +15,7 @@
*/ */
import expect from 'expect'; import expect from 'expect';
import { getTestState, setupTestBrowserHooks } from './mocha-utils'; import { getTestState, setupTestBrowserHooks } from './mocha-utils'; // eslint-disable-line import/extensions
describe('Browser specs', function () { describe('Browser specs', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -19,8 +19,8 @@ import {
getTestState, getTestState,
setupTestBrowserHooks, setupTestBrowserHooks,
itFailsFirefox, itFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
import utils from './utils'; import utils from './utils.js';
describe('BrowserContext', function () { describe('BrowserContext', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -19,7 +19,7 @@ import {
setupTestBrowserHooks, setupTestBrowserHooks,
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
describeChromeOnly, describeChromeOnly,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
describeChromeOnly('Chromium-Specific Launcher tests', function () { describeChromeOnly('Chromium-Specific Launcher tests', function () {
describe('Puppeteer.launch |browserURL| option', function () { describe('Puppeteer.launch |browserURL| option', function () {

View File

@ -20,8 +20,8 @@ import {
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
setupTestBrowserHooks, setupTestBrowserHooks,
itFailsFirefox, itFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
import utils from './utils'; import utils from './utils.js';
describe('Page.click', function () { describe('Page.click', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -19,7 +19,7 @@ import {
setupTestBrowserHooks, setupTestBrowserHooks,
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
itFailsFirefox, itFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
describe('Cookie specs', () => { describe('Cookie specs', () => {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -39,32 +39,32 @@ const fs = require('fs');
* part of the TSDoc migration. * part of the TSDoc migration.
*/ */
const MODULES_TO_CHECK_FOR_COVERAGE = { const MODULES_TO_CHECK_FOR_COVERAGE = {
Accessibility: '../src/common/Accessibility', Accessibility: '../lib/cjs/common/Accessibility',
Browser: '../src/common/Browser', Browser: '../lib/cjs/common/Browser',
BrowserContext: '../src/common/Browser', BrowserContext: '../lib/cjs/common/Browser',
BrowserFetcher: '../src/node/BrowserFetcher', BrowserFetcher: '../lib/cjs/node/BrowserFetcher',
CDPSession: '../src/common/Connection', CDPSession: '../lib/cjs/common/Connection',
ConsoleMessage: '../src/common/ConsoleMessage', ConsoleMessage: '../lib/cjs/common/ConsoleMessage',
Coverage: '../src/common/Coverage', Coverage: '../lib/cjs/common/Coverage',
Dialog: '../src/common/Dialog', Dialog: '../lib/cjs/common/Dialog',
ElementHandle: '../src/common/JSHandle', ElementHandle: '../lib/cjs/common/JSHandle',
ExecutionContext: '../src/common/ExecutionContext', ExecutionContext: '../lib/cjs/common/ExecutionContext',
EventEmitter: '../src/common/EventEmitter', EventEmitter: '../lib/cjs/common/EventEmitter',
FileChooser: '../src/common/FileChooser', FileChooser: '../lib/cjs/common/FileChooser',
Frame: '../src/common/FrameManager', Frame: '../lib/cjs/common/FrameManager',
JSHandle: '../src/common/JSHandle', JSHandle: '../lib/cjs/common/JSHandle',
Keyboard: '../src/common/Input', Keyboard: '../lib/cjs/common/Input',
Mouse: '../src/common/Input', Mouse: '../lib/cjs/common/Input',
Page: '../src/common/Page', Page: '../lib/cjs/common/Page',
Puppeteer: '../src/common/Puppeteer', Puppeteer: '../lib/cjs/common/Puppeteer',
HTTPRequest: '../src/common/HTTPRequest', HTTPRequest: '../lib/cjs/common/HTTPRequest',
HTTPResponse: '../src/common/HTTPResponse', HTTPResponse: '../lib/cjs/common/HTTPResponse',
SecurityDetails: '../src/common/SecurityDetails', SecurityDetails: '../lib/cjs/common/SecurityDetails',
Target: '../src/common/Target', Target: '../lib/cjs/common/Target',
TimeoutError: '../src/common/Errors', TimeoutError: '../lib/cjs/common/Errors',
Touchscreen: '../src/common/Input', Touchscreen: '../lib/cjs/common/Input',
Tracing: '../src/common/Tracing', Tracing: '../lib/cjs/common/Tracing',
WebWorker: '../src/common/WebWorker', WebWorker: '../lib/cjs/common/WebWorker',
}; };
function traceAPICoverage(apiCoverage, className, modulePath) { function traceAPICoverage(apiCoverage, className, modulePath) {

View File

@ -20,7 +20,7 @@ import {
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
setupTestBrowserHooks, setupTestBrowserHooks,
describeChromeOnly, describeChromeOnly,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
describe('Coverage specs', function () { describe('Coverage specs', function () {
describeChromeOnly('JSCoverage', function () { describeChromeOnly('JSCoverage', function () {

View File

@ -19,7 +19,7 @@ import {
setupTestBrowserHooks, setupTestBrowserHooks,
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
itFailsFirefox, itFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
describe('DefaultBrowserContext', function () { describe('DefaultBrowserContext', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -21,7 +21,7 @@ import {
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
setupTestBrowserHooks, setupTestBrowserHooks,
itFailsFirefox, itFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
describe('Page.Events.Dialog', function () { describe('Page.Events.Dialog', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -21,10 +21,10 @@ import {
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
describeFailsFirefox, describeFailsFirefox,
itFailsFirefox, itFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
import utils from './utils'; import utils from './utils.js';
import { ElementHandle } from '../src/common/JSHandle'; import { ElementHandle } from '../lib/cjs/common/JSHandle.js';
describe('ElementHandle specs', function () { describe('ElementHandle specs', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -21,7 +21,7 @@ import {
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
itFailsFirefox, itFailsFirefox,
describeFailsFirefox, describeFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
describe('Emulation', () => { describe('Emulation', () => {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import utils from './utils'; import utils from './utils.js';
import expect from 'expect'; import expect from 'expect';
import { import {
getTestState, getTestState,
@ -22,7 +22,7 @@ import {
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
itFailsFirefox, itFailsFirefox,
describeFailsFirefox, describeFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
const bigint = typeof BigInt !== 'undefined'; const bigint = typeof BigInt !== 'undefined';

View File

@ -17,7 +17,7 @@
/* eslint-disable @typescript-eslint/no-var-requires */ /* eslint-disable @typescript-eslint/no-var-requires */
import expect from 'expect'; import expect from 'expect';
import { getTestState, itChromeOnly } from './mocha-utils'; import { getTestState, itChromeOnly } from './mocha-utils'; // eslint-disable-line import/extensions
import path from 'path'; import path from 'path';

View File

@ -14,14 +14,14 @@
* limitations under the License. * limitations under the License.
*/ */
import utils from './utils'; import utils from './utils.js';
import expect from 'expect'; import expect from 'expect';
import { import {
getTestState, getTestState,
setupTestBrowserHooks, setupTestBrowserHooks,
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
itFailsFirefox, itFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
describe('Frame specs', function () { describe('Frame specs', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -23,7 +23,7 @@ import {
getTestState, getTestState,
describeChromeOnly, describeChromeOnly,
itFailsWindows, itFailsWindows,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
import rimraf from 'rimraf'; import rimraf from 'rimraf';
const rmAsync = promisify(rimraf); const rmAsync = promisify(rimraf);

View File

@ -19,7 +19,7 @@ import {
getTestState, getTestState,
describeFailsFirefox, describeFailsFirefox,
itFailsFirefox, itFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
describe('ignoreHTTPSErrors', function () { describe('ignoreHTTPSErrors', function () {
/* Note that this test creates its own browser rather than use /* Note that this test creates its own browser rather than use

View File

@ -21,7 +21,7 @@ import {
setupTestBrowserHooks, setupTestBrowserHooks,
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
describeFailsFirefox, describeFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
const FILE_TO_UPLOAD = path.join(__dirname, '/assets/file-to-upload.txt'); const FILE_TO_UPLOAD = path.join(__dirname, '/assets/file-to-upload.txt');

View File

@ -20,7 +20,7 @@ import {
setupTestBrowserHooks, setupTestBrowserHooks,
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
itFailsFirefox, itFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
describe('JSHandle', function () { describe('JSHandle', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import utils from './utils'; import utils from './utils.js';
import os from 'os'; import os from 'os';
import expect from 'expect'; import expect from 'expect';
import { import {
@ -22,8 +22,8 @@ import {
setupTestBrowserHooks, setupTestBrowserHooks,
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
itFailsFirefox, itFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
import { KeyInput } from '../src/common/USKeyboardLayout'; import { KeyInput } from '../lib/cjs/common/USKeyboardLayout.js';
describe('Keyboard', function () { describe('Keyboard', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -23,11 +23,11 @@ import {
itFailsFirefox, itFailsFirefox,
itOnlyRegularInstall, itOnlyRegularInstall,
itFailsWindowsUntilDate, itFailsWindowsUntilDate,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
import utils from './utils'; import utils from './utils.js';
import expect from 'expect'; import expect from 'expect';
import rimraf from 'rimraf'; import rimraf from 'rimraf';
import { Page } from '../src/common/Page'; import { Page } from '../lib/cjs/common/Page.js';
const rmAsync = promisify(rimraf); const rmAsync = promisify(rimraf);
const mkdtempAsync = promisify(fs.mkdtemp); const mkdtempAsync = promisify(fs.mkdtemp);

8
test/mocha-ts-require.js Normal file
View File

@ -0,0 +1,8 @@
require('ts-node').register({
/**
* We ignore the lib/ directory because that's already been TypeScript
* compiled and checked. So we don't want to check it again as part of running
* the unit tests.
*/
ignore: ['lib/*', 'node_modules'],
});

View File

@ -14,19 +14,19 @@
* limitations under the License. * limitations under the License.
*/ */
import { TestServer } from '../utils/testserver/index'; import { TestServer } from '../utils/testserver/index.js';
import * as path from 'path'; import * as path from 'path';
import * as fs from 'fs'; import * as fs from 'fs';
import * as os from 'os'; import * as os from 'os';
import sinon from 'sinon'; import sinon from 'sinon';
import puppeteer from '../src/index'; import puppeteer from '../lib/cjs/index.js';
import { Browser, BrowserContext } from '../src/common/Browser'; import { Browser, BrowserContext } from '../lib/cjs/common/Browser.js';
import { Page } from '../src/common/Page'; import { Page } from '../lib/cjs/common/Page.js';
import { Puppeteer } from '../src/common/Puppeteer'; import { Puppeteer } from '../lib/cjs/common/Puppeteer.js';
import utils from './utils'; import utils from './utils.js';
import rimraf from 'rimraf'; import rimraf from 'rimraf';
import { trackCoverage } from './coverage-utils'; import { trackCoverage } from './coverage-utils.js';
const setupServer = async () => { const setupServer = async () => {
const assetsPath = path.join(__dirname, 'assets'); const assetsPath = path.join(__dirname, 'assets');

View File

@ -20,8 +20,8 @@ import {
setupTestBrowserHooks, setupTestBrowserHooks,
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
itFailsFirefox, itFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
import { KeyInput } from '../src/common/USKeyboardLayout'; import { KeyInput } from '../lib/cjs/common/USKeyboardLayout.js';
interface Dimensions { interface Dimensions {
x: number; x: number;

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import utils from './utils'; import utils from './utils.js';
import expect from 'expect'; import expect from 'expect';
import { import {
getTestState, getTestState,
@ -22,7 +22,7 @@ import {
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
itFailsFirefox, itFailsFirefox,
describeFailsFirefox, describeFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
import os from 'os'; import os from 'os';
describe('navigation', function () { describe('navigation', function () {

View File

@ -16,7 +16,7 @@
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import utils from './utils'; import utils from './utils.js';
import expect from 'expect'; import expect from 'expect';
import { import {
getTestState, getTestState,
@ -24,7 +24,7 @@ import {
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
itFailsFirefox, itFailsFirefox,
describeFailsFirefox, describeFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
describe('network', function () { describe('network', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -15,7 +15,7 @@
*/ */
import expect from 'expect'; import expect from 'expect';
import { getTestState, describeChromeOnly } from './mocha-utils'; import { getTestState, describeChromeOnly } from './mocha-utils'; // eslint-disable-line import/extensions
describeChromeOnly('OOPIF', function () { describeChromeOnly('OOPIF', function () {
/* We use a special browser for this test as we need the --site-per-process flag */ /* We use a special browser for this test as we need the --site-per-process flag */

View File

@ -15,7 +15,7 @@
*/ */
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import utils from './utils'; import utils from './utils.js';
const { waitEvent } = utils; const { waitEvent } = utils;
import expect from 'expect'; import expect from 'expect';
import sinon from 'sinon'; import sinon from 'sinon';
@ -25,9 +25,9 @@ import {
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
itFailsFirefox, itFailsFirefox,
describeFailsFirefox, describeFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
import { Page, Metrics } from '../src/common/Page'; import { Page, Metrics } from '../lib/cjs/common/Page.js';
import { JSHandle } from '../src/common/JSHandle'; import { JSHandle } from '../lib/cjs/common/JSHandle.js';
describe('Page', function () { describe('Page', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -18,7 +18,7 @@ import {
getTestState, getTestState,
setupTestBrowserHooks, setupTestBrowserHooks,
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
describe('querySelector', function () { describe('querySelector', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -16,14 +16,14 @@
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import utils from './utils'; import utils from './utils.js';
import expect from 'expect'; import expect from 'expect';
import { import {
getTestState, getTestState,
setupTestBrowserHooks, setupTestBrowserHooks,
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
describeFailsFirefox, describeFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
describe('request interception', function () { describe('request interception', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -20,7 +20,7 @@ import {
setupTestBrowserHooks, setupTestBrowserHooks,
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
itFailsFirefox, itFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
describe('Screenshots', function () { describe('Screenshots', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
import utils from './utils'; import utils from './utils.js';
const { waitEvent } = utils; const { waitEvent } = utils;
import expect from 'expect'; import expect from 'expect';
import { import {
@ -22,8 +22,8 @@ import {
setupTestBrowserHooks, setupTestBrowserHooks,
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
itFailsFirefox, itFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
import { Target } from '../src/common/Target'; import { Target } from '../lib/cjs/common/Target.js';
describe('Target', function () { describe('Target', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -20,7 +20,7 @@ import {
setupTestBrowserHooks, setupTestBrowserHooks,
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
describeFailsFirefox, describeFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
describeFailsFirefox('Touchscreen', function () { describeFailsFirefox('Touchscreen', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -17,7 +17,7 @@
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import expect from 'expect'; import expect from 'expect';
import { getTestState, describeChromeOnly } from './mocha-utils'; import { getTestState, describeChromeOnly } from './mocha-utils'; // eslint-disable-line import/extensions
describeChromeOnly('Tracing', function () { describeChromeOnly('Tracing', function () {
let outputFile; let outputFile;

View File

@ -14,14 +14,14 @@
* limitations under the License. * limitations under the License.
*/ */
import utils from './utils'; import utils from './utils.js';
import expect from 'expect'; import expect from 'expect';
import { import {
getTestState, getTestState,
setupTestBrowserHooks, setupTestBrowserHooks,
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
itFailsFirefox, itFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
describe('waittask specs', function () { describe('waittask specs', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();

View File

@ -20,10 +20,10 @@ import {
setupTestBrowserHooks, setupTestBrowserHooks,
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
describeFailsFirefox, describeFailsFirefox,
} from './mocha-utils'; } from './mocha-utils'; // eslint-disable-line import/extensions
import utils from './utils'; import utils from './utils.js';
import { WebWorker } from '../src/common/WebWorker'; import { WebWorker } from '../lib/cjs/common/WebWorker.js';
import { ConsoleMessage } from '../src/common/ConsoleMessage'; import { ConsoleMessage } from '../lib/cjs/common/ConsoleMessage.js';
const { waitEvent } = utils; const { waitEvent } = utils;
describeFailsFirefox('Workers', function () { describeFailsFirefox('Workers', function () {