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
test: print failed tests upon interrupt (#3316)
Pavel Feldman0a5d340e8eff
diff --git a/test/jest/playwrightEnvironment.js b/test/jest/playwrightEnvironment.jsindex 1e27c7b3e7..c7761788ac 100644--- a/test/jest/playwrightEnvironment.js+++ b/test/jest/playwrightEnvironment.js@@ -20,6 +20,7 @@ const os = require('os');const path = require('path');const fs = require('fs');const debug = require('debug');+const util = require('util');const platform = process.env.REPORT_ONLY_PLATFORM || os.platform();const GoldenUtils = require('../../utils/testrunner/GoldenUtils');const {installCoverageHooks} = require('./coverage');@@ -170,6 +171,7 @@ class PlaywrightEnvironment extends NodeEnvironment {if (event.name === 'test_start') {const fn = event.test.fn;+ this._lastTest = event.test;event.test.fn = async () => {if (reportOnly) {if (fn.__fail)@@ -179,6 +181,9 @@ class PlaywrightEnvironment extends NodeEnvironment {debug('pw:test')(`start "${testOrSuiteName(event.test)}"`);try {await this.fixturePool.resolveParametersAndRun(fn);+ } catch(e) {+ debug('pw:test')(`error "${testOrSuiteName(event.test)}"`, util.inspect(e));+ throw e;} finally {await this.fixturePool.teardownScope('test');debug('pw:test')(`finish "${testOrSuiteName(event.test)}"`);@@ -186,6 +191,9 @@ class PlaywrightEnvironment extends NodeEnvironment {};}+ if (event.name === 'error')+ debug('pw:test')(`error "${testOrSuiteName(this._lastTest)}"`, util.inspect(event.error));+if (event.name === 'test_fn_failure') {await this.fixturePool.teardownScope('worker');}diff --git a/test/jest/reporter.js b/test/jest/reporter.jsindex 257cdb994b..169c7bd59d 100644--- a/test/jest/reporter.js+++ b/test/jest/reporter.js@@ -14,13 +14,31 @@* limitations under the License.*/+const colors = require('colors/safe');const fs = require('fs');const os = require('os');+const failures = [];+module.exports = function Reporter() {this.onRunComplete = (test, runResults) => {runResults.platform = process.env.REPORT_ONLY_PLATFORM || os.platform();runResults.browserName = process.env.BROWSER || 'chromium';fs.writeFileSync('jest-report.json', JSON.stringify(runResults, undefined, 2));};+ this.onTestCaseResult = (test, testCaseResult) => {+ if (testCaseResult.status === 'failed')+ failures.push([test, testCaseResult]);+ }}++process.on('SIGINT', async () => {+ for (let i = 0; i < failures.length; ++i) {+ const [test, testCaseResult] = failures[i];+ const path = test.path.replace(/.*test/, 'test');+ const name = colors.yellow(path) + ' — ' + colors.bold(colors.yellow(testCaseResult.fullName));+ process.stderr.write(`\n${i + 1}) ${colors.red('[FAIL]')} ${name}\n\n`);+ process.stderr.write(testCaseResult.failureMessages + '\n');+ }+ process.exit(130);+});