Skip to content

Testing > DI dependencies #445

Description

@baerrach

https://aurelia.io/docs/testing/components#using-a-real-parent-view-model

In "A Custom Attribute Test with Real Parent View-model and DI dependencies"

The example is

  import {StageComponent} from 'aurelia-testing';
  import {bootstrap} from 'aurelia-bootstrapper';
  import {MyComponent} from 'src/my-component';
  import {Container} from 'aurelia-dependency-injection';
  import {MyService} from 'src/my-service';
  
  describe('MyAttribute', () => {
    let component;
    let container;
    let viewModel;
    let myService;
  
    beforeEach(() => {
      container = new Container();
      myService = container.get(MyService);
      viewModel = container.get(MyComponent);
      component = StageComponent
          .withResources('src/my-attribute')
          .inView('<div my-attribute.bind="color">Bob</div>')
          .boundTo(viewModel);
    });
    //...
  });

Shouldn't the .get calls be .registerInstance instead?
How does StageComponent know about the newly created Container?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions