chore: add npm run lint-tests (#10252)

This commit is contained in:
Dmitry Gozman 2021-11-11 13:27:50 -08:00 committed by GitHub
parent 4c93417e8a
commit f38f611478
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 6 deletions

View file

@ -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",

View file

@ -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);
}

View file

@ -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);

33
utils/lint_tests.js Normal file
View file

@ -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);
}