Skip to content

Commit

Permalink
test(playwright): explded os version from snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
mJarsater committed Oct 25, 2023
1 parent 12b1a89 commit 9471c87
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 1 deletion.
1 change: 0 additions & 1 deletion packages/core/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const config: PlaywrightTestConfig = {
reuseExistingServer: !process.env.CI,
},
workers: 4,
snapshotPathTemplate: 'snapshots/{arg}{ext}',
};

export default config;
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';
import { configureSnapshotPath } from '../../../../utils/configureSnapshotPath';

test.beforeEach(configureSnapshotPath());

test.describe('tds-accordiong', () => {
test('renders basic accordion correctly', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';
import { configureSnapshotPath } from '../../../../utils/configureSnapshotPath';

test.beforeEach(configureSnapshotPath());

test.describe('tds-accordiong', () => {
test('renders disabled accordion correctly', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';
import { configureSnapshotPath } from '../../../../utils/configureSnapshotPath';

test.beforeEach(configureSnapshotPath());

test.describe('tds-accordiong', () => {
test('renders expanded accordion correctly', async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';
import { configureSnapshotPath } from '../../../../utils/configureSnapshotPath';

test.beforeEach(configureSnapshotPath());

test.describe('tds-accordiong', () => {
test('renders padding-reset accordion correctly', async ({ page }) => {
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/components/badge/test/basic/badge.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';
import { configureSnapshotPath } from '../../../../utils/configureSnapshotPath';

test.beforeEach(configureSnapshotPath());

test.describe('tds-badge', () => {
test('renders basic badge correctly', async ({ page }) => {
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/components/badge/test/value/badge.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { test } from 'stencil-playwright';
import { expect } from '@playwright/test';
import { configureSnapshotPath } from '../../../../utils/configureSnapshotPath';

test.beforeEach(configureSnapshotPath());

test.describe('tds-badge', () => {
test('renders value badge correctly', async ({ page }) => {
Expand Down
18 changes: 18 additions & 0 deletions packages/core/src/utils/configureSnapshotPath.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable no-unused-vars */
export const configureSnapshotPath =
(options?: {}) =>
({}: any, testInfo): any => {
const originalSnapshotPath = testInfo.snapshotPath;

testInfo.snapshotPath = (snapshotName) => {
const result = originalSnapshotPath
.apply(testInfo, [snapshotName])
.replace('.txt', '.json')
.replace('-chromium', '')
.replace('-linux', '')
.replace('-darwin', '');

return result;
};
};

0 comments on commit 9471c87

Please sign in to comment.