swc-project / swc-project/swc-node

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

Open
#933 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2k
Forks
95
Avg merge
14d 11h
Merged PRs (30d)
1

Description

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'.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the test command from the linked minimal example with Node.js 22.15.0 and @swc-node/register 1.10.10, starting with src/myClass.test.ts and the MyClass definition. Compare the output while removing individual properties or methods, and consider the issue resolved when the unchanged example reports all tests as passing.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
testing-qa, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.