Skip to content

Angular2 testing: TestBed - #1160

Merged
vicb merged 5 commits into
angular:masterfrom
vicb:0330-test
Apr 6, 2015
Merged

vicb merged 5 commits into
angular:masterfrom
vicb:0330-test

Conversation

@vicb

@vicb vicb commented Mar 30, 2015

Copy link
Copy Markdown
Contributor

todos:

  • rename async: AsyncTestCompleter

@vicb
vicb force-pushed the 0330-test branch 2 times, most recently from 808e975 to 0e509f4 Compare March 31, 2015 14:56

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return type: 'void'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

void as well?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the "equivalent" to stabilization from ng1?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In ng2 the change detection is always executed only once (vs until il stabilizes in ng1) because the cd graph is a DAG.
So yes it could be thought as the equivalent.

@vicb
vicb force-pushed the 0330-test branch 2 times, most recently from 5ddb8b3 to ce58fad Compare March 31, 2015 19:11
@vicb vicb changed the title [WIP] Angular2 testing: TestBed Angular2 testing: TestBed Mar 31, 2015
@vicb

vicb commented Mar 31, 2015

Copy link
Copy Markdown
Contributor Author

+ @mhevery @yjbanov could you please review the PR

@vicb
vicb force-pushed the 0330-test branch 2 times, most recently from 9912088 to f4e973a Compare March 31, 2015 19:23

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Dart 1.9+ async is a keyword. Let's not use it in variable names.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.
Added a todo in this PR, we'll rename right before merging.

@yjbanov

yjbanov commented Apr 1, 2015

Copy link
Copy Markdown
Contributor

This is certainly an improvement for Angular's own tests. However, this is not something we can expose to users. View is an internal class. External API should not expose it. Also, I'm not sure if this supports the requirements listed in #1146, so I'd prefer that we keep #1146 open.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would overriding the template this way mean we won't be able to run tests in static mode? We certainly want to be able to do this once transformers are ready. (This comments applies to other methods in this class)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no problem running tests in static mode.
A @Component could have many @Template annotations and the TemplateResolver returns the active one. The code here wraps the resolver to return an overridden Template, no matter what the underlying annotations are.

@vicb

vicb commented Apr 1, 2015

Copy link
Copy Markdown
Contributor Author

@yjbanov what about providing an (extra) higher level API targeted to end user ? will still need the lower level API for core tests.

Agree to keep 1146 opened until then. While most features in 1146 should be doable, I still have no clue how we could implement something like FakeAsync in JS. Timers should be ok, however there is no microtask hooks in JS that would allow to microleap.

/ref angular/zone.js#59, #1116

@vicb

vicb commented Apr 1, 2015

Copy link
Copy Markdown
Contributor Author

@yjbanov I've updated the design doc & added a last commit with a more end user friendly API. I would appreciate your feedback on those.

I'd like to push the async tests to some further PR in order not to delay the merge of this one.

We also need to discuss about the declarative API (@TestComponent) - let have a chat today if you're available.

@yjbanov

yjbanov commented Apr 2, 2015

Copy link
Copy Markdown
Contributor

I didn't mean to imply that you fix the API in this request (indeed I should have LGTM'd immediately). The original goal seemed to be to simplify the testbed for Angular's own tests. I'd say in that respect mission accomplished.

As for publicly facing API, the issue with exposing internal objects is not complexity but a promise of stability. We want the freedom to change Angular internals without breaking users, advanced or otherwise, and the only way to ensure that is to keep private objects private. So LGTM, and let's think more deeply what the public API should look like.

@yjbanov yjbanov added @lgtm action: merge The PR is ready for merge by the caretaker labels Apr 2, 2015
@vicb
vicb force-pushed the 0330-test branch 2 times, most recently from 6b7d685 to 7506680 Compare April 2, 2015 10:48
@vicb
vicb force-pushed the 0330-test branch 2 times, most recently from dfb7e04 to 7f2ab25 Compare April 2, 2015 13:46
@vicb

vicb commented Apr 2, 2015

Copy link
Copy Markdown
Contributor Author

@yjbanov ok.

/all While this PR was working fine before the render branch was merged, it now trigger an error (JS only, Dart is fine):

Chrome 39.0.2171 (Linux) ERROR: 'TypeError: Super expression must either be null or a function, not undefined.
    at getProtoParent (http://localhost:9876/base/node_modules/traceur/bin/traceur-runtime.js?0efd4bd36ca4386e3c89392aa3aa909a8694adda:965:11)
    at Object.createClass (http://localhost:9876/base/node_modules/traceur/bin/traceur-runtime.js?0efd4bd36ca4386e3c89392aa3aa909a8694adda:946:32)
    at http://localhost:9876/base/modules/angular2/src/render/dom/compiler/property_binding_parser.js:54:45
    at execute (http://localhost:9876/base/modules/angular2/src/render/dom/compiler/property_binding_parser.js:112:8)
    at ensureEvaluated (http://localhost:9876/base/node_modules/systemjs/lib/extension-register.js?5730d38b1338519d3f62780c419851412d64eae2:421:26)
    at ensureEvaluated (http://localhost:9876/base/node_modules/systemjs/lib/extension-register.js?5730d38b1338519d3f62780c419851412d64eae2:413:11)
    at ensureEvaluated (http://localhost:9876/base/node_modules/systemjs/lib/extension-register.js?5730d38b1338519d3f62780c419851412d64eae2:413:11)
    at ensureEvaluated (http://localhost:9876/base/node_modules/systemjs/lib/extension-register.js?5730d38b1338519d3f62780c419851412d64eae2:413:11)
    at ensureEvaluated (http://localhost:9876/base/node_modules/systemjs/lib/extension-register.js?5730d38b1338519d3f62780c419851412d64eae2:413:11)
    at ensureEvaluated (http://localhost:9876/base/node_modules/systemjs/lib/extension-register.js?5730d38b1338519d3f62780c419851412d64eae2:413:11)'

For some reason CompilerStep evaluates to undefined in property_binding_parser.

If any body as any clue, that would be really helpful

@vicb

vicb commented Apr 2, 2015

Copy link
Copy Markdown
Contributor Author

The last commit fixes the error (but why ???) - should we go with it for now and revisit this once we switch to TS ?

@vicb
vicb force-pushed the 0330-test branch 2 times, most recently from 11f2e44 to 61fdae6 Compare April 2, 2015 16:12
@yjbanov

yjbanov commented Apr 2, 2015

Copy link
Copy Markdown
Contributor

@tbosch @mprobst Could you please help Victor debug this traceur issue?

@mprobst

mprobst commented Apr 2, 2015

Copy link
Copy Markdown
Contributor

I don't think I can, I'm not in the office and honestly know squat about Traceur. Maybe @alexeagle can help?

@alexeagle

Copy link
Copy Markdown
Contributor

I don't know about the traceur problem either. But we do have other places where we are making temporary fixes for ts2dart and for typescript to co-exist with traceur in the short-term, so that solution is probably okay

@vicb

vicb commented Apr 6, 2015

Copy link
Copy Markdown
Contributor Author

The issue was a circular dependency (compile_control -> compile_step -> compile_control), found thanks to @arv.

The circular dependency is not introduced by this PR but was trigerred because the loading order of modules was changed by this PR. Anyway seems like it's gone after rebasing on latest master.

If Travis is green, I'll merge this.

@vicb
vicb merged commit 94a48e8 into angular:master Apr 6, 2015
@vicb vicb removed the in progress label Apr 6, 2015
@vicb
vicb deleted the 0330-test branch April 7, 2015 07:18
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants