-
Notifications
You must be signed in to change notification settings - Fork 19
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
node:test
support
#308
base: native-node-runner
Are you sure you want to change the base?
node:test
support
#308
Conversation
node:test's default reporter is really limted, and doesn't print the errors that earl generates in a nice way. I replaced it with a better one, which behaves like mocha.
🦋 Changeset detectedLatest commit: 9680303 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -8,7 +8,7 @@ jobs: | |||
CI: | |||
strategy: | |||
matrix: | |||
node: ["16.x", "18.x"] | |||
node: ["18.x", "20.x", "22.x"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for the change is that 16 is EOL'ed, and I believe it doesn't support node:test
.
Also added 20 and 22 to make sure it works with them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node:test
is much better in 22. It was more experimental in the previous versions.
@@ -10,11 +10,13 @@ | |||
"lint": "biome check ./src", | |||
"lint:fix": "biome check --apply ./src", | |||
"typecheck": "tsc --noEmit", | |||
"test": "node --test --loader ts-node/esm src/*.test.ts", | |||
"test": "node --test --test-reporter=@voxpelli/node-test-pretty-reporter --loader ts-node/esm src/*.test.ts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This uses this other reporter, which takes advantage of the errors that earl generates to print a diff: https://github.com/voxpelli/node-test-pretty-reporter
I think this should be documented.
@@ -41,6 +42,6 @@ describe('stack traces for errors', () => { | |||
return nestedGetControl() | |||
} | |||
const control = nestedValidator() | |||
expect(control.file).to.equal(import.meta.url) | |||
expect(control.file).to.equal(fileURLToPath(import.meta.url)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a fix. I believe this changed in node 18/20, but import.meta.url
is a file://
URL, and control.file
is a path.
@@ -10,11 +10,14 @@ | |||
"lint": "biome check ./src", | |||
"lint:fix": "biome check --apply ./src", | |||
"typecheck": "tsc --noEmit", | |||
"test": "node --test --loader ts-node/esm src/*.test.ts", | |||
"test": "glob -c \"node --test --test-reporter=@voxpelli/node-test-pretty-reporter --loader ts-node/esm\" \"src/*.test.ts\"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The need for glob
is unfortunate. This is because npm scripts on windows don't work well with globs, and node:test
before node 22 doesn't support glob patterns natively.
ebee8f2
to
00384a8
Compare
00384a8
to
0ea81c4
Compare
0ea81c4
to
c3d5ddd
Compare
I understand what the last TODO item means now. I believe it may come from not using project references and tsc getting somewhat lost. From a separate npm project things work as expected. |
I can try to fix this, but would like to validate it with you first, as it would touch most |
No, it's not that. The problem is that the |
6c2c8ad
to
385b16e
Compare
385b16e
to
bc4ccdb
Compare
bc4ccdb
to
5425e8c
Compare
@alcuadrado Great work. Sorry I couldn't look at this earlier, I was really busy with conferences. I'll try to review this week and hopefully get this merged and released. |
Hey @sz-piotr,
I continued your work on #305 in this PR.
Your previous TODO:
examples/example-node-runner
What does the last todo item mean? I'm willing to fix it if you explain it.
Also, can I add info about
node:test
to the readme and the docs?I really really think this library +
node:test
are a great combo