Skip to content
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

Error: overrideDirective is not supported in this implementation of TestComponentBuilder. #9857

Closed
wethinkagile opened this issue Jul 7, 2016 · 6 comments

Comments

@wethinkagile
Copy link

I'm submitting a ... (check one with "x")

[x ] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

  it('should select all <ion-title> directives matching text="Cancel"', () => {
        return tcb
        .overrideDirective(
                 MyComponent, MySubComponent, MockMySubComponent
        )
        .createAsync(MyComponent).then((fixture) => {
        ...

Error: overrideDirective is not supported in this implementation of TestComponentBuilder.

Expected/desired behavior

Expecting overrideDirective to work with TestComponentBuilder. I am using Angular2 RC-4

Reproduction of the problem
If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).

What is the expected behavior?

Overriding Directives in Tests

What is the motivation / use case for changing the behavior?

Unit Testing

Please tell us about your environment:

  • Angular version: 2.0.0-rc.4
  • Browser: [all | Chrome Version 51.0.2704.106 (64-bit)]
  • Language: [ "typescript@~1.8.7",]
@vicb
Copy link
Contributor

vicb commented Jul 7, 2016

Error: overrideDirective is not supported in this implementation of TestComponentBuilder.

It's a known limitation of this implementation and will be fixed in a future release.

@juliemr @vikerman more info to add ?

@vicb vicb closed this as completed Jul 7, 2016
@Bolza
Copy link

Bolza commented Jul 13, 2016

I opened a question on stackoverflow about this and then i found that using OverridingTestComponentBuilder can be a viable workaround. Is there anything that we should know about this class?

Also why this change is not documented in the changelog?

@juliemr
Copy link
Member

juliemr commented Jul 13, 2016

I'll post on SO as well, but this was not a breaking change because our test providers should give you an OverridingTestComponentBuilder by default. How are you setting up your test? (e.g. setBaseTestProviders? Using the lists provided by Angular should fix your problem. Here's an example: https://github.com/juliemr/ng2-test-seed/blob/master/karma-test-shim.js#L84

@Bolza
Copy link

Bolza commented Jul 13, 2016

Pretty much the same, only my test-setup is not async :/

import {setBaseTestProviders} from '@angular/core/testing';
import {
    TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
    TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS
} from '@angular/platform-browser-dynamic/testing';

setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
    TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);

@juliemr
Copy link
Member

juliemr commented Jul 13, 2016

@Bolza interesting, you should be just getting an OverridingTestComponentBuilder by default then. You can see the rest of my setup in that repository: https://github.com/juliemr/ng2-test-seed

I use the TestComponentBuilder to overrides things there. Could you do some searching and see if there's anything special in your setup that might be overriding the test providers somehow?

@angular-automatic-lock-bot
Copy link

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 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants