diff --git a/src/component/props_validation.ts b/src/component/props_validation.ts index 996ffb03..4fad585e 100644 --- a/src/component/props_validation.ts +++ b/src/component/props_validation.ts @@ -37,7 +37,7 @@ QWeb.utils.validateProps = function (Widget, props: Object) { if (propsDef[propName] && !propsDef[propName].optional) { throw new Error(`Missing props '${propName}' (component '${Widget.name}')`); } else { - break; + continue; } } let isValid; diff --git a/tests/component/props_validation.test.ts b/tests/component/props_validation.test.ts index 8973cb2e..98526cfc 100644 --- a/tests/component/props_validation.test.ts +++ b/tests/component/props_validation.test.ts @@ -786,6 +786,31 @@ describe("props validation", () => { await nextTick(); expect(fixture.innerHTML).toBe("
4
"); }); + + test("mix of optional and mandatory", async () => { + class Child extends Component { + static props = { + optional: { type: String, optional: true }, + mandatory: Number, + }; + static template = xml`
`; + } + + class App extends Component { + static components = { Child }; + static template = xml`
`; + } + + const w = new App(undefined, {}); + let error; + try { + await w.mount(fixture); + } catch (e) { + error = e; + } + expect(error).toBeDefined(); + expect(error.message).toBe("Missing props 'mandatory' (component 'Child')"); + }); }); describe("default props", () => {