Java2TypeScript JUnit

raw JSON →
92.0.0 verified Fri May 01 auth: no javascript

Required runtime dependency for the J2TS transpiler that converts Java code to TypeScript. Version 92.0.0 is current. The package provides JUnit-like annotations and test infrastructure for transpiled TypeScript tests. Closely tied to the J2TS ecosystem; not useful standalone. Updated infrequently alongside the transpiler. No alternatives exist for J2TS projects.

error Cannot find module 'j2ts-junit'
cause Package not installed or not in node_modules.
fix
Run 'npm install j2ts-junit' and ensure it is in package.json dependencies.
error TypeError: Class extends value undefined is not a constructor or null
cause Missing runtime dependency from J2TS transpiler.
fix
Ensure 'j2ts-core' is also installed and at compatible version.
gotcha Package is tied to J2TS transpiler version; mismatched versions may cause runtime errors.
fix Keep j2ts-junit version aligned with the J2TS transpiler version used in your project.
deprecated The Assert class methods may be deprecated in favor of chai or other assertion libraries in future versions.
fix Check changelog for assertion migration guidance.
npm install j2ts-junit
yarn add j2ts-junit
pnpm add j2ts-junit

Example of JUnit-style test using decorators and assertions in TypeScript.

import { Test, Before, After, Assert } from 'j2ts-junit';

class MyTest {
  @Before
  setup(): void {
    console.log('setup');
  }

  @Test
  testAddition(): void {
    Assert.assertEquals(4, 2 + 2);
  }

  @After
  teardown(): void {
    console.log('teardown');
  }
}