diff --git a/src/app/app.ts b/src/app/app.ts index a4ea1f9e..cc5fcdff 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -60,6 +60,9 @@ export class App< mount(target: HTMLElement, options?: MountOptions): Promise & InstanceType> { App.validateTarget(target); + if (this.dev) { + this.helpers.validateProps(this.Root, this.props); + } const node = this.makeNode(this.Root, this.props); const prom = this.mountNode(node, target, options); this.root = node; diff --git a/tests/components/props_validation.test.ts b/tests/components/props_validation.test.ts index d21b4cac..e80a44a6 100644 --- a/tests/components/props_validation.test.ts +++ b/tests/components/props_validation.test.ts @@ -87,6 +87,22 @@ describe("props validation", () => { expect(error!.message).toBe("Invalid props for component 'SubComp': 'message' is missing"); }); + test("validate props for root component", async () => { + class Root extends Component { + static props = ["message"]; + static template = xml`
`; + } + + let error: Error; + try { + await mount(Root, fixture, { dev: true }); + } catch (e) { + error = e as Error; + } + expect(error!).toBeDefined(); + expect(error!.message).toBe("Invalid props for component 'Root': 'message' is missing"); + }); + test("validate simple types", async () => { const Tests = [ { type: Number, ok: 1, ko: "1" },