Skip to content

How to run the Node built-in testrunner for TypeScript files inside a specific directory? #3902

Closed
nodejs/node
#55081
@jtuchel

Description

@jtuchel

Details

I want to replace Mocha tests with the built-in testrunner. All tests are inside a test directory and follow the pattern

...Tests.ts

I started with a fooTests.ts file

import assert from 'assert/strict';
import test from 'node:test';

test('1 is equal to 1.', () => {
  assert.strictEqual(1, 1);
});

and added the npm script

"test": "node --test ./test/**/*Tests.ts",

The script fails with the message

Could not find '/home/.../test/**/*Tests.ts'

How can I fix the script to

  • test files matching the path ./test/**/*Tests.ts only
  • run with TS files ( I'm pretty sure I must use ts-node for this )

? Thanks in advance!

Node.js version

v18

Operating system

Linux ( Ubuntu 22.04 )

Scope

Built-in testrunner

Module and version

Not applicable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions