Unable to compose power-assert + espower in vanilla node 7 or 8
See original GitHub issueI am trying to use power-assert
to get pretty assert output in node, without using mocha or babel.
I’m trying to implement assertions by reading the documentation, but haven’t been able to get it working so far.
Here is my attempt at a “vanilla node” (no mocha) seed: https://github.com/TehShrike/power-assert-espower-repro
entry point:
require('espower-loader')({
pattern: 'test/*.js',
})
require('./test/test.js')
test/test.js:
const assert = require('power-assert')
const test = () => {
const value1 = true
const value2 = 3
assert.deepEqual({ value: value1 }, { value: value2 })
}
test()
Instead of a nice pretty error message, I get:
/Users/josh/code/power-assert-espower-repro/node_modules/empower-core/lib/decorator.js:110
ret = func.apply(thisObj, args);
^
AssertionError: { value: true } deepEqual { value: 3 }
at Decorator._callFunc (/Users/josh/code/power-assert-espower-repro/node_modules/empower-core/lib/decorator.js:110:20)
(snip)
What am I missing? I’m guessing this is a documentation/implementation issue, and not an actual bug.
(node 7.6.0)
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Creating and testing a complete Node.js Rest API (WITH NO ...
I'm gonna show you how to use only the Node.js native modules ... ... try restarting your device. Your browser can't play this...
Read more >What is “assert” in JavaScript? - Stack Overflow
The assert function then simply creates a list item, applies a class of either “pass” or “fail,” dependent upon whether your test returned...
Read more >Why the Hell Would I Use Node.js? A Case-by-case Tutorial
Node.js can solve I/O scaling, but was not created to compute scaling problems. Learn why and when to use Node.js in this case-by-case...
Read more >Math208 Discrete Mathematics - College of Arts & Sciences
11.7 Exercises. 109. 12 Special Functions. 111. 12.1 Floor and ceiling functions. 111. 12.2 Fractional part. 111. 12.3 Integral part. 112. 12.4 Power...
Read more >Known issues — nRF Connect SDK 2.2.99 documentation
If a device-bound message is sent to the device while it is in the LTE Power Saving Mode (PSM), the TCP connection will...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve figured out this.
Node.js 6
Node.js 7
Node.js 8:
(Error code is added: https://github.com/nodejs/node/pull/12651)
Actually, empower does
e.message = buildPowerAssertText(formatter, errorEvent.originalMessage, errorEvent.powerAssertContext);
.But, Node.js 7~ does not show this
e.message
of throwing AssertionError.I think that Node.js 7~ treat
AssertionError
as special object.Node 8 work fine.
After updating the dependencies in my power-assert-espower-repro repository (and removing the duplicate log/throw), this is the output using node 8: