Skip to content

Commit 6b41e88

Browse files
authored
chore(tests) (#6363)
* chore(tests) Uses document tree verification instead of snapshot tests to confirm rendering works for two failing tests. Tests were failing due to some limitations with the testing framework. Specifically that numerous snapshots of the same segment of HTML were not allowed in certain use cases * chore(tests) I've run the formatter and linter. Fixed a linting error in package.json where Windows machines will not run eslint if the targets are wrapped in single quotes
1 parent 7047196 commit 6b41e88

3 files changed

Lines changed: 19 additions & 24 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"clean": "rimraf --max-retries=2 build/ cli/ compiler/ dev-server/ internal/ mock-doc/ sys/node/ sys/ testing/ && npm run clean:scripts && npm run clean.screenshots",
105105
"clean.screenshots": "rimraf test/end-to-end/screenshot/builds test/end-to-end/screenshot/images",
106106
"clean:scripts": "rimraf scripts/build",
107-
"lint": "eslint 'bin/*' 'scripts/*.ts' 'scripts/**/*.ts' 'src/*.ts' 'src/**/*.ts' 'src/**/*.tsx' 'test/wdio/**/*.tsx'",
107+
"lint": "eslint bin/* scripts/*.ts scripts/**/*.ts src/*.ts src/**/*.ts src/**/*.tsx test/wdio/**/*.tsx",
108108
"install.jest": "npx tsx ./src/testing/jest/install-dependencies.mts",
109109
"prettier": "npm run prettier.base -- --write",
110110
"prettier.base": "prettier --cache \"./({bin,scripts,src,test}/**/*.{ts,tsx,js,jsx})|bin/stencil|.github/(**/)?*.(yml|yaml)|*.js\"",

test/wdio/render/render.test.tsx

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,21 @@ describe('Render VDOM', () => {
3232
</div>
3333
);
3434
render(vdom, document.body);
35-
await expect($(document.body).$('div')).toMatchInlineSnapshot(`
36-
"<div>
37-
<complex-properties class="hydrated">
38-
<template shadowrootmode="open">
39-
<style>h2 { font-size: 16px; color: red; }h2::after { content: ": from global-css-entry.css"; }:host { display: block; margin: 10px; padding: 20px; border: 5px dotted red; }h1 { font-size: 18px; color: maroon; display: flex; }h1::after { content:": from global-sass-entry.scss"; }</style>
40-
<ul>
41-
<li>this.foo.bar: 123</li>
42-
<li>this.foo.loo: 1, 2, 3</li>
43-
<li>this.foo.qux: symbol</li>
44-
<li>this.baz.get('foo'): symbol</li>
45-
<li>this.quux.has('foo'): true</li>
46-
<li>this.grault: true</li>
47-
<li>this.waldo: true</li>
48-
<li>this.kidsNames: John, Jane, Jim</li>
49-
</ul>
50-
</template>
51-
</complex-properties>
52-
</div>"
53-
`);
35+
36+
// Use separate assertions instead of inline snapshot to avoid framework issues
37+
const component = await $('complex-properties');
38+
await expect(component).toExist();
39+
await expect(component).toHaveElementClass('hydrated');
40+
41+
// Verify each prop value is rendered correctly
42+
const listItems = await component.$$('li');
43+
await expect(listItems[0]).toHaveText('this.foo.bar: 123');
44+
await expect(listItems[1]).toHaveText('this.foo.loo: 1, 2, 3');
45+
await expect(listItems[2]).toHaveText('this.foo.qux: symbol');
46+
await expect(listItems[3]).toHaveText("this.baz.get('foo'): symbol");
47+
await expect(listItems[4]).toHaveText("this.quux.has('foo'): true");
48+
await expect(listItems[5]).toHaveText('this.grault: true');
49+
await expect(listItems[6]).toHaveText('this.waldo: true');
50+
await expect(listItems[7]).toHaveText('this.kidsNames: John, Jane, Jim');
5451
});
5552
});

test/wdio/text-content-patch/cmp.test.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ describe('textContent patch', () => {
2424
describe('scoped encapsulation', () => {
2525
it('should return the content of all slots', async () => {
2626
const elm = $('text-content-patch-scoped-with-slot');
27-
await expect(elm.getText()).toMatchInlineSnapshot(`
28-
"Slot content
29-
Suffix content"`);
27+
await expect(await elm.getText()).toBe('Slot content\nSuffix content');
3028
});
3129

3230
it('should return an empty string if there is no slotted content', async () => {
@@ -43,7 +41,7 @@ Suffix content"`);
4341
elm as any as HTMLElement,
4442
);
4543

46-
await expect(elm.getText()).toMatchInlineSnapshot(`"New slot content"`);
44+
await expect(await elm.getText()).toBe('New slot content');
4745
});
4846

4947
it('should not insert the text node if there is no default slot', async () => {

0 commit comments

Comments
 (0)