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 npm run lint-tests (#10252)
Dmitry Gozmanf38f6114789f
diff --git a/package.json b/package.jsonindex 05e15c6ef6..2b6f4df5ca 100644--- a/package.json+++ b/package.json@@ -25,9 +25,10 @@"tsc": "tsc -p .","build-installer": "babel -s --extensions \".ts\" --out-dir packages/playwright-core/lib/utils/ packages/playwright-core/src/utils","doc": "node utils/doclint/cli.js",- "lint": "npm run eslint && npm run tsc && npm run doc && npm run check-deps && node utils/generate_channels.js && node utils/generate_types/ --check-clean && npm run test-types && npm run lint-packages",+ "lint": "npm run eslint && npm run tsc && npm run doc && npm run check-deps && node utils/generate_channels.js && node utils/generate_types/ --check-clean && npm run lint-tests && npm run test-types && npm run lint-packages","lint-packages": "node utils/prepare_packages.js --check-clean",- "flint": "concurrently \"npm run eslint\" \"npm run tsc\" \"npm run doc\" \"npm run check-deps\" \"node utils/generate_channels.js\" \"node utils/generate_types/ --check-clean\" \"npm run test-types\" \"npm run lint-packages\"",+ "lint-tests": "node utils/lint_tests.js",+ "flint": "concurrently \"npm run eslint\" \"npm run tsc\" \"npm run doc\" \"npm run check-deps\" \"node utils/generate_channels.js\" \"node utils/generate_types/ --check-clean\" \"npm run lint-tests\" \"npm run test-types\" \"npm run lint-packages\"","clean": "rimraf packages/playwright-core/lib && rimraf packages/playwright-test/lib && rimraf packages/playwright-core/src/generated/","prepare": "node install-from-github.js","build": "node utils/build/build.js",diff --git a/packages/playwright-test/src/runner.ts b/packages/playwright-test/src/runner.tsindex 9bb8ccdf8b..cf8b4ade71 100644--- a/packages/playwright-test/src/runner.ts+++ b/packages/playwright-test/src/runner.ts@@ -94,9 +94,12 @@ export class Runner {return prints;});if (reporters.length && !someReporterPrintsToStdio) {- // Add a line/dot report for convenience.+ // Add a line/dot/list-mode reporter for convenience.// Important to put it first, jsut in case some other reporter stalls onEnd.- reporters.unshift(process.stdout.isTTY && !process.env.CI ? new LineReporter({ omitFailures: true }) : new DotReporter({ omitFailures: true }));+ if (list)+ reporters.unshift(new ListModeReporter());+ else+ reporters.unshift(process.stdout.isTTY && !process.env.CI ? new LineReporter({ omitFailures: true }) : new DotReporter({ omitFailures: true }));}return new Multiplexer(reporters);}diff --git a/tests/playwright-test/list-mode.spec.ts b/tests/playwright-test/list-mode.spec.tsindex 69fb362419..b2bbe5098b 100644--- a/tests/playwright-test/list-mode.spec.ts+++ b/tests/playwright-test/list-mode.spec.ts@@ -42,7 +42,7 @@ test('should list tests', async ({ runInlineTest }) => {].join('\n'));});-test('should not list tests to stdout when JSON reporter is used', async ({ runInlineTest }) => {+test('should list tests to stdout when JSON reporter outputs to a file', async ({ runInlineTest }) => {const result = await runInlineTest({'playwright.config.ts': `module.exports = { projects: [{ name: 'foo' }, {}] };@@ -58,7 +58,7 @@ test('should not list tests to stdout when JSON reporter is used', async ({ runI`}, { 'list': true, 'reporter': 'json' });expect(result.exitCode).toBe(0);- expect(result.output).not.toContain('Listing tests');+ expect(result.output).toContain('Listing tests');expect(result.report.config.projects.length).toBe(2);expect(result.report.suites.length).toBe(1);expect(result.report.suites[0].specs.length).toBe(2);diff --git a/utils/lint_tests.js b/utils/lint_tests.jsnew file mode 100644index 0000000000..fd008b2335--- /dev/null+++ b/utils/lint_tests.js@@ -0,0 +1,33 @@+#!/usr/bin/env node+/**+ * 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.+ */++const { execSync } = require('child_process');+const path = require('path');++// Note: we ignore stdout for smaller output.+try {+ execSync('npm run test -- --list --forbid-only', {+ stdio: ['ignore', 'ignore', 'inherit'],+ cwd: path.join(__dirname, '..'),+ });+ execSync('npm run ttest -- --list --forbid-only', {+ stdio: ['ignore', 'ignore', 'inherit'],+ cwd: path.join(__dirname, '..'),+ });+} catch (e) {+ process.exit(1);+}