New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ivy): implement TestBed #25369
feat(ivy): implement TestBed #25369
Conversation
ff03264
to
ecb9d18
Compare
@@ -201,6 +201,11 @@ export function getCreationMode(): boolean { | |||
*/ | |||
let viewData: LViewData; | |||
|
|||
export function getViewData(): LViewData { | |||
// top level variables should not be exported for performance reasons (PERF_NOTES.md) | |||
return viewData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exported already through _getViewData
261b70d
to
ba51342
Compare
const isInternalRootView = rootSelectorOrNode === undefined; | ||
|
||
const rendererFactory = | ||
ngModule ? ngModule.injector.get(RendererFactory2) : domRendererFactory3; | ||
(ngModule ? wrapRendererFactory2(ngModule.injector.get(RendererFactory2)) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs be done in a way where we don't pull in the TestBed codebase into production application.
const wrapper = ngModule.injector.get(WraperToken, Optional);
let render2 = ngModule.injector.get(RendererFactory2);
if (wrapper) {
renderer2 = wrapper(render2);
}
@@ -31,13 +30,12 @@ declare global { | |||
rendererRemoveNode: number; | |||
rendererCreateComment: number; | |||
} | |||
const ngDebugRenderer: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert whole file.
@@ -0,0 +1,258 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to @angular/core/testing
.
/** | ||
* Base interface to resolve `@Component`, `@Directive`, `@Pipe` and `@NgModule`. | ||
*/ | ||
export interface Resolver<T> { resolve(type: Type<any>): T|null; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to @angular/core/testing
export function defineNgModule({bootstrap}: {bootstrap?: Type<any>[]}): | ||
NgModuleDef<any, any, any, any> { | ||
return ({ bootstrap: bootstrap || [], } as any); | ||
if (ivyEnabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to ivyEnabled && describe(...
so that we don't have every line changed by you.
export declare function resetFakeAsyncZone(): void; | ||
|
||
export declare class TestBed implements Injector { | ||
export declare class _ViewEngineTestBed implements Injector { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change name to TestBedViewEngine
or TestBed2
so that order is preserved.
/** @experimental */ | ||
export declare function resetFakeAsyncZone(): void; | ||
|
||
export declare const TestBed: typeof _Render3TestBed | typeof _ViewEngineTestBed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_Render3TestBed
seems to be missing from export. Also rename to TestBed3
5713bb5
to
9677059
Compare
86b0064
to
89aed19
Compare
@vicb I looked at the failing integration/bazel test and it looks like the
That bundle is not included in the devserver since it was an AOT build. Is |
The bundles included in the devserver in the
|
For reference, the core bundle on angular master master looks like this:
|
You can preview 89f7b91 at https://pr25369-89f7b91.ngbuilds.io/. |
You can preview bb6fc89 at https://pr25369-bb6fc89.ngbuilds.io/. |
You can preview d2d5100 at https://pr25369-d2d5100.ngbuilds.io/. |
You can preview 106703a at https://pr25369-106703a.ngbuilds.io/. |
You can preview d084e80 at https://pr25369-d084e80.ngbuilds.io/. |
@mhevery approved the changed (which apparently do not dismiss prior "requesting changes")
Waiting for g3 to go green before re-presubmitting. |
You can preview 460d984 at https://pr25369-460d984.ngbuilds.io/. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
The goal of this PR is to implement the
TestBed
for IVY so that tests relying on it could be run either for the ViewEngine or for the Render3 without having to modify the test file.bazel test <target>
to execute a test targeting the ViewEnginebazel test <target> --define=compile=jit
to execute a test targeting the Render3This PR also add a spec for the
TestBed
itself which can be run for either the ViewEngine or Render3:bazel test packages/core/test:test
runs the ViewEngine testsbazel test packages/core/test:test --define=compile=jit
runs the Render3 testsNote that in the second case (Render3) there will be quite some errors due to the fact that much more specs than the TestBed spec are executed. You might want to
fdescribe
the TestBed spec for now when adding functionality.Notes
TestBed
now point to either_Render3TestBed
or_ViewEngineTestBed
depending on if IVY is respectively enabled (--define=compile=jit
) or not._Render3TestBed
and_ViewEngineTestBed
do not implement a common interface / extends a base class because it would be hard to do with the static methods. However they have a compatible interface and the code would not compile w/o errors if it was not the case.Todo
see #25389
Recommended usage
Because of the high number of failing tests using IVY, the best for now is to
fdescribe
a test suite (ieNgFor
spec and execute the spec against IVYbazel test packages/common/test:test[_web]
and fix the errors by_Render3TestBed
,DebugContext
orDebugNode