-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add initial implementation (#1)
Release-As: 0.1.0
- Loading branch information
Showing
12 changed files
with
4,924 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
extends: '@meyfa/eslint-config' | ||
parserOptions: | ||
project: './tsconfig.lint.json' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
lint: | ||
name: Linting | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
cache: npm | ||
- run: npm ci | ||
- run: npm run lint | ||
|
||
test: | ||
name: test - Node.js ${{ matrix.node-version }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: | ||
- 18 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: npm | ||
- run: npm ci | ||
- run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.DS_Store | ||
.idea | ||
node_modules/ | ||
/dist | ||
.nyc_output | ||
/coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,41 @@ | ||
# ts-node-test | ||
Use the Node.js test runner, but with TypeScript via ts-node | ||
|
||
[![CI](https://github.com/meyfa/ts-node-test/actions/workflows/main.yml/badge.svg)](https://github.com/meyfa/ts-node-test/actions/workflows/main.yml) | ||
|
||
Use the [Node.js test runner](https://nodejs.org/dist/latest-v18.x/docs/api/test.html), but with TypeScript via ts-node. | ||
You need to have `typescript` installed as a (dev) dependency and must be using Node version 18.7.0 or later. | ||
|
||
Imagine it like `ts-node --test`, if that command existed. | ||
|
||
### How to use | ||
|
||
Install as a dev dependency: | ||
|
||
``` | ||
npm i -D ts-node-test | ||
``` | ||
|
||
Then add a script to your `package.json`: | ||
|
||
``` | ||
{ | ||
"scripts": { | ||
"test": "ts-node-test test-file1.ts foo/test-file2.ts another-dir/" | ||
} | ||
} | ||
``` | ||
|
||
The command syntax is similar to `node --test`. Multiple paths can be passed. Directories will be searched recursively | ||
for any files with supported extensions (currently: `.js`, `.mjs`, `.cjs`; `.ts`, `.mts`, `.cts`). | ||
Then, Node's test runner will be started on all files that were found in this process. | ||
|
||
### Why this is needed | ||
|
||
TL;DR: Node.js (at the time of writing) does not allow to override the list of extensions that are used when searching | ||
for test files. The official recommendation is to list all files explicitly. That is precisely what this CLI wrapper | ||
does behind the scenes. | ||
|
||
Please refer to the following issues for further information: | ||
|
||
* [Node.js #44023](https://github.com/nodejs/node/issues/44023) | ||
* [ts-node #1853](https://github.com/TypeStrong/ts-node/issues/1853) |
Oops, something went wrong.