You can use predefined JS library stubs in Webstorm/PHPStorm/Idea
- Open File > Settings...
- Select Languages & Frameworks > JavaScript > Libraries
- Click on Download...
- Swich to TypeScript community stubs
- Find karma-jasmine (originally under the name jasmine) (If this does not work, try jasmine instead)
- Click on Download and Install
I am using this setup with Jasmine 2.0
>=RC.5
import the RouterModule
See also https://angular.io/guide/router
@NgModule({
imports: [RouterModule],
...
})
>=RC.2
app.routes.ts
import { provideRouter, RouterConfig } from '@angular/router';
export const routes: RouterConfig = [
...
];
export const APP_ROUTER_PROVIDERS = [provideRouter(routes)];
main.ts
import { bootstrap } from '@angular/platform-browser-dynamic';
import { APP_ROUTER_PROVIDERS } from './app.routes';
bootstrap(AppComponent, [APP_ROUTER_PROVIDERS]);
<=RC.1
Your code is missing
@Component({
...
directives: [ROUTER_DIRECTIVES],
...)}
You can't use directives like routerLink
or router-outlet
without making them known to your component.
While directive names were changed to be case-sensitive in Angular2, elements still use -
in the name like <router-outlet>
to be compatible with the web-components spec which require a -
in the name of custom elements.
register globally
To make ROUTER_DIRECTIVES
globally available, add this provider to bootstrap(...)
:
provide(PLATFORM_DIRECTIVES, {useValue: [ROUTER_DIRECTIVES], multi: true})
then it's no longer necessary to add ROUTER_DIRECTIVES
to each component.
Best Answer
Each of your
.spec.ts
file have all its tests grouped indescribe
block like this:describe('SomeComponent', () => {...}
You can easily run just this single block, by prefixing the
describe
function name withf
:fdescribe('SomeComponent', () => {...}
If you have such function, no other
describe
blocks will run. Btw. you can do similar thing withit
=>fit
and there is also a "blacklist" version -x
. So:fdescribe
andfit
causes only functions marked this way to runxdescribe
andxit
causes all but functions marked this way to run