@blockquote/create-wc 2.5.1 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/common-linting/templates/package.json +1 -1
- package/src/common-repo/templates/package.json +6 -6
- package/src/common-repo/templates/static/vite.config.js +7 -9
- package/src/testing/templates/my-el.test.js +24 -37
- package/src/testing-ts/templates/my-el.test.ts +24 -38
package/package.json
CHANGED
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"chai-a11y-axe": "^1.5.0",
|
|
44
44
|
"concurrently": "^9.2.1",
|
|
45
45
|
"sort-package-json": "^3.4.0",
|
|
46
|
-
"@vitest/browser": "^
|
|
47
|
-
"@vitest/coverage-istanbul": "^
|
|
48
|
-
"@vitest/coverage-v8": "^
|
|
49
|
-
"@vitest/ui": "^
|
|
50
|
-
"vitest": "^
|
|
51
|
-
"vite": "^7.1.
|
|
46
|
+
"@vitest/browser-playwright": "^4.0.3",
|
|
47
|
+
"@vitest/coverage-istanbul": "^4.0.3",
|
|
48
|
+
"@vitest/coverage-v8": "^4.0.3",
|
|
49
|
+
"@vitest/ui": "^4.0.3",
|
|
50
|
+
"vitest": "^4.0.3",
|
|
51
|
+
"vite": "^7.1.12"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {defineConfig} from 'vite';
|
|
2
|
+
import {playwright} from '@vitest/browser-playwright';
|
|
2
3
|
import {globSync} from 'tinyglobby';
|
|
3
4
|
import copy from 'rollup-plugin-copy';
|
|
4
5
|
import totalBundlesize from '@blockquote/rollup-plugin-total-bundlesize';
|
|
@@ -39,22 +40,19 @@ export default defineConfig({
|
|
|
39
40
|
browser: {
|
|
40
41
|
enabled: true,
|
|
41
42
|
headless: false,
|
|
42
|
-
provider:
|
|
43
|
+
provider: playwright({
|
|
44
|
+
launchOptions: {
|
|
45
|
+
devtools: true,
|
|
46
|
+
args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-gpu'],
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
43
49
|
screenshotFailures: false,
|
|
44
|
-
viewport: {width: 1920, height: 1080},
|
|
45
50
|
instances: [
|
|
46
51
|
{
|
|
47
52
|
browser: 'chromium',
|
|
48
|
-
launch: {
|
|
49
|
-
devtools: true,
|
|
50
|
-
args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-gpu'],
|
|
51
|
-
},
|
|
52
|
-
context: {},
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
browser: 'webkit',
|
|
56
|
-
launch: {},
|
|
57
|
-
context: {},
|
|
58
56
|
},
|
|
59
57
|
],
|
|
60
58
|
},
|
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
test,
|
|
4
|
-
assert,
|
|
5
|
-
expect,
|
|
6
|
-
beforeAll,
|
|
7
|
-
afterAll,
|
|
8
|
-
beforeEach,
|
|
9
|
-
afterEach,
|
|
10
|
-
vi,
|
|
11
|
-
chai,
|
|
12
|
-
} from 'vitest';
|
|
13
|
-
import {getElementLocatorSelectors} from '@vitest/browser/utils';
|
|
14
|
-
import {html} from 'lit';
|
|
15
|
-
import {chaiA11yAxe} from 'chai-a11y-axe';
|
|
1
|
+
import {describe, it, expect, beforeAll, afterAll, beforeEach, afterEach, vi, chai} from 'vitest';
|
|
2
|
+
import {utils} from 'vitest/browser';
|
|
16
3
|
import {fixture, fixtureCleanup} from '@open-wc/testing-helpers';
|
|
4
|
+
import {chaiA11yAxe} from 'chai-a11y-axe';
|
|
17
5
|
import {getDiffableHTML} from '@open-wc/semantic-dom-diff/get-diffable-html.js';
|
|
6
|
+
import {html} from 'lit';
|
|
18
7
|
import '../src/define/<%= tagName %>.js';
|
|
19
8
|
|
|
20
9
|
chai.use(chaiA11yAxe);
|
|
21
10
|
|
|
22
|
-
|
|
11
|
+
describe('<%= className %>', () => {
|
|
23
12
|
/**
|
|
24
13
|
* @type {import('../src/index').<%= className %>}
|
|
25
14
|
*/
|
|
@@ -27,77 +16,75 @@ suite('<%= className %>', () => {
|
|
|
27
16
|
let elShadowRoot;
|
|
28
17
|
let elLocator;
|
|
29
18
|
|
|
30
|
-
|
|
19
|
+
describe('Semantic Dom and a11y', () => {
|
|
31
20
|
beforeAll(async () => {
|
|
32
21
|
el = await fixture(html`<<%= tagName %>>light-dom</<%= tagName %>>`);
|
|
33
22
|
elShadowRoot = el?.shadowRoot?.innerHTML;
|
|
34
|
-
elLocator = getElementLocatorSelectors(el);
|
|
23
|
+
elLocator = utils.getElementLocatorSelectors(el);
|
|
35
24
|
});
|
|
36
25
|
|
|
37
26
|
afterAll(() => {
|
|
38
27
|
fixtureCleanup();
|
|
39
28
|
});
|
|
40
29
|
|
|
41
|
-
|
|
30
|
+
it('has a default heading "Hey there" and counter 5', () => {
|
|
42
31
|
const button = elLocator.getByText('Counter: 5').query();
|
|
43
32
|
const heading = elLocator.getByText('Hey there').query();
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
expect(button).toBeTruthy();
|
|
34
|
+
expect(heading).toBeTruthy();
|
|
46
35
|
});
|
|
47
36
|
|
|
48
|
-
|
|
37
|
+
it('SHADOW DOM - Structure test', () => {
|
|
49
38
|
expect(getDiffableHTML(elShadowRoot)).toMatchSnapshot('SHADOW DOM');
|
|
50
39
|
});
|
|
51
40
|
|
|
52
|
-
|
|
41
|
+
it('LIGHT DOM - Structure test', () => {
|
|
53
42
|
expect(getDiffableHTML(el, {ignoreAttributes: ['id']})).toMatchSnapshot('LIGHT DOM');
|
|
54
43
|
});
|
|
55
44
|
|
|
56
|
-
|
|
57
|
-
await
|
|
45
|
+
it('a11y', async () => {
|
|
46
|
+
await expect(el).accessible();
|
|
58
47
|
});
|
|
59
48
|
});
|
|
60
49
|
|
|
61
|
-
|
|
50
|
+
describe('Events ', () => {
|
|
62
51
|
beforeEach(async () => {
|
|
63
52
|
el = await fixture(html`<<%= tagName %>></<%= tagName %>>`);
|
|
64
|
-
elLocator = getElementLocatorSelectors(el);
|
|
53
|
+
elLocator = utils.getElementLocatorSelectors(el);
|
|
65
54
|
});
|
|
66
55
|
|
|
67
56
|
afterEach(() => {
|
|
68
57
|
fixtureCleanup();
|
|
69
58
|
});
|
|
70
59
|
|
|
71
|
-
|
|
60
|
+
it('should increment value on click', async () => {
|
|
72
61
|
const button = elLocator.getByText('Counter: 5');
|
|
73
62
|
const elButton = button.query();
|
|
74
63
|
await button.dblClick();
|
|
75
64
|
await el.updateComplete;
|
|
76
|
-
|
|
65
|
+
expect(elButton.textContent).toContain('Counter: 7');
|
|
77
66
|
});
|
|
78
67
|
|
|
79
|
-
|
|
68
|
+
it('counterchange event is dispatched - vi', async () => {
|
|
80
69
|
const spyEvent = vi.spyOn(el, 'dispatchEvent');
|
|
81
70
|
const button = elLocator.getByText('Counter: 5');
|
|
82
71
|
await button.click();
|
|
83
|
-
|
|
84
|
-
const calledWithCounterChange = spyEvent.mock.lastCall?.[0].type === 'counterchange';
|
|
85
|
-
assert.isTrue(calledWithCounterChange);
|
|
72
|
+
expect(spyEvent).toHaveBeenCalledWith(expect.objectContaining({type: 'counterchange'}));
|
|
86
73
|
});
|
|
87
74
|
});
|
|
88
75
|
|
|
89
|
-
|
|
76
|
+
describe('Override ', () => {
|
|
90
77
|
beforeAll(async () => {
|
|
91
78
|
el = await fixture(html`<<%= tagName %> heading="attribute heading"></<%= tagName %>>`);
|
|
92
|
-
elLocator = getElementLocatorSelectors(el);
|
|
79
|
+
elLocator = utils.getElementLocatorSelectors(el);
|
|
93
80
|
|
|
94
81
|
return () => {
|
|
95
82
|
fixtureCleanup();
|
|
96
83
|
};
|
|
97
84
|
});
|
|
98
85
|
|
|
99
|
-
|
|
100
|
-
|
|
86
|
+
it('can override the heading via attribute', () => {
|
|
87
|
+
expect(el.heading).toBe('attribute heading');
|
|
101
88
|
});
|
|
102
89
|
});
|
|
103
90
|
});
|
|
@@ -1,102 +1,88 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
test,
|
|
4
|
-
assert,
|
|
5
|
-
expect,
|
|
6
|
-
beforeAll,
|
|
7
|
-
afterAll,
|
|
8
|
-
beforeEach,
|
|
9
|
-
afterEach,
|
|
10
|
-
vi,
|
|
11
|
-
chai,
|
|
12
|
-
} from 'vitest';
|
|
13
|
-
import {type LocatorSelectors} from '@vitest/browser/context';
|
|
14
|
-
import {getElementLocatorSelectors} from '@vitest/browser/utils';
|
|
15
|
-
import {html} from 'lit';
|
|
16
|
-
import {chaiA11yAxe} from 'chai-a11y-axe';
|
|
1
|
+
import {describe, it, expect, beforeAll, afterAll, beforeEach, afterEach, vi, chai} from 'vitest';
|
|
2
|
+
import {type LocatorSelectors, utils} from 'vitest/browser';
|
|
17
3
|
import {fixture, fixtureCleanup} from '@open-wc/testing-helpers';
|
|
4
|
+
import {chaiA11yAxe} from 'chai-a11y-axe';
|
|
18
5
|
import {getDiffableHTML} from '@open-wc/semantic-dom-diff/get-diffable-html.js';
|
|
6
|
+
import {html} from 'lit';
|
|
19
7
|
import {<%= className %>} from '../src/<%= className %>.js';
|
|
20
8
|
import '../src/define/<%= tagName %>.js';
|
|
21
9
|
|
|
22
10
|
chai.use(chaiA11yAxe);
|
|
23
11
|
|
|
24
|
-
|
|
12
|
+
describe('<%= className %>', () => {
|
|
25
13
|
let el: <%= className %>;
|
|
26
14
|
let elShadowRoot: string;
|
|
27
15
|
let elLocator: LocatorSelectors;
|
|
28
16
|
|
|
29
|
-
|
|
17
|
+
describe('Semantic Dom and a11y', () => {
|
|
30
18
|
beforeAll(async () => {
|
|
31
19
|
el = await fixture(html`<<%= tagName %>>light-dom</<%= tagName %>>`);
|
|
32
20
|
elShadowRoot = el?.shadowRoot!.innerHTML;
|
|
33
|
-
elLocator = getElementLocatorSelectors(el);
|
|
21
|
+
elLocator = utils.getElementLocatorSelectors(el);
|
|
34
22
|
});
|
|
35
23
|
|
|
36
24
|
afterAll(() => {
|
|
37
25
|
fixtureCleanup();
|
|
38
26
|
});
|
|
39
27
|
|
|
40
|
-
|
|
28
|
+
it('has a default heading "Hey there" and counter 5', () => {
|
|
41
29
|
const button = elLocator.getByText('Counter: 5').query();
|
|
42
30
|
const heading = elLocator.getByText('Hey there').query();
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
expect(button).toBeTruthy();
|
|
32
|
+
expect(heading).toBeTruthy();
|
|
45
33
|
});
|
|
46
34
|
|
|
47
|
-
|
|
35
|
+
it('SHADOW DOM - Structure test', () => {
|
|
48
36
|
expect(getDiffableHTML(elShadowRoot)).toMatchSnapshot('SHADOW DOM');
|
|
49
37
|
});
|
|
50
38
|
|
|
51
|
-
|
|
39
|
+
it('LIGHT DOM - Structure test', () => {
|
|
52
40
|
expect(getDiffableHTML(el, {ignoreAttributes: ['id']})).toMatchSnapshot('LIGHT DOM');
|
|
53
41
|
});
|
|
54
42
|
|
|
55
|
-
|
|
56
|
-
await
|
|
43
|
+
it('a11y', async () => {
|
|
44
|
+
await expect(el).accessible();
|
|
57
45
|
});
|
|
58
46
|
});
|
|
59
47
|
|
|
60
|
-
|
|
48
|
+
describe('Events ', () => {
|
|
61
49
|
beforeEach(async () => {
|
|
62
50
|
el = await fixture(html`<<%= tagName %>></<%= tagName %>>`);
|
|
63
|
-
elLocator = getElementLocatorSelectors(el);
|
|
51
|
+
elLocator = utils.getElementLocatorSelectors(el);
|
|
64
52
|
});
|
|
65
53
|
|
|
66
54
|
afterEach(() => {
|
|
67
55
|
fixtureCleanup();
|
|
68
56
|
});
|
|
69
57
|
|
|
70
|
-
|
|
58
|
+
it('should increment value on click', async () => {
|
|
71
59
|
const button = elLocator.getByText('Counter: 5');
|
|
72
60
|
const elButton = button.query()!;
|
|
73
61
|
await button.dblClick();
|
|
74
62
|
await el.updateComplete;
|
|
75
|
-
|
|
63
|
+
expect(elButton.textContent).toContain('Counter: 7');
|
|
76
64
|
});
|
|
77
65
|
|
|
78
|
-
|
|
66
|
+
it('counterchange event is dispatched - vi', async () => {
|
|
79
67
|
const spyEvent = vi.spyOn(el, 'dispatchEvent');
|
|
80
68
|
const button = elLocator.getByText('Counter: 5');
|
|
81
69
|
await button.click();
|
|
82
|
-
|
|
83
|
-
const calledWithCounterChange = spyEvent.mock.lastCall?.[0].type === 'counterchange';
|
|
84
|
-
assert.isTrue(calledWithCounterChange);
|
|
70
|
+
expect(spyEvent).toHaveBeenCalledWith(expect.objectContaining({type: 'counterchange'}));
|
|
85
71
|
});
|
|
86
72
|
});
|
|
87
73
|
|
|
88
|
-
|
|
74
|
+
describe('Override ', () => {
|
|
89
75
|
beforeAll(async () => {
|
|
90
76
|
el = await fixture(html`<<%= tagName %> heading="attribute heading"></<%= tagName %>>`);
|
|
91
|
-
elLocator = getElementLocatorSelectors(el);
|
|
77
|
+
elLocator = utils.getElementLocatorSelectors(el);
|
|
92
78
|
|
|
93
79
|
return () => {
|
|
94
80
|
fixtureCleanup();
|
|
95
81
|
};
|
|
96
82
|
});
|
|
97
83
|
|
|
98
|
-
|
|
99
|
-
|
|
84
|
+
it('can override the heading via attribute', () => {
|
|
85
|
+
expect(el.heading).toBe('attribute heading');
|
|
100
86
|
});
|
|
101
87
|
});
|
|
102
88
|
});
|