How to add console.log to test source code
See original GitHub issueI’d like to add console.logs inside my code to see what’s going on.
In as-pect.config.js
, I’ve got
imports: {
console: {
log(msg) {
console.log(msg)
},
},
},
In a globals.d.ts
file I have
declare const console: {
log(a: any): void
}
In my AS source I have things like console.log(whatever)
and my IDE doesn’t have any issue with it.
But when I run tests it says
ERROR TS2304: Cannot find name 'console'.
console.log('HELLO --------------------- ')
~~~~~~~
My globals.d.ts
is listed in tsconfig.json
, and it works fine with asc
.
Is there something I have to do for it to work specifically in asp
?
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (12 by maintainers)
Top Results From Across the Web
How To Test Console Log - DEV Community
In Jest, we have two ways to verify that console.log was called as we expect it to be. First, we can mock the...
Read more >Console.log statements output nothing at all in Jest
Run console.debug('Message here', yourValueHere) inside test function and it should show in the console output when running test script. You can verify if...
Read more >JavaScript Console.log() Example – How to Print to the ...
Just open the console, Ctrl+Shift+K or F12 , and in the top right you will see a button that says "Switch to multi-line...
Read more >Log messages in the Console - Chrome Developers
# Filter by message source · Click Show Console Sidebar Show Console Sidebar. . The Sidebar. · Click the Expand Expand. icon next...
Read more >console.log does not output when running tests #2441 - GitHub
Calling console. log using the default testEnvironment of jsdom doesn't print to stdout. If the current behavior is a bug, please provide the ......
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 re-worded my previous to last comment, I didn’t mean to sound too critical! as-pect is super nice already. 😃
Cool. Thanks! 🙏 😃