Skip to content

Running a test with the node-runner reports an error after everything was sucessfull #933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JonasDoe opened this issue May 12, 2025 · 0 comments

Comments

@JonasDoe
Copy link

JonasDoe commented May 12, 2025

I've created a minimal example: https://github.com/JonasDoe/swc-node-issue

When I run a test in this example, I get this log:

> swc-node@1.0.0 test:swc-node
> node --import @swc-node/register/esm-register --test src/**/*.test.ts

▶ MyClass
  ✔ should not return an error after the assertion (0.5667ms)
✔ MyClass (1.3728ms)
✖ src\myClass.test.ts (507.915ms)
ℹ tests 2
ℹ suites 1
ℹ pass 1
ℹ fail 1
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 514.5506

✖ failing tests:

test at src\myClass.test.ts:1:1
✖ src\myClass.test.ts (507.915ms)
  'test failed'

The tests does nothing more than creating an instance of myClass (without that, it would succeed):

import * as assert from 'assert';
import {describe, it} from 'node:test';
import {MyClass} from "./myClass.js";

describe('MyClass', () => {
    it('should not return an error after the assertion', () => {
        new MyClass()
        assert.ok(true)
    })
})

MyClass looks like this:

export class MyClass {
     prop1?: string;
     prop2?: string;
     prop3?: string;
     prop4?: string;
     prop5?: string;

    constructor() {}

    get p1() {return this.prop1;}
    get p2() {return this.prop2;}
    method1() {}
    method2() {}
    method3() {}
    method4() {}
}

So for some reason my tests is reported as failure besides everything was successful.

The curious thing is: when I remove even a single property or method in MyClass, the test succeds, though.

I'm using @swc-node/register@1.10.10 and Node.js@v22.15.0 under Windows 11 with type: 'module'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant