TesBed - Error to run unit test
See original GitHub issueHello @marcoturi !! I tried use this repo structure. The jasmine Simple test works fine, but, if I create another spec that use the TestBed
angular2 class to load a component, I got the error below:
Do you know what does mean “symbol” error ? I think that needs include zone.js
library on karma.conf.js
. What dou think?
See my snippet code, after change home.spec.ts
file
import { HomePage } from './home';
import { TestBed } from '@angular/core/testing';
describe('Sales Service', () => {
let fixture: any;
let component: HomePage;
beforeEach((done) => {
TestBed.configureTestingModule({
declarations: [HomePage],
});
fixture = TestBed.createComponent(HomePage);
component = fixture.componentInstance;
done();
});
it('should load component', (done) => {
expect(fixture).toBeDefined();
expect(component).toBeDefined();
done();
});
});
OBS: Needs perform npm install --save rxjs-es
to store in package.json
file. Your karma.conf.js
require this 😃
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
How to resolve unit testcase error in Angular - Stack Overflow
If you don't care about Component1 being rendered while running unit tests of Component2 , you can use schemas: [NO_ERRORS_SCHEMA].
Read more >Unit test should fail if an element is not known #36430 - GitHub
Having errors in console with unit tests passing is not good. I use this snippet: const originalConsoleError = window.console.error; const ...
Read more >Angular unit testing tutorial with examples - LogRocket Blog
This tutorial demonstrates how to build an Angular app and write a unit test, test an async operator, and automatically generate a unit ......
Read more >Component testing scenarios - Angular
Error : This test module uses the component BannerComponent which is using a "templateUrl" or "styleUrls", but they were never compiled. Please call...
Read more >Testing Services – Testing Angular
In the unit test, we replace the dependency with a fake that ... For testing Services with dependencies, we will use the TestBed...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://github.com/driftyco/ionic-app-scripts/issues/51 Looks like ionic team is implementing e2e and unit tests by default (over angular cli).
Hello guys!! @marcoturi and @NelsonBrandao, I was did these changes on
files
karma param, and the ‘Zone undefined error is gone’. However, I got a lot of many errors haha. But, I’ve added the minors files like your snippet @NelsonBrandao!So, I created this gist today: https://gist.github.com/mfdeveloper/d9349dea78ba34a36adc7ada56ffd0c0
There, you will find the implementations:
1 - Fix the
injector of null
error andplatform
error with this line:2 - Remove
console.log(process...)
fromhome.ts
file, to avoidprocess undefined
error.Now, I got the error:
Uncaught SyntaxError: Unexpected token export
I think that this happens because Ionic2 has so many components/services dependencies on their flow. But, I don’t know which the dependency
token
is. I tried use theNO_ERRORS_SCHEMA
onTestBed.configureTestingModule
method (like official angular doc link: https://angular.io/docs/ts/latest/guide/testing.html#!#shallow-component-test) , but the same error is displayed for me 😦OBS: I created this gist instead a pull request because this isn’t working by now.