Skip to content

Syntactic sugar for instantiating Components in tests #615

Closed

Description

@mhevery

Prerequisite: #614, #596

describe('MyComponent', () => {
  it('should instantiate', @Injectable (tb:Testbed) => {
    var element:Element = tb
      .directive(MyDirective, { override: [new Template(...), new Component(...)] })
      .compile({
        html: '<my-component a="b" [c]="exp">lightdom</my-component>')
      .instantiate({some instance or Type})
      .element;
    });
  });
});

@Component({
  selector: 'my-component'
})
class MyComponent{}

Activity

  1. added this to the M5: Early Adopters milestone on Feb 12, 2015
  2. vicb commented on Feb 16, 2015

    @vicb
    Contributor

    Some remarks:

    Traceur does not support types for arrow functions:
    (tb:Testbed) => null does not compile, function(tb:Testbed) { return null;} is ok
    see google/traceur-compiler#1580

    Reflexion information are not added to anonymous functions:
    If you have it(name, function(tb:Testbed) {...}) then you can not retrieve the reflexion info on the anonymous function
    see google/traceur-compiler#1760

  3. vsavkin commented on Feb 24, 2015

    @vsavkin
    Contributor

    Since testing is an important part of the Angular story, it'd be great to see a design of the test infrastructure before we start implementing it.

    For example, how do we support the following use cases:

    • Running tests synchronously using MockZone
    • Running tests asynchronously without mocking the zones api
    • Testing components in isolation (without html)
    • Testing components with html
    • Replacing injectables in the injector tree
    • Replacing directives in the component tree

    Some of them do not have a good answer in AngularDart. In Angular2, where everything is hierarchical, they will be even harder to solve.

  4. mhevery commented on Feb 24, 2015

    @mhevery
    ContributorAuthor

    I can take a stab at creating a design doc/ issues

  5. modified the milestones: M6: Material Design Support, on Mar 31, 2015
  6. vicb commented on Apr 6, 2015

    @vicb
    Contributor

    closed via #1160

  7. angular-automatic-lock-bot commented on Sep 6, 2019

    @angular-automatic-lock-bot

    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.

  8. locked and limited conversation to collaborators on Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions