Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

playwright-json-summary-reporter

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

playwright-json-summary-reporter - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

tests/after.teardown.ts

28

build/src/index.js

@@ -11,3 +11,5 @@ "use strict";

this.warned = [];
this.interrupted = [];
this.timedOut = [];
this.flakey = [];
this.status = 'unknown';

@@ -29,3 +31,3 @@ this.startedAt = 0;

title.push(s);
if (s.includes('spec.ts')) {
if (s.includes('.ts') || s.includes('.js')) {
fileName.push(s);

@@ -36,7 +38,15 @@ }

var z = "".concat(fileName[0], ":").concat(test.location.line, ":").concat(test.location.column);
// Using the t variable in the push will push a full test test name + test description
// Using the t variable in the push will push a full test name + test description
var t = title.join(' > ');
// Set the status
var status = !['passed', 'skipped'].includes(result.status) && t.includes('@warn')
? 'warned'
: result.status;
// Logic to push the results into the correct array
if (result.status === 'passed' && result.retry >= 1) {
this.flakey.push(z);
}
else {
this[status].push(z);
}
this[status].push(z);

@@ -52,3 +62,3 @@ };

});
// removing duplicate and flakey (passed on a retry) tests from the failed array
// removing duplicate tests from the failed array
this.failed = this.failed.filter(function (element, index) {

@@ -58,2 +68,14 @@ if (!_this.passed.includes(element))

});
// removing duplicate tests from the skipped array
this.skipped = this.skipped.filter(function (element, index) {
return _this.skipped.indexOf(element) === index;
});
// removing duplicate tests from the timedOut array
this.timedOut = this.timedOut.filter(function (element, index) {
return _this.timedOut.indexOf(element) === index;
});
// removing duplicate tests from the interrupted array
this.interrupted = this.interrupted.filter(function (element, index) {
return _this.interrupted.indexOf(element) === index;
});
fs.writeFileSync('./summary.json', JSON.stringify(this, null, ' '));

@@ -60,0 +82,0 @@ };

4

package.json
{
"name": "playwright-json-summary-reporter",
"version": "1.0.0",
"version": "1.0.1",
"description": "A Simple Playwright Reporter",

@@ -16,3 +16,3 @@ "license": "MIT",

"devDependencies": {
"@playwright/test": "^1.29.2",
"@playwright/test": "^1.38.1",
"@types/node": "^14.11.2",

@@ -19,0 +19,0 @@ "gts": "^3.1.1",

@@ -1,107 +0,20 @@

import type { PlaywrightTestConfig } from '@playwright/test';
import { devices } from '@playwright/test';
import {defineConfig} from '@playwright/test';
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
/**
* See https://playwright.dev/docs/test-configuration.
*/
const config: PlaywrightTestConfig = {
export default defineConfig({
testDir: './tests',
/* Maximum time one test can run for. */
timeout: 30 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 5000
},
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://localhost:3000',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
/* Configure projects for major browsers */
retries: process.env.CI ? 2 : 2,
trace: 'on-first-retry',
reporter: [['list'], ['./src/index.ts']],
projects: [
{name: 'setup', testMatch: /.setup.ts/},
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
},
name: 'tests',
dependencies: ['setup'],
},
{
name: 'firefox',
use: {
...devices['Desktop Firefox'],
},
name: 'teardown',
dependencies: ['setup'],
testMatch: /.teardown.ts/,
},
{
name: 'webkit',
use: {
...devices['Desktop Safari'],
},
},
/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: {
// ...devices['Pixel 5'],
// },
// },
// {
// name: 'Mobile Safari',
// use: {
// ...devices['iPhone 12'],
// },
// },
/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: {
// channel: 'msedge',
// },
// },
// {
// name: 'Google Chrome',
// use: {
// channel: 'chrome',
// },
// },
],
/* Folder for test artifacts such as screenshots, videos, traces, etc. */
// outputDir: 'test-results/',
/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// port: 3000,
// },
};
export default config;
});

@@ -29,29 +29,28 @@ # playwright-json-summary-reporter

{
"durationInMS": 41565,
"durationInMS": 3260,
"passed": [
"api/create-user-account.spec.ts:34:3",
"api/create-user-account.spec.ts:55:3",
"api/delete-user-account.spec.ts:47:3",
"api/login.spec.ts:12:3",
"api/login.spec.ts:37:3",
"api/login.spec.ts:61:3",
"api/login.spec.ts:84:3",
"ui/codepen/copyToClipboard.spec.ts:5:1",
"ui/codepen/copyToClipboard.spec.ts:17:1",
"ui/internet.app/selectPresentElement.spec.ts:10:1",
"ui/internet.app/selectPresentElement.spec.ts:35:1",
"ui/grep.spec.ts:4:3",
"ui/grep.spec.ts:9:3",
"ui/loginUser.spec.ts:22:3",
"ui/loginUserNoImages.spec.ts:23:3",
"ui/loginUser.spec.ts:37:3",
"ui/loginUserNoImages.spec.ts:40:3",
"ui/registerUser.spec.ts:17:1"
"before.setup.ts:3:6",
"after.teardown.ts:3:9",
"tests.spec.ts:6:7",
"tests.spec.ts:9:7",
"tests.spec.ts:12:7",
"tests.spec.ts:18:7",
"tests.spec.ts:28:7"
],
"skipped": [],
"failed": [],
"skipped": [
"tests.spec.ts:21:8"
],
"failed": [
"tests.spec.ts:15:7"
],
"warned": [],
"timedOut": [],
"status": "passed",
"startedAt": 1674431153277
"interrupted": [],
"timedOut": [
"tests.spec.ts:24:7"
],
"flakey": [
"tests.spec.ts:18:7"
],
"status": "failed",
"startedAt": 1696537674443
}

@@ -61,1 +60,6 @@ ```

If you found this helpful feel free to check out <https://playwrightsolutions.com>!
**Note:**
* This reporter doesn't support parameterized tests.
* The tests that are listed in flakey are also listed in the passed array, but not in the failed array. This was a decision that I made as the test eventually passed.

@@ -15,3 +15,6 @@ import * as fs from 'fs';

warned: string[];
interrupted: string[];
timedOut: string[];
flakey: string[];
status: FullResult['status'] | 'unknown' | 'warned' | 'skipped';

@@ -26,3 +29,5 @@ }

warned: string[] = [];
interrupted: string[] = [];
timedOut: string[] = [];
flakey: string[] = [];

@@ -44,3 +49,3 @@ status: Summary['status'] = 'unknown';

title.push(s);
if (s.includes('spec.ts')) {
if (s.includes('.ts') || s.includes('.js')) {
fileName.push(s);

@@ -53,5 +58,6 @@ }

// Using the t variable in the push will push a full test test name + test description
// Using the t variable in the push will push a full test name + test description
const t = title.join(' > ');
// Set the status
const status =

@@ -61,2 +67,9 @@ !['passed', 'skipped'].includes(result.status) && t.includes('@warn')

: result.status;
// Logic to push the results into the correct array
if (result.status === 'passed' && result.retry >= 1) {
this.flakey.push(z);
} else {
this[status].push(z);
}
this[status].push(z);

@@ -74,3 +87,3 @@ }

// removing duplicate and flakey (passed on a retry) tests from the failed array
// removing duplicate tests from the failed array
this.failed = this.failed.filter((element, index) => {

@@ -81,2 +94,17 @@ if (!this.passed.includes(element))

// removing duplicate tests from the skipped array
this.skipped = this.skipped.filter((element, index) => {
return this.skipped.indexOf(element) === index;
});
// removing duplicate tests from the timedOut array
this.timedOut = this.timedOut.filter((element, index) => {
return this.timedOut.indexOf(element) === index;
});
// removing duplicate tests from the interrupted array
this.interrupted = this.interrupted.filter((element, index) => {
return this.interrupted.indexOf(element) === index;
});
fs.writeFileSync('./summary.json', JSON.stringify(this, null, ' '));

@@ -83,0 +111,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc