Skip to content

Commit

Permalink
test: add karma test showing hydration mismatch when a child componen…
Browse files Browse the repository at this point in the history
…t has scopd styles and a custom HTML template
  • Loading branch information
nrobertdehault committed Nov 14, 2024
1 parent 2efbadf commit cc7caf9
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
advancedTest(target, { Component, hydrateComponent, consoleSpy }) {
hydrateComponent(target, Component, {});

expect(consoleSpy.calls.warn).toHaveSize(0);
expect(consoleSpy.calls.error).toHaveSize(0);
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { LightningElement } from 'lwc';
import style from './component.scoped.css';
import html from './template.html';

export default class extends LightningElement {
static renderMode = 'light';
static stylesheets = [style];

render() {
return html;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
h1 {
color: red;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<template lwc:render-mode="light">
<span>hello</span>
</template>

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<template lwc:render-mode="light">
<x-component></x-component>
</template>

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { LightningElement } from 'lwc';

export default class extends LightningElement {
static renderMode = 'light';
}

0 comments on commit cc7caf9

Please sign in to comment.