You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/_posts/2025-01-19-stacktrace-cleaner.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,15 +38,15 @@ Result This is actual.
38
38
Source: @/test/example.js:3:10
39
39
"></figure>
40
40
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).
42
42
43
43
This works well in browsers. But, when it comes to Node.js, we can do better!
44
44
45
45
## Node.js runtime internals
46
46
47
47
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.
48
48
49
-
Let's look a slow example test:
49
+
Let's look at an example test:
50
50
51
51
```js
52
52
QUnit.test('slow example', function (assert) {
@@ -80,7 +80,7 @@ Notice the function calls inside the virtual `note:internal` module?
80
80
81
81
### Hide internal frames
82
82
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:
84
84
85
85
```tap
86
86
TAP version 13
@@ -141,7 +141,7 @@ Notice the removal of the first `Object.on (qunit/qunit.js)` line, so that the t
141
141
142
142
### Trimming traces
143
143
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.
Copy file name to clipboardExpand all lines: docs/api/assert/throws.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,9 +29,9 @@ The `expectedMatcher` argument can be:
29
29
* An Error object.
30
30
* An Error constructor, evaluated as `errorValue instanceof expectedMatcher`.
31
31
* 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`.
33
33
34
-
<pclass="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
+
<pclass="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>
0 commit comments