Skip to content

Commit c9eb69d

Browse files
committed
Docs: Fix grammar in 2025-stacktrace post, update assert.throws()
1 parent 4955dd9 commit c9eb69d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

docs/_posts/2025-01-19-stacktrace-cleaner.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ Result This is actual.
3838
Source: @/test/example.js:3:10
3939
"></figure>
4040

41-
The "real" stack trace is actually quite a bit longer, but we rebase it to become trace for your assertion. We remove lines before your assertion point (i.e. QUnit calling your test function), and remove any calls after that point (i.e. code inside an assert function).
41+
The "real" stack trace is actually quite a bit longer, but we rebase it to become the trace to your assertion. We remove lines before your assertion point (i.e. QUnit calling your test function), and remove any calls after that point (i.e. code inside an assertion method).
4242

4343
This works well in browsers. But, when it comes to Node.js, we can do better!
4444

4545
## Node.js runtime internals
4646

4747
Web browsers generally don't expose their own internals to stack traces at all. For example, the internals of `fetch()`, or `setTimeout()`. [^2] Node.js implements many of its internals in JavaScript, which are sometimes visible in a stack trace.
4848

49-
Let's look a slow example test:
49+
Let's look at an example test:
5050

5151
```js
5252
QUnit.test('slow example', function (assert) {
@@ -80,7 +80,7 @@ Notice the function calls inside the virtual `note:internal` module?
8080

8181
### Hide internal frames
8282

83-
While these functions are not called inside QUnit, we hide them because this timer is scheduled by QUnit. In this case, there are other stack frames and we can omit the trace entirely, for an even cleaner result. The same result in QUnit 2.24.0:
83+
While these functions are not called inside QUnit, we hide them because this timer is scheduled by QUnit. In this case, there are no other stack frames and we can omit the trace entirely, for an even cleaner result. The same result in QUnit 2.24.0:
8484

8585
```tap
8686
TAP version 13
@@ -141,7 +141,7 @@ Notice the removal of the first `Object.on (qunit/qunit.js)` line, so that the t
141141

142142
### Trimming traces
143143

144-
For assertion failures and uncaught exceptions alike, we only trim internal frames from the start or end of a stack. Removing frames from the middle would falsely present a call relationship that never happened, and would cause confusion among developers. Instead, frames we can't trim, are greyed out instead. This works similar to Node.js' error handler.
144+
For both assertion failures and uncaught exceptions, we only trim internal frames from the start or end of a stack. Removing frames from the middle would falsely present a call relationship that never happened, and would cause confusion among developers. Instead, frames we can't trim, are greyed out. This works similar to Node.js' error handler.
145145

146146
## TAP reporter
147147

docs/api/assert/throws.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ The `expectedMatcher` argument can be:
2929
* An Error object.
3030
* An Error constructor, evaluated as `errorValue instanceof expectedMatcher`.
3131
* A RegExp that matches (or partially matches) the string representation.
32-
* A callback Function that must return `true` to pass the assertion check.
32+
* A callback with your own custom validation, that returns `true` or `false`.
3333

34-
<p class="note" markdown="1">In very few environments, like Closure Compiler, `throws` may cause an error. There you can use `assert.raises()`. It has the same signature and behaviour, just a different name.</p>
34+
<p class="note" markdown="1">If you need to comply with classic ES3 syntax, such as in early versions of Closure Compiler, you can use `assert.raises()`, which is an alias for `assert.throws()`. It has the same signature and behaviour.</p>
3535

3636
## Changelog
3737

0 commit comments

Comments
 (0)