Registry / testing / jasmine-ts

jasmine-ts

JSON →
library0.4.0jsnpmunverified

jasmine-ts is a command-line utility designed to simplify the process of running Jasmine tests written in TypeScript. It achieves this by leveraging `ts-node` to transpile TypeScript specifications on the fly, eliminating the need for a separate compilation step. The package is currently at version 0.4.0. Its release cadence is infrequent, suggesting an active but early-stage development. A key differentiator is its direct execution model through a single CLI command, seamlessly integrating with `package.json` scripts. It also provides robust support for configuring Jasmine reporters directly within the `jasmine.json` file, even allowing specific named exports from reporter modules using a `#` separator. Furthermore, it transparently passes through `ts-node` configuration options, offering flexibility in how TypeScript is handled during test execution. It acts as a wrapper around Jasmine and `ts-node`, streamlining the setup for TypeScript-based unit testing.

npm install jasmine-ts
INSTALL
IMPORT
SIG · JASMINE-TS
J
jasmine-ts
testingjavascriptv0.4.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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
musl
node 18226 runs
build_error
glibc
node 18226 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
Debug
Known issues
breakingThe package specifies a peer dependency for `ts-node` with a version range `>=3.2.0 <=11`. Using `ts-node` versions higher than 11 (e.g., v12+) may lead to compatibility issues or errors, as `ts-node` has undergone significant changes in newer versions, particularly regarding ESM support.
fix
Ensure your `ts-node` installation is within the compatible range (e.g., `npm i -D ts-node@^10`).
affects: >=0.4.0
gotchaFor TypeScript projects, it is crucial to install `@types/jasmine` to provide type definitions for Jasmine's global functions (`describe`, `it`, `expect`, etc.). Without these typings, the TypeScript compiler will report errors about undeclared globals.
fix
Install the type definitions: `npm i -D @types/jasmine`.
affects: >=0.0.3
deprecatedOlder versions of TypeScript (prior to 2.0) often relied on the `typings` tool for managing type definitions. For TypeScript 2.0 and later, the official method is to use `@types/` packages from npm.
fix
Avoid `typings i -DG dt~jasmine`; instead, use `npm i -D @types/jasmine`.
affects: >=0.0.3
gotcha`jasmine-ts` passes `ts-node` options through directly since version `0.1.3`. Users need to be aware of `ts-node`'s configuration options (e.g., `compilerOptions`, `files`, `transpileOnly`) to properly configure how TypeScript files are handled during testing. Incorrect `tsconfig.json` or `ts-node` options can lead to compilation or runtime errors.
fix
Consult `ts-node` documentation for relevant configuration options and ensure your `tsconfig.json` is correctly set up for your project and test environment.
affects: >=0.1.3
gotchaThe `jasmine-ts` project itself appears to be archived on GitHub as of December 3, 2022, and marked as read-only. While the package is still available on npm, active development and official support for new features or bug fixes might be limited.
fix
Consider checking for alternative tools or forks if you require features not present in the current version or need active maintenance.
affects: >=0.4.0
Errors
Common errors & fixes
Error: Cannot find module 'jasmine'
The `jasmine` package, a peer dependency, is not installed in the project.
fix
Install 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`.
fix
Downgrade `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.
fix
Install `@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.
fix
Install `@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.
fix
Ensure 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`.
Upgrade
Version history
0.4.0latest on npm
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.
Agent activity
4 hits · last 30 days
node
4
Resources