Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: add validations into check_deps (#10661)
Pavel Feldmanb9731a904eba
diff --git a/packages/playwright-core/src/server/chromium/chromium.ts b/packages/playwright-core/src/server/chromium/chromium.tsindex 1393dbbd09..5544aed14f 100644--- a/packages/playwright-core/src/server/chromium/chromium.ts+++ b/packages/playwright-core/src/server/chromium/chromium.ts@@ -36,7 +36,7 @@ import { CallMetadata } from '../instrumentation';import http from 'http';import https from 'https';import { registry } from '../../utils/registry';-import { ManualPromise } from 'playwright-core/lib/utils/async';+import { ManualPromise } from '../../utils/async';const ARTIFACTS_FOLDER = path.join(os.tmpdir(), 'playwright-artifacts-');diff --git a/packages/playwright-test/package.json b/packages/playwright-test/package.jsonindex 5cfcfe5102..ef5132c809 100644--- a/packages/playwright-test/package.json+++ b/packages/playwright-test/package.json@@ -46,9 +46,11 @@"@babel/preset-typescript": "^7.14.5","colors": "^1.4.0","commander": "^8.2.0",+ "debug": "^4.1.1","expect": "=27.2.5","jest-matcher-utils": "=27.2.5","jpeg-js": "^0.4.2",+ "mime": "^2.4.6","minimatch": "^3.0.3","ms": "^2.1.2","open": "^8.3.0",@@ -59,6 +61,6 @@"rimraf": "^3.0.2","source-map-support": "^0.4.18","stack-utils": "^2.0.3",- "debug": "^4.1.1"+ "yazl": "^2.5.1"}}diff --git a/packages/playwright-test/src/matchers/toMatchText.ts b/packages/playwright-test/src/matchers/toMatchText.tsindex 2739e2addf..97cbef09b5 100644--- a/packages/playwright-test/src/matchers/toMatchText.ts+++ b/packages/playwright-test/src/matchers/toMatchText.ts@@ -16,7 +16,7 @@import colors from 'colors/safe';-import { ExpectedTextValue } from 'playwright-core/lib/protocol/channels';+import type { ExpectedTextValue } from 'playwright-core/lib/protocol/channels';import { isRegExp, isString } from 'playwright-core/lib/utils/utils';import { currentTestInfo } from '../globals';import type { Expect } from '../types';diff --git a/utils/check_deps.js b/utils/check_deps.jsindex 713716e5d0..0f9092494c 100644--- a/utils/check_deps.js+++ b/utils/check_deps.js@@ -21,8 +21,24 @@ const ts = require('typescript');const path = require('path');async function checkDeps() {- const root = path.normalize(path.join(__dirname, '..', 'packages', 'playwright-core'));- const src = path.normalize(path.join(__dirname, '..', 'packages', 'playwright-core', 'src'));+ const packages = path.normalize(path.join(__dirname, '..', 'packages'));+ const corePackageJson = await innerCheckDeps(path.join(packages, 'playwright-core'), true);+ const testPackageJson = await innerCheckDeps(path.join(packages, 'playwright-test'), false);++ let hasVersionMismatch = false;+ for (const [key, value] of Object.entries(corePackageJson.dependencies)) {+ const value2 = testPackageJson.dependencies[key];+ if (value2 && value2 !== value) {+ hasVersionMismatch = true;+ console.log(`Dependency version mismatch ${key}: ${value} != ${value2}`);+ }+ }+ process.exit(hasVersionMismatch ? 1 : 0);+}++async function innerCheckDeps(root, checkDepsFile) {+ const deps = new Set();+ const src = path.join(root, 'src');const packageJSON = require(path.join(root, 'package.json'));const program = ts.createProgram({options: {@@ -40,23 +56,46 @@ async function checkDeps() {if (!usedDeps.has(key) && DEPS[key].length)errors.push(`Stale DEPS entry "${key}"`);}- for (const error of errors)- console.log(error);- if (errors.length) {+ if (checkDepsFile && errors.length) {+ for (const error of errors)+ console.log(error);console.log(`--------------------------------------------------------`);console.log(`Changing the project structure or adding new components?`);console.log(`Update DEPS in ./${path.relative(root, __filename)}`);console.log(`--------------------------------------------------------`);+ process.exit(1);}- process.exit(errors.length ? 1 : 0);++ for (const dep of deps) {+ const resolved = require.resolve(dep);+ if (dep === resolved || !resolved.includes('node_modules'))+ deps.delete(dep);+ }+ for (const dep of Object.keys(packageJSON.dependencies))+ deps.delete(dep);++ if (deps.size) {+ console.log('Dependencies are not declared in package.json:');+ for (const dep of deps)+ console.log(` ${dep}`);+ process.exit(1);+ }++ return packageJSON;function visit(node, fileName) {if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) {const importName = node.moduleSpecifier.text;+ if (!importName.startsWith('.') && !node.importClause.isTypeOnly && !fileName.includes(path.sep + 'web' + path.sep)) {+ if (importName.startsWith('@'))+ deps.add(importName.split('/').slice(0, 2).join('/'));+ else+ deps.add(importName.split('/')[0]);+ }const importPath = path.resolve(path.dirname(fileName), importName) + '.ts';- if (!allowImport(fileName, importPath))+ if (checkDepsFile && !allowImport(fileName, importPath))errors.push(`Disallowed import from ${path.relative(root, fileName)} to ${path.relative(root, importPath)}`);- if (!allowExternalImport(fileName, importPath, importName))+ if (checkDepsFile && !allowExternalImport(fileName, importPath, importName))errors.push(`Disallowed external dependency ${importName} from ${path.relative(root, fileName)}`);}ts.forEachChild(node, x => visit(x, fileName));