I'm getting this error:
Error: This test module uses the component MessagesComponent which is using a "templateUrl", but they were never compiled. Please call "TestBed.compileComponents" before your test.
When trying to run this simple test Angular 2 & Jasmine Test:
let comp: MessagesComponent;
let fixture: ComponentFixture<MessagesComponent>;
describe('MessagesComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ MessagesComponent ],
providers: [ {provide: DataService, useValue: {} } ]
})
.compileComponents(); // compile template and css
fixture = TestBed.createComponent(MessagesComponent);
comp = fixture.componentInstance;
});
it('example', () => {
expect("true").toEqual("true");
});
});
I think it might be due to something with my webpack test configuration:
'use strict';
const path = require('path');
const webpack = require('webpack');
module.exports = {
devtool: 'inline-source-map',
module: {
loaders: [
{ loader: 'raw', test: /\.(css|html)$/ },
{ exclude: /node_modules/, loader: 'ts', test: /\.ts$/ }
]
},
resolve: {
extensions: ['', '.js', '.ts'],
modulesDirectories: ['node_modules'],
root: path.resolve('.', 'src')
},
tslint: {
emitErrors: true
}
};