Skip to content

Commit 1d01c93

Browse files
committed
Run tests individually
1 parent 34de2d0 commit 1d01c93

File tree

15 files changed

+228
-207
lines changed

15 files changed

+228
-207
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ docs/libraries
88
out
99
.firebase
1010
.wireit
11+
dist

libraries/__shared__/tests/advanced-tests.test.js

Lines changed: 51 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -16,61 +16,62 @@
1616
*/
1717

1818
import {expect, test} from '@playwright/test';
19-
import {getProp, each, weight} from "./util";
19+
import {getProp, weight} from "./util";
2020

21+
test.beforeEach(async ({page}) => {
22+
await page.goto('/');
23+
})
2124

22-
each(() => {
23-
test.describe('advanced support', weight(2), () => {
24-
test.describe('attributes and properties', () => {
25-
test('will pass array data as a property', async ({page}) => {
26-
const ce = page.locator('#ce-with-properties');
27-
expect(await getProp(ce, 'arr')).toEqual(['c', 'u', 's', 't', 'o', 'm'])
28-
})
25+
test.describe('advanced support', weight(2), () => {
26+
test.describe('attributes and properties', () => {
27+
test('will pass array data as a property', async ({page}) => {
28+
const ce = page.locator('#ce-with-properties');
29+
expect(await getProp(ce, 'arr')).toEqual(['c', 'u', 's', 't', 'o', 'm'])
30+
})
2931

30-
test('will pass object data as a property', async ({page}) => {
31-
const ce = page.locator('#ce-with-properties');
32-
expect(await getProp(ce, 'obj')).toEqual({org: 'webcomponents', repo: 'custom-elements-everywhere'})
33-
})
32+
test('will pass object data as a property', async ({page}) => {
33+
const ce = page.locator('#ce-with-properties');
34+
expect(await getProp(ce, 'obj')).toEqual({org: 'webcomponents', repo: 'custom-elements-everywhere'})
35+
})
3436

35-
test("will pass object data to a camelCase-named property", async ({page}) => {
36-
const ce = page.locator('#ce-with-properties');
37-
expect(await getProp(ce, 'camelCaseObj')).toEqual({label: "passed"})
38-
})
39-
});
37+
test("will pass object data to a camelCase-named property", async ({page}) => {
38+
const ce = page.locator('#ce-with-properties');
39+
expect(await getProp(ce, 'camelCaseObj')).toEqual({label: "passed"})
40+
})
41+
});
4042

41-
test.describe('events', weight(1), () => {
43+
test.describe('events', weight(1), () => {
4244

43-
test("can declaratively listen to a lowercase DOM event dispatched by a Custom Element", weight(2), async ({page}) => {
44-
const ce = page.locator('#ce-with-declarative-event');
45-
await expect(page.getByText(/lowercase:/)).toHaveText(/false/);
46-
await ce.click();
47-
await expect(page.getByText(/lowercase:/)).toHaveText(/true/);
48-
})
45+
test("can declaratively listen to a lowercase DOM event dispatched by a Custom Element", weight(2), async ({page}) => {
46+
const ce = page.locator('#ce-with-declarative-event');
47+
await expect(page.getByText(/lowercase:/)).toHaveText(/false/);
48+
await ce.click();
49+
await expect(page.getByText(/lowercase:/)).toHaveText(/true/);
50+
})
4951

50-
test("can declaratively listen to a camelCase DOM event dispatched by a Custom Element", async ({page}) => {
51-
const ce = page.locator('#ce-with-declarative-event');
52-
await expect(page.getByText(/camelCase:/)).toHaveText(/false/);
53-
await ce.click();
54-
await expect(page.getByText(/camelCase:/)).toHaveText(/true/);
55-
})
56-
test("can declaratively listen to a kebab-case DOM event dispatched by a Custom Element", async ({page}) => {
57-
const ce = page.locator('#ce-with-declarative-event');
58-
await expect(page.getByText(/kebab-case:/)).toHaveText(/false/);
59-
await ce.click();
60-
await expect(page.getByText(/kebab-case:/)).toHaveText(/true/);
61-
})
62-
test("can declaratively listen to a CAPScase DOM event dispatched by a Custom Element", async ({page}) => {
63-
const ce = page.locator('#ce-with-declarative-event');
64-
await expect(page.getByText(/CAPScase:/)).toHaveText(/false/);
65-
await ce.click();
66-
await expect(page.getByText(/CAPScase:/)).toHaveText(/true/);
67-
})
68-
test("can declaratively listen to a PascalCase DOM event dispatched by a Custom Element", async ({page}) => {
69-
const ce = page.locator('#ce-with-declarative-event');
70-
await expect(page.getByText(/PascalCase:/)).toHaveText(/false/);
71-
await ce.click();
72-
await expect(page.getByText(/PascalCase:/)).toHaveText(/true/);
73-
})
74-
});
75-
})
52+
test("can declaratively listen to a camelCase DOM event dispatched by a Custom Element", async ({page}) => {
53+
const ce = page.locator('#ce-with-declarative-event');
54+
await expect(page.getByText(/camelCase:/)).toHaveText(/false/);
55+
await ce.click();
56+
await expect(page.getByText(/camelCase:/)).toHaveText(/true/);
57+
})
58+
test("can declaratively listen to a kebab-case DOM event dispatched by a Custom Element", async ({page}) => {
59+
const ce = page.locator('#ce-with-declarative-event');
60+
await expect(page.getByText(/kebab-case:/)).toHaveText(/false/);
61+
await ce.click();
62+
await expect(page.getByText(/kebab-case:/)).toHaveText(/true/);
63+
})
64+
test("can declaratively listen to a CAPScase DOM event dispatched by a Custom Element", async ({page}) => {
65+
const ce = page.locator('#ce-with-declarative-event');
66+
await expect(page.getByText(/CAPScase:/)).toHaveText(/false/);
67+
await ce.click();
68+
await expect(page.getByText(/CAPScase:/)).toHaveText(/true/);
69+
})
70+
test("can declaratively listen to a PascalCase DOM event dispatched by a Custom Element", async ({page}) => {
71+
const ce = page.locator('#ce-with-declarative-event');
72+
await expect(page.getByText(/PascalCase:/)).toHaveText(/false/);
73+
await ce.click();
74+
await expect(page.getByText(/PascalCase:/)).toHaveText(/true/);
75+
})
76+
});
7677
})

libraries/__shared__/tests/basic-tests.test.js

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -16,73 +16,75 @@
1616
*/
1717

1818
import {expect, test} from '@playwright/test';
19-
import {each, getPropOrAttr, weight} from './util';
19+
import { getPropOrAttr, weight} from './util';
2020

2121

22-
each(() => {
23-
test.describe("basic support", weight(3), () => {
24-
test.describe("no children", () => {
25-
test("can display a Custom Element with no children", async ({page}) => {
26-
await expect(page.locator('#ce-without-children')).toBeAttached();
27-
});
22+
test.beforeEach(async ({page}) => {
23+
await page.goto('/');
24+
})
2825

29-
test.describe('with children', () => {
30-
const expectHasChildren = async (wc) => {
31-
await expect(wc.locator('h1')).toHaveText('Test h1');
32-
await expect(wc.locator('p')).toHaveText('Test p');
33-
}
26+
test.describe("basic support", weight(3), () => {
27+
test.describe("no children", () => {
28+
test("can display a Custom Element with no children", async ({page}) => {
29+
await expect(page.locator('#ce-without-children')).toBeAttached();
30+
});
31+
32+
test.describe('with children', () => {
33+
const expectHasChildren = async (wc) => {
34+
await expect(wc.locator('h1')).toHaveText('Test h1');
35+
await expect(wc.locator('p')).toHaveText('Test p');
36+
}
3437

35-
test("can display a Custom Element with children in a Shadow Root", async ({page}) => {
36-
await expectHasChildren(page.locator('#ce-with-children'))
37-
})
38+
test("can display a Custom Element with children in a Shadow Root", async ({page}) => {
39+
await expectHasChildren(page.locator('#ce-with-children'))
40+
})
3841

39-
test("can display a Custom Element with children in a Shadow Root and pass in Light DOM children", async ({page}) => {
40-
const ce = page.locator('#ce-with-children-renderer');
41-
await expectHasChildren(ce);
42-
await expect(ce).toHaveText(/2/);
43-
})
42+
test("can display a Custom Element with children in a Shadow Root and pass in Light DOM children", async ({page}) => {
43+
const ce = page.locator('#ce-with-children-renderer');
44+
await expectHasChildren(ce);
45+
await expect(ce).toHaveText(/2/);
46+
})
4447

45-
test('can display a Custom Element with children in the Shadow DOM and handle hiding and showing the element', async ({page}) => {
46-
const ce = page.locator('#ce-with-different-views')
47-
const toggle = page.getByRole('button', {name: /toggle views/i});
48+
test('can display a Custom Element with children in the Shadow DOM and handle hiding and showing the element', async ({page}) => {
49+
const ce = page.locator('#ce-with-different-views')
50+
const toggle = page.getByRole('button', {name: /toggle views/i});
4851

49-
await expectHasChildren(ce);
52+
await expectHasChildren(ce);
5053

51-
await toggle.click();
52-
await expect(ce).toHaveText(/dummy view/i);
54+
await toggle.click();
55+
await expect(ce).toHaveText(/dummy view/i);
5356

54-
await toggle.click();
55-
await expectHasChildren(ce);
56-
})
57+
await toggle.click();
58+
await expectHasChildren(ce);
5759
})
60+
})
61+
});
62+
63+
test.describe('attributes and properties', () => {
64+
test("will pass boolean data as either an attribute or a property", async ({page}) => {
65+
const ce = page.locator('#ce-with-properties');
66+
expect(await getPropOrAttr(ce, 'bool')).toEqual(true)
5867
});
5968

60-
test.describe('attributes and properties', () => {
61-
test("will pass boolean data as either an attribute or a property", async ({page}) => {
62-
const ce = page.locator('#ce-with-properties');
63-
expect(await getPropOrAttr(ce, 'bool')).toEqual(true)
64-
});
65-
66-
test("will pass numeric data as either an attribute or a property", async ({page}) => {
67-
const ce = page.locator('#ce-with-properties');
68-
expect(parseInt(await getPropOrAttr(ce, 'num'))).toEqual(42)
69-
});
70-
71-
test("will pass string data as either an attribute or a property", async ({page}) => {
72-
const ce = page.locator('#ce-with-properties');
73-
expect(await getPropOrAttr(ce, 'str')).toEqual("custom")
74-
});
69+
test("will pass numeric data as either an attribute or a property", async ({page}) => {
70+
const ce = page.locator('#ce-with-properties');
71+
expect(parseInt(await getPropOrAttr(ce, 'num'))).toEqual(42)
7572
});
7673

77-
test.describe('events', () => {
78-
test("can imperatively listen to a DOM event dispatched by a Custom Element", async ({page}) => {
79-
const ce = page.locator('#ce-with-imperative-event');
80-
const result = page.locator('#ce-with-imperative-event-handled');
81-
await expect(result).toHaveText(/false/i);
82-
await ce.click();
83-
await expect(result).toHaveText(/true/i);
84-
})
74+
test("will pass string data as either an attribute or a property", async ({page}) => {
75+
const ce = page.locator('#ce-with-properties');
76+
expect(await getPropOrAttr(ce, 'str')).toEqual("custom")
77+
});
78+
});
79+
80+
test.describe('events', () => {
81+
test("can imperatively listen to a DOM event dispatched by a Custom Element", async ({page}) => {
82+
const ce = page.locator('#ce-with-imperative-event');
83+
const result = page.locator('#ce-with-imperative-event-handled');
84+
await expect(result).toHaveText(/false/i);
85+
await ce.click();
86+
await expect(result).toHaveText(/true/i);
8587
})
88+
})
8689

87-
});
8890
});

libraries/__shared__/tests/package.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,21 @@
77
"private": true,
88
"scripts": {
99
"serve": "http-server harness",
10-
"test": "wireit"
10+
"test": "playwright test"
1111
},
1212
"devDependencies": {
1313
"@playwright/test": "^1.56.1",
1414
"http-server": "^14.1.1"
1515
},
1616
"wireit": {
17-
"test": {
18-
"dependencies": [
19-
"../../react:build",
20-
"../../svelte:build"
21-
],
17+
"test-files": {
2218
"files": [
2319
"advanced-tests.test.js",
2420
"basic-tests.test.js",
2521
"playwright.config.js",
2622
"reporter.js",
2723
"utils.js"
28-
],
29-
"command": "playwright test"
24+
]
3025
}
3126
}
3227
}

libraries/__shared__/tests/playwright.config.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,27 @@ export default defineConfig({
77
projects: [
88
{
99
name: 'chromium',
10-
use: { ...devices['Desktop Chrome'] },
10+
use: {...devices['Desktop Chrome']},
1111
},
1212
{
1313
name: 'firefox',
14-
use: { ...devices['Desktop Firefox'] },
14+
use: {...devices['Desktop Firefox']},
1515
},
1616
],
1717
webServer: {
18-
command: 'pnpm serve',
18+
command: `http-server ../../${process.env.CEE_WORKSPACE}/dist/`,
1919
url: 'http://localhost:8080',
2020
reuseExistingServer: !process.env.CI,
2121
stdout: 'ignore',
2222
stderr: 'pipe'
2323
},
2424
reporter: [
2525
['list'],
26+
['html', {
27+
outputFolder: `../../${process.env.CEE_WORKSPACE}/results/`,
28+
open: 'never',
29+
title: process.env.CEE_WORKSPACE
30+
}],
2631
['./reporter.js']
2732
]
2833
})

0 commit comments

Comments
 (0)