[IMP] app: throw error when static components key is missing in parent

This commit improves the error message that's thrown when a static
component definition is missing, as outlined in issue #1286.
This commit is contained in:
tom hunkapiller
2022-10-29 14:12:49 -05:00
committed by Sam Degueldre
parent 620e41daa1
commit 3d49daedcd
3 changed files with 39 additions and 1 deletions
+17
View File
@@ -126,6 +126,23 @@ describe("basics", () => {
);
});
test("display a nice error if the components key is missing with subcomponents", async () => {
class Parent extends Component {
static template = xml`<div><MissingChild /></div>`;
}
const app = new App(Parent as typeof Component);
let error: Error;
const mountProm = app.mount(fixture).catch((e: Error) => (error = e));
await expect(nextAppError(app)).resolves.toThrow(
'Cannot find the definition of component "MissingChild", missing static components key in parent'
);
await mountProm;
expect(error!).toBeDefined();
expect(error!.message).toBe(
'Cannot find the definition of component "MissingChild", missing static components key in parent'
);
});
test("simple catchError", async () => {
class Boom extends Component {
static template = xml`<div t-esc="a.b.c"/>`;