When a new Angular project is created, the *.spec.ts files provide access to Jasmine functions such as "describe", "beforeEach", and expect. Despite not having an import clause for them in spec.ts files, I can click on these functions and navigate to their typed definitions.
For instance, consider logger.service.spec.ts:
import { TestBed } from '@angular/core/testing';
import { LoggerService } from './logger.service';
describe('LoggerService', () => {
let service: LoggerService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(LoggerService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
it('should return the input string', () => {
let retval = service.calculate("hello");
expect(retval).toBe("hello");
});
});
Whenever I click on "describe", it redirects me to node_modules/jasmine/index.d.ts file:
/**
* Create a group of specs (often called a suite).
* @param description Textual description of the group
* @param specDefinitions Function for Jasmine to invoke that will define inner suites a specs
*/
declare function describe(description: string, specDefinitions: () => void): void;
The seamless integration of these functionalities across the project poses the question - what mechanism enables this?