-
Notifications
You must be signed in to change notification settings - Fork 67
chore: approach Node.js' "suites and tests" way of testing #328
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
Conversation
|
@iStefo, feel free to give this a look-see and propose changes. |
(now that I can read it following having the test-reporter set to =spec)
| "markdownlint": "markdownlint *.md ./github/**/*.md", | ||
| "shellcheck": "shellcheck .github/workflows/*.sh", | ||
| "test": "node test/setup-beam.test.js", | ||
| "test": "node --test --test-reporter=spec", |
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.
Without --test-reporter=spec ::debug:: gets output as # ::debug:: which means GitHub Actions can't understand debug is off.
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.
LGTM ❤️
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.
I appreciate you adopting the node test runner!
I think it greatly helps structuring tests, having a standardized way of configuring each test's preconditions (see my comment), identifying individual test failures and also allows executing specific parts of the suits in isolation (which is faster and avoids cluttering the the console with output from other tests).
So big 👍 from my side
| 'https://repo.hex.pm, https://cdn.jsdelivr.net/hex', | ||
| { multiline: true }, | ||
| ) | ||
| const previousRunnerArch = process.env.RUNNER_ARCH |
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.
Configuring or restoring environment and mocks should general happen in before/after or beforeEach/afterEach blocks. This helps readers understand that setup/teardown code is being run (in contrast to code that dynamically generates test cases) and ensure that the modifications actually happen at the correct time (afaik the test runner doesn't necessarily execute the tests in the moment they are defined using it)
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.
Good to know, thanks. 👍 For now, I just wanted to have a base building block.
|
This change was released in v1.19.0, also tagged |
Description
This change stemmed from a proposal in #327.
The goal of the change is to approach a more modern (and readable?) way of writing tests and looking at execution output.
I didn't bother to review the existing tests, but only to propose a new format for writing them. If needed I can revise them in a different pull request, which means "This pull request is probably best seen with
Hide whitespaceenabled".Ref.: https://nodejs.org/api/test.html#describe-and-it-aliases.
Further considerations
changes regarding Gleam aren't "this pull request" -specific, but they make "this pull request"'s CI fail, which is why I added them here. If you want I can do it in a separate pull request, though.
changes regarding Ubuntu-24.04 aren't "this pull request" -specific, but they make "this pull request"'s CI fail (or get warned on), which is why I added them here. If you want I can do it in a separate pull request, though.