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
TestComponentBuilder.createAsync() does not resolve its promise #8527
Comments
I managed to fix this by myself. It turns out my application and platform testing providers setup was wrong. Configuring the setup script like this did the trick: import { resetBaseTestProviders, setBaseTestProviders } from '@angular/core/testing';
import { BROWSER_APP_DYNAMIC_PROVIDERS } from "@angular/platform-browser-dynamic";
import {
TEST_BROWSER_STATIC_PLATFORM_PROVIDERS,
ADDITIONAL_TEST_BROWSER_PROVIDERS
} from '@angular/platform-browser/testing';
resetBaseTestProviders();
setBaseTestProviders(
TEST_BROWSER_STATIC_PLATFORM_PROVIDERS,
[
BROWSER_APP_DYNAMIC_PROVIDERS,
ADDITIONAL_TEST_BROWSER_PROVIDERS
]
); My bad! ;) |
@deeleman I'm running into this same issue w/ the default setup used by the ng-cli and https://github.com/juliemr/ng2-test-seed/blob/master/karma-test-shim.js :( /*global jasmine, __karma__, window*/
Error.stackTraceLimit = Infinity;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
__karma__.loaded = function () {
};
var distPath = '/base/.test/';
var appPath = distPath + 'app/';
function isJsFile(path) {
return path.slice(-3) == '.js';
}
function isSpecFile(path) {
return path.slice(-8) == '.spec.js';
}
function isAppFile(path) {
return isJsFile(path) && (path.substr(0, appPath.length) == appPath);
}
var allSpecFiles = Object.keys(window.__karma__.files)
.filter(isSpecFile)
.filter(isAppFile);
// Load our SystemJS configuration.
System.config({
baseURL: distPath,
});
System.import('system.config.js').then(function(e) {
// Load and configure the TestComponentBuilder.
return Promise.all([
System.import('@angular/core/testing'),
System.import('@angular/platform-browser-dynamic/testing')
]).then(function (providers) {
var testing = providers[0];
var testingBrowser = providers[1];
testing.setBaseTestProviders(
testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS
);
});
}).then(function() {
return Promise.all(
allSpecFiles.map(function (moduleName) {
return System.import(moduleName);
}));
}).then(__karma__.start, __karma__.error); |
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. |
Given a component
MyComponent
exposing a simplistic API for demo purposes, and importing the symbols we require to conduct usual component testing:I attempt to conduct a basic test injecting and instantiating the TestComponentBuilder to create a fixture component of the
MyComponent
type, like this:I always get the same error after upgrading my code to RC.1.
Error: No precompiled component MyComponent found
Basically the promise returned by
testComponentBuilder.createAsync(MyComponent)
is never resolved. The issue is consistent on all my tests encompassing the use ofTestComponentBuilder
.For the record, and prior to conduct any test, I previously configure the testing providers like this:
I've scanned the code high and low to determine wether this is an actual bug in RC.1 or an issue with my test setup, with no success. Prior to RC.1, my testing setup worked seamlessly in all specs testing components specifically.
Any pointers?
The text was updated successfully, but these errors were encountered: