Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
CLI Command
✓ "test": "jasmine-ts \"path/to/specs/**/*.spec.ts\""
✗ jasmine-ts
The primary usage is via `package.json` scripts, where `jasmine-ts` is invoked with a glob pattern for your TypeScript test files. Running `jasmine-ts` without arguments will likely result in an error as it expects a glob.
Initialization Command
✓ node_modules/.bin/jasmine-ts init
✗ jasmine-ts init
Run this command once to generate a `jasmine.json` configuration file, which can then be customized for reporters and other settings. Ensure `node_modules/.bin` is in your PATH or use the full path.
Reporter Configuration
✓ {
"reporters": [
{
"name": "jasmine-spec-reporter#SpecReporter",
"options": {
"displayStacktrace": "all"
}
}
]
}
✗ {
"reporters": [
{
"name": "jasmine-spec-reporter",
"options": {}
}
]
}
When configuring custom reporters in `jasmine.json`, use the `#` separator to reference named exports from reporter modules, as shown with `jasmine-spec-reporter#SpecReporter`.
This quickstart demonstrates how to set up `jasmine-ts` to run TypeScript-based Jasmine tests, including installation, `jasmine.json` initialization, and a minimal runnable test suite.
// 1. Initialize your project:
// npm init -y
// 2. Install dependencies:
// npm i -D jasmine jasmine-ts ts-node@^10 typescript @types/jasmine
// package.json (excerpt for scripts and devDependencies)
// {
// "scripts": {
// "test": "jasmine-ts \"./src/**/*.spec.ts\""
// },
// "devDependencies": {
// "jasmine": "^5.0.0",
// "jasmine-ts": "0.4.0",
// "ts-node": "^10.0.0", // Ensure ts-node version is <=11 for jasmine-ts 0.4.0 compatibility
// "typescript": "^5.0.0",
// "@types/jasmine": "^5.0.0"
// }
// }
// 3. Generate jasmine.json configuration file:
// node_modules/.bin/jasmine-ts init
// 4. Create a TypeScript test file (e.g., src/my.spec.ts):
describe('My test suite', () => {
let counter = 0;
beforeEach(() => {
counter++;
});
it('should increment the counter', () => {
expect(counter).toBe(1);
});
it('should have an updated counter for the next spec', () => {
expect(counter).toBe(2);
});
it('should allow async operations', async () => {
await new Promise(resolve => setTimeout(resolve, 10));
expect(true).toBe(true);
});
});
// 5. Run your tests:
// npm test
jasmine-ts --version
Errors
Common errors & fixes
Error: Cannot find module 'jasmine'
The `jasmine` package, a peer dependency, is not installed in the project.
fixInstall Jasmine: `npm i -D jasmine`
TypeError: Cannot read properties of undefined (reading 'register')
This error or similar runtime issues can occur if an incompatible version of `ts-node` is installed, especially if it's newer than the `ts-node@11` range specified by `jasmine-ts`.
fixDowngrade `ts-node` to a compatible version, for example: `npm i -D ts-node@^10`.
Type 'typeof describe' is not assignable to type '...'. Property 'name' is missing in type 'typeof describe'.
The TypeScript compiler cannot find the global type definitions for Jasmine's testing constructs.
fixInstall `@types/jasmine`: `npm i -D @types/jasmine`
Cannot find name 'describe'.
Similar to the above, this indicates missing global type definitions for Jasmine in your TypeScript environment.
fixInstall `@types/jasmine`: `npm i -D @types/jasmine`
Unknown reporter: my-custom-reporter#MyReporter
The custom reporter module is not installed, or the name/path in `jasmine.json` is incorrect, or the specific export (`#MyReporter`) does not exist.
fixEnsure the reporter package is installed (`npm i -D my-custom-reporter`) and verify the exact `name` string, including the `#` separator if applicable, in your `jasmine.json`.
Audit
Dependencies
jasminerequiredCore testing framework required for defining and running tests.
ts-noderequiredRequired for on-the-fly TypeScript compilation and execution in Node.js.
typescriptrequiredThe TypeScript compiler is necessary for type checking and transpilation.
@types/jasminerequiredProvides TypeScript type definitions for Jasmine to ensure correct type checking in test files.