fix(ct-angular): resolve Angular imports/providers usages
This commit is contained in:
parent
89b885a273
commit
fcc1635185
|
|
@ -147,11 +147,15 @@ function collectClassMountUsages(node: T.Node): Set<string> {
|
|||
const names = new Set<string>();
|
||||
traverse(node, {
|
||||
enter: p => {
|
||||
// Treat calls to mount as component usages.
|
||||
// e.g. mount(MyComponent, ...)
|
||||
if (t.isCallExpression(p.node) && t.isIdentifier(p.node.callee) && p.node.callee.name === 'mount' && t.isIdentifier(p.node.arguments[0]))
|
||||
names.add(p.node.arguments[0].name);
|
||||
|
||||
// Treat calls to mount and all identifiers in arguments as component usages.
|
||||
// e.g. mount(MyComponent, { imports: [OtherComponent], providers: [Token]})
|
||||
if (t.isCallExpression(p.node) && t.isIdentifier(p.node.callee) && p.node.callee.name === 'mount') {
|
||||
p.traverse({
|
||||
Identifier: p => {
|
||||
names.add(p.node.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return names;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { expect, test } from "@playwright/experimental-ct-angular"
|
|||
test('render a template', async ({ mount }) => {
|
||||
const component = await mount('<h1>{{ 1 + 1 }}</h1>');
|
||||
|
||||
await expect(component.getByRole('heading')).toContainText('2');
|
||||
await expect(component).toHaveText('2');
|
||||
})
|
||||
|
||||
test('render a template with child components', async ({ mount }) => {
|
||||
|
|
@ -38,7 +38,7 @@ test('render a template with outputs', async ({ mount }) => {
|
|||
}
|
||||
});
|
||||
|
||||
component.getByRole('button').click();
|
||||
await component.getByRole('button').click();
|
||||
|
||||
await expect(async () => {expect(_message).toBe('hello')}).toPass();
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue