Skip to content

Commit

Permalink
fix playwright tests
Browse files Browse the repository at this point in the history
  • Loading branch information
epszaw committed May 17, 2024
1 parent 48d0df5 commit d1d32fe
Show file tree
Hide file tree
Showing 23 changed files with 99 additions and 95 deletions.
123 changes: 62 additions & 61 deletions .pnp.cjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ packageExtensions:
postman-sandbox@*:
dependencies:
postman-collection: "*"
allure-js-commons@*:
dependencies:
allure-playwright: "workspace:*"

plugins:
- ./plugin-ci-version.js
Expand Down
1 change: 1 addition & 0 deletions packages/allure-js-commons/src/TestRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const getGlobalTestRuntime = (): TestRuntime => {
try {
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("allure-playwright/autoconfig");

return getGlobalTestRuntimeFunction()?.() ?? noopRuntime;
} catch (err) {
// eslint-disable-next-line no-console
Expand Down
1 change: 0 additions & 1 deletion packages/allure-playwright/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
Status,
TestRuntime,
getStatusFromError,
setGlobalTestRuntime,
} from "allure-js-commons/sdk/node";

export class AllurePlaywrightTestRuntime implements TestRuntime {
Expand Down
8 changes: 4 additions & 4 deletions packages/allure-playwright/test/spec/attachment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { runPlaywrightInlineTest } from "../utils";
it("doesn't not throw on missing attachment", async () => {
const { tests, attachments } = await runPlaywrightInlineTest({
"sample.test.js": `
import test from 'allure-playwright';
import test from '@playwright/test';
test('should add attachment', async ({}, testInfo) => {
testInfo.attachments.push({
Expand Down Expand Up @@ -37,7 +37,7 @@ it("doesn't not throw on missing attachment", async () => {
it("adds snapshots correctly and provide a screenshot diff", async () => {
const { tests } = await runPlaywrightInlineTest({
"sample.test.js": `
import test from 'allure-playwright';
import test from '@playwright/test';
test('should add attachment', async ({ page }, testInfo) => {
testInfo.snapshotSuffix = '';
Expand All @@ -61,7 +61,7 @@ it("adds snapshots correctly and provide a screenshot diff", async () => {
it("should add attachments into steps", async () => {
const { tests, attachments } = await runPlaywrightInlineTest({
"sample.test.js": `
import test from 'allure-playwright';
import test from '@playwright/test';
import { step, attachment } from 'allure-js-commons';
test('should add attachment', async ({}, testInfo) => {
Expand Down Expand Up @@ -160,7 +160,7 @@ it("should add attachments into steps", async () => {
it("doesn't not report detail steps for attachments", async () => {
const { tests, attachments } = await runPlaywrightInlineTest({
"sample.test.js": `
import test from 'allure-playwright';
import test from '@playwright/test';
import { step, attachment } from 'allure-js-commons';
test('should add attachment', async ({}, testInfo) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/allure-playwright/test/spec/categories.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { runPlaywrightInlineTest } from "../utils";
it("has categories", async () => {
const { categories } = await runPlaywrightInlineTest({
"a.test.ts": `
import { test, expect } from 'allure-playwright';
import { test, expect } from '@playwright/test';
test('does nothing', async ({}, testInfo) => {
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { runPlaywrightInlineTest } from "../utils";
it("has environment info", async () => {
const { envInfo } = await runPlaywrightInlineTest({
"a.test.ts": `
import { test, expect } from 'allure-playwright';
import { test, expect } from '@playwright/test';
test('does nothing', async ({}, testInfo) => {
});
Expand Down
2 changes: 1 addition & 1 deletion packages/allure-playwright/test/spec/history.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { runPlaywrightInlineTest } from "../utils";
it("historical data should be fine", async () => {
const { tests } = await runPlaywrightInlineTest({
"sample.test.js": `
import { test } from 'allure-playwright';
import { test } from '@playwright/test';
test.describe('nested', () => {
test('test', async ({}, testInfo) => {});
Expand Down
4 changes: 2 additions & 2 deletions packages/allure-playwright/test/spec/hooks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { runPlaywrightInlineTest } from "../utils";
it("handles before hooks", async () => {
const { tests } = await runPlaywrightInlineTest({
"sample.test.js": `
import test from 'allure-playwright';
import test from '@playwright/test';
test.beforeAll(async () => {});
Expand Down Expand Up @@ -34,7 +34,7 @@ it("handles before hooks", async () => {
it("handles after hooks", async () => {
const results = await runPlaywrightInlineTest({
"sample.test.js": `
import test from 'allure-playwright';
import test from '@playwright/test';
test.afterAll(async () => {});
Expand Down
6 changes: 3 additions & 3 deletions packages/allure-playwright/test/spec/labelOverride.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { runPlaywrightInlineTest } from "../utils";
it("overrides suite label", async () => {
const { tests } = await runPlaywrightInlineTest({
"a.test.ts": `
import { test, expect } from 'allure-playwright';
import { test, expect } from '@playwright/test';
import { suite } from "allure-js-commons"
test('should override SUITE label', async ({}) => {
Expand All @@ -25,7 +25,7 @@ it("overrides suite label", async () => {
it("overrides parent-suite label", async () => {
const { tests } = await runPlaywrightInlineTest({
"a.test.ts": `
import { test, expect } from 'allure-playwright';
import { test, expect } from '@playwright/test';
import { parentSuite } from "allure-js-commons"
test('should override PARENT SUITE label', async ({}) => {
Expand All @@ -45,7 +45,7 @@ it("overrides parent-suite label", async () => {
it("overrides sub-suite label", async () => {
const { tests } = await runPlaywrightInlineTest({
"a.test.ts": `
import { test, expect } from 'allure-playwright';
import { test, expect } from '@playwright/test';
import { subSuite } from "allure-js-commons"
test('should override SUB SUITE label', async ({}) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/allure-playwright/test/spec/labels.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ it("sets runtime labels", async () => {
it("reports a single suite structure", async () => {
const { tests } = await runPlaywrightInlineTest({
"sample.test.js": `
import test from 'allure-playwright';
import test from '@playwright/test';
test.describe('suite', () => {
test('should work', async ({}) => {});
Expand Down Expand Up @@ -118,7 +118,7 @@ it("reports a single suite structure", async () => {
it("reports a multiple nested suites structure", async () => {
const { tests } = await runPlaywrightInlineTest({
"sample.test.js": `
import test from 'allure-playwright';
import test from '@playwright/test';
test.describe('parent suite 2', () => {
test.describe('suite 2', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/allure-playwright/test/spec/links.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { runPlaywrightInlineTest } from "../utils";
it("sets runtime links", async () => {
const results = await runPlaywrightInlineTest({
"sample.test.js": `
import { test } from 'allure-playwright';
import { test } from '@playwright/test';
import { link, links, issue, tms } from 'allure-js-commons';
test('should add epic link', async ({}, testInfo) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/allure-playwright/test/spec/parameters.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ it("sets parameters", async () => {
const { tests } = await runPlaywrightInlineTest(
{
"sample.test.js": `
import { test, expect } from 'allure-playwright';
import { test, expect } from '@playwright/test';
import { parameter } from "allure-js-commons";
test('should add epic label', async ({}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { LabelName } from "allure-js-commons";
import { runPlaywrightInlineTest } from "../utils";

const testFile = `
import test from 'allure-playwright';
import test from '@playwright/test';
test.beforeEach(() => {
console.log("This is the beforeEach hook");
Expand Down
2 changes: 1 addition & 1 deletion packages/allure-playwright/test/spec/skip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { runPlaywrightInlineTest } from "../utils";
it("reports programmatically skipped results", async () => {
const { tests } = await runPlaywrightInlineTest({
"sample.test.js": `
import test from 'allure-playwright';
import test from '@playwright/test';
test.skip('should be skipped 1', async () => {});
Expand Down
2 changes: 1 addition & 1 deletion packages/allure-playwright/test/spec/status.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { runPlaywrightInlineTest } from "../utils";
it("reports test status", async () => {
const { tests } = await runPlaywrightInlineTest({
"sample.test.js": `
import { test, expect } from 'allure-playwright';
import { test, expect } from '@playwright/test';
test('should pass', async ({}) => {
});
Expand Down
2 changes: 1 addition & 1 deletion packages/allure-playwright/test/spec/statusDetails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { runPlaywrightInlineTest } from "../utils";
it("reports test status details", async () => {
const { tests } = await runPlaywrightInlineTest({
"sample.test.js": `
import { test, expect } from 'allure-playwright';
import { test, expect } from '@playwright/test';
test('should fail', async ({}) => {
expect(true).toBe(false);
Expand Down
2 changes: 1 addition & 1 deletion packages/allure-playwright/test/spec/stdio.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { runPlaywrightInlineTest } from "../utils";
it("reports stdout", async () => {
const { tests, attachments } = await runPlaywrightInlineTest({
"sample.test.js": `
import test from 'allure-playwright';
import test from '@playwright/test';
test("Demo test", async () => {
console.log("Test log");
Expand Down
4 changes: 2 additions & 2 deletions packages/allure-playwright/test/spec/steps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { runPlaywrightInlineTest } from "../utils";
it("reports test steps", async () => {
const { tests } = await runPlaywrightInlineTest({
"a.test.js": `
import { test, expect } from 'allure-playwright';
import { test, expect } from '@playwright/test';
test('should pass', async ({}) => {
await test.step('outer step 1', async () => {
Expand Down Expand Up @@ -77,7 +77,7 @@ it("reports test steps", async () => {
it("reports failed test steps", async () => {
const { tests } = await runPlaywrightInlineTest({
"a.test.ts": `
import { test, expect } from 'allure-playwright';
import { test, expect } from '@playwright/test';
test('should pass', async ({}) => {
await test.step('outer step 1', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/allure-playwright/test/spec/tags.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { runPlaywrightInlineTest } from "../utils";
it("sets multiply tags", async () => {
const results = await runPlaywrightInlineTest({
"sample.test.js": `
import { test } from 'allure-playwright';
import { test } from '@playwright/test';
import { tag, tags } from 'allure-js-commons';
test('should add multiply tags', async ({}, testInfo) => {
Expand Down
12 changes: 6 additions & 6 deletions packages/allure-playwright/test/spec/testplan.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,32 @@ it("respects testplan", async () => {
{
[testPlanFilename]: JSON.stringify(exampleTestPlan),
"a.test.ts": /* ts */ `
import { test, expect } from 'allure-playwright';
import { test, expect } from '@playwright/test';
test('should not execute', async ({}, testInfo) => {
expect(1).toBe(1);
});
`,
"b.test.ts": /* ts */ `
import { test, expect } from 'allure-playwright';
import { test, expect } from '@playwright/test';
test('should execute', async ({}, testInfo) => {
expect(1).toBe(1);
});
`,
"nested/super strange nested/super strange name.test.ts": /* ts */ `
import { test, expect } from 'allure-playwright';
import { test, expect } from '@playwright/test';
test.describe('also nested', () => {
test('should execute', async ({}, testInfo) => {
});
});
`,
".+.test.ts": /* ts */ `
import { test, expect } from 'allure-playwright';
import { test, expect } from '@playwright/test';
test('+.', async ({}, testInfo) => {
expect(1).toBe(1);
});
`,
"aga.test.ts": /* ts */ `
import { test, expect } from 'allure-playwright';
import { test, expect } from '@playwright/test';
test('a', async ({}, testInfo) => {
expect(1).toBe(1);
});
Expand All @@ -71,7 +71,7 @@ it("respects testplan", async () => {
});
`,
"notaga.test.ts": /* ts */ `
import { test, expect } from 'allure-playwright';
import { test, expect } from '@playwright/test';
test('a', async ({}, testInfo) => {
expect(1).toBe(1);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/allure-playwright/test/spec/titleMetadata.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { runPlaywrightInlineTest } from "../utils";
it("has metadata from title", async () => {
const { tests } = await runPlaywrightInlineTest({
"sample.test.js": `
import { test } from 'allure-playwright';
import { test } from '@playwright/test';
test('some strange name to test @allure.id=228 @allure.label.tag=slow @allure.label.labelName=labelValue', async ({}, testInfo) => {
});
Expand All @@ -28,7 +28,7 @@ it("has metadata from title", async () => {
it("supports multiline name", async () => {
const results = await runPlaywrightInlineTest({
"sample.test.js": `
import { test } from 'allure-playwright';
import { test } from '@playwright/test';
test(
\`some strange name to test @allure.label.l1=v1
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3764,7 +3764,7 @@ __metadata:
languageName: unknown
linkType: soft

"allure-playwright@workspace:packages/allure-playwright":
"allure-playwright@workspace:*, allure-playwright@workspace:packages/allure-playwright":
version: 0.0.0-use.local
resolution: "allure-playwright@workspace:packages/allure-playwright"
dependencies:
Expand Down

0 comments on commit d1d32fe

Please sign in to comment.